decline
This commit is contained in:
parent
b98663e589
commit
c83fe38f4a
|
|
@ -193,13 +193,12 @@ def process_dsv_file(
|
||||||
):
|
):
|
||||||
commands = []
|
commands = []
|
||||||
if _include_comments():
|
if _include_comments():
|
||||||
commands.append(FORMAT_STR_COMMENT_LINE.format_map({
|
commands.append(FORMAT_STR_COMMENT_LINE.format_map({'comment': dsv_path}))
|
||||||
'comment': dsv_path}))
|
|
||||||
with open(dsv_path, 'r') as h:
|
with open(dsv_path, 'r') as h:
|
||||||
content = h.read()
|
content = h.read()
|
||||||
lines = content.splitlines()
|
lines = content.splitlines()
|
||||||
|
|
||||||
basename_map = OrderedDict()
|
basenames = OrderedDict()
|
||||||
for i, line in enumerate(lines):
|
for i, line in enumerate(lines):
|
||||||
# skip over empty or whitespace-only lines
|
# skip over empty or whitespace-only lines
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
|
|
@ -224,21 +223,21 @@ def process_dsv_file(
|
||||||
else:
|
else:
|
||||||
# group remaining source lines by basename
|
# group remaining source lines by basename
|
||||||
path_without_ext, ext = os.path.splitext(remainder)
|
path_without_ext, ext = os.path.splitext(remainder)
|
||||||
if path_without_ext not in basename_map:
|
if path_without_ext not in basenames:
|
||||||
basename_map[path_without_ext] = set()
|
basenames[path_without_ext] = set()
|
||||||
assert ext.startswith('.')
|
assert ext.startswith('.')
|
||||||
ext = ext[1:]
|
ext = ext[1:]
|
||||||
if ext in (primary_extension, additional_extension):
|
if ext in (primary_extension, additional_extension):
|
||||||
basename_map[path_without_ext].add(ext)
|
basenames[path_without_ext].add(ext)
|
||||||
|
|
||||||
# add the dsv extension to each basename if the file exists
|
# add the dsv extension to each basename if the file exists
|
||||||
for basename, extensions in basename_map.items():
|
for basename, extensions in basenames.items():
|
||||||
if not os.path.isabs(basename):
|
if not os.path.isabs(basename):
|
||||||
basename = os.path.join(prefix, basename)
|
basename = os.path.join(prefix, basename)
|
||||||
if os.path.exists(basename + '.dsv'):
|
if os.path.exists(basename + '.dsv'):
|
||||||
extensions.add('dsv')
|
extensions.add('dsv')
|
||||||
|
|
||||||
for basename, extensions in basename_map.items():
|
for basename, extensions in basenames.items():
|
||||||
if not os.path.isabs(basename):
|
if not os.path.isabs(basename):
|
||||||
basename = os.path.join(prefix, basename)
|
basename = os.path.join(prefix, basename)
|
||||||
if 'dsv' in extensions:
|
if 'dsv' in extensions:
|
||||||
|
|
@ -305,8 +304,8 @@ def handle_dsv_types_except_source(type_, remainder, prefix):
|
||||||
comment = f'skip extending {env_name} with not existing ' \
|
comment = f'skip extending {env_name} with not existing ' \
|
||||||
f'path: {value}'
|
f'path: {value}'
|
||||||
if _include_comments():
|
if _include_comments():
|
||||||
commands.append(FORMAT_STR_COMMENT_LINE.format_map({
|
commands.append(
|
||||||
'comment': comment}))
|
FORMAT_STR_COMMENT_LINE.format_map({'comment': comment}))
|
||||||
elif type_ == DSV_TYPE_APPEND_NON_DUPLICATE:
|
elif type_ == DSV_TYPE_APPEND_NON_DUPLICATE:
|
||||||
commands += _append_unique_value(env_name, value)
|
commands += _append_unique_value(env_name, value)
|
||||||
else:
|
else:
|
||||||
|
|
@ -321,15 +320,15 @@ env_state = {}
|
||||||
|
|
||||||
|
|
||||||
def _append_unique_value(name, value):
|
def _append_unique_value(name, value):
|
||||||
|
global env_state
|
||||||
if name not in env_state:
|
if name not in env_state:
|
||||||
if os.environ.get(name):
|
if os.environ.get(name):
|
||||||
env_state[name] = set(os.environ[name].split(os.pathsep))
|
env_state[name] = set(os.environ[name].split(os.pathsep))
|
||||||
else:
|
else:
|
||||||
env_state[name] = set()
|
env_state[name] = set()
|
||||||
# Append even if the variable has not been set yet, in case a shell script
|
# append even if the variable has not been set yet, in case a shell script sets the
|
||||||
# sets the same variable without the knowledge of this Python script.
|
# same variable without the knowledge of this Python script.
|
||||||
# Later, _remove_ending_separators() will cleanup any unintentional
|
# later _remove_ending_separators() will cleanup any unintentional leading separator
|
||||||
# leading separator.
|
|
||||||
extend = FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + os.pathsep
|
extend = FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + os.pathsep
|
||||||
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
||||||
{'name': name, 'value': extend + value})
|
{'name': name, 'value': extend + value})
|
||||||
|
|
@ -343,15 +342,15 @@ def _append_unique_value(name, value):
|
||||||
|
|
||||||
|
|
||||||
def _prepend_unique_value(name, value):
|
def _prepend_unique_value(name, value):
|
||||||
|
global env_state
|
||||||
if name not in env_state:
|
if name not in env_state:
|
||||||
if os.environ.get(name):
|
if os.environ.get(name):
|
||||||
env_state[name] = set(os.environ[name].split(os.pathsep))
|
env_state[name] = set(os.environ[name].split(os.pathsep))
|
||||||
else:
|
else:
|
||||||
env_state[name] = set()
|
env_state[name] = set()
|
||||||
# Prepend even if the variable has not been set yet, in case a shell script
|
# prepend even if the variable has not been set yet, in case a shell script sets the
|
||||||
# sets the same variable without the knowledge of this Python script.
|
# same variable without the knowledge of this Python script.
|
||||||
# Later, _remove_ending_separators() will cleanup any unintentional
|
# later _remove_ending_separators() will cleanup any unintentional trailing separator
|
||||||
# trailing separator.
|
|
||||||
extend = os.pathsep + FORMAT_STR_USE_ENV_VAR.format_map({'name': name})
|
extend = os.pathsep + FORMAT_STR_USE_ENV_VAR.format_map({'name': name})
|
||||||
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
||||||
{'name': name, 'value': value + extend})
|
{'name': name, 'value': value + extend})
|
||||||
|
|
@ -370,10 +369,10 @@ def _remove_ending_separators():
|
||||||
if FORMAT_STR_REMOVE_TRAILING_SEPARATOR is None:
|
if FORMAT_STR_REMOVE_TRAILING_SEPARATOR is None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
global env_state
|
||||||
commands = []
|
commands = []
|
||||||
for name in env_state:
|
for name in env_state:
|
||||||
# skip variables that already had values before this script started
|
# skip variables that already had values before this script started prepending
|
||||||
# appending/prepending
|
|
||||||
if name in os.environ:
|
if name in os.environ:
|
||||||
continue
|
continue
|
||||||
commands += [
|
commands += [
|
||||||
|
|
@ -383,6 +382,7 @@ def _remove_ending_separators():
|
||||||
|
|
||||||
|
|
||||||
def _set(name, value):
|
def _set(name, value):
|
||||||
|
global env_state
|
||||||
env_state[name] = value
|
env_state[name] = value
|
||||||
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
||||||
{'name': name, 'value': value})
|
{'name': name, 'value': value})
|
||||||
|
|
@ -390,6 +390,7 @@ def _set(name, value):
|
||||||
|
|
||||||
|
|
||||||
def _set_if_unset(name, value):
|
def _set_if_unset(name, value):
|
||||||
|
global env_state
|
||||||
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
||||||
{'name': name, 'value': value})
|
{'name': name, 'value': value})
|
||||||
if env_state.get(name, os.environ.get(name)):
|
if env_state.get(name, os.environ.get(name)):
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ FORMAT_STR_COMMENT_LINE = '# {comment}'
|
||||||
FORMAT_STR_SET_ENV_VAR = 'export {name}="{value}"'
|
FORMAT_STR_SET_ENV_VAR = 'export {name}="{value}"'
|
||||||
FORMAT_STR_USE_ENV_VAR = '${name}'
|
FORMAT_STR_USE_ENV_VAR = '${name}'
|
||||||
FORMAT_STR_INVOKE_SCRIPT = 'COLCON_CURRENT_PREFIX="{prefix}" _colcon_prefix_sh_source_script "{script_path}"' # noqa: E501
|
FORMAT_STR_INVOKE_SCRIPT = 'COLCON_CURRENT_PREFIX="{prefix}" _colcon_prefix_sh_source_script "{script_path}"' # noqa: E501
|
||||||
FORMAT_STR_REMOVE_LEADING_SEPARATOR = 'export {name}=${{{name}#:}}' # noqa: E501
|
FORMAT_STR_REMOVE_LEADING_SEPARATOR = 'if [ "$(echo -n ${name} | head -c 1)" = ":" ]; then export {name}=${{{name}#?}} ; fi' # noqa: E501
|
||||||
FORMAT_STR_REMOVE_TRAILING_SEPARATOR = 'export {name}=${{{name}%:}}' # noqa: E501
|
FORMAT_STR_REMOVE_TRAILING_SEPARATOR = 'if [ "$(echo -n ${name} | tail -c 1)" = ":" ]; then export {name}=${{{name}%?}} ; fi' # noqa: E501
|
||||||
|
|
||||||
DSV_TYPE_APPEND_NON_DUPLICATE = 'append-non-duplicate'
|
DSV_TYPE_APPEND_NON_DUPLICATE = 'append-non-duplicate'
|
||||||
DSV_TYPE_PREPEND_NON_DUPLICATE = 'prepend-non-duplicate'
|
DSV_TYPE_PREPEND_NON_DUPLICATE = 'prepend-non-duplicate'
|
||||||
|
|
@ -193,13 +193,12 @@ def process_dsv_file(
|
||||||
):
|
):
|
||||||
commands = []
|
commands = []
|
||||||
if _include_comments():
|
if _include_comments():
|
||||||
commands.append(FORMAT_STR_COMMENT_LINE.format_map({
|
commands.append(FORMAT_STR_COMMENT_LINE.format_map({'comment': dsv_path}))
|
||||||
'comment': dsv_path}))
|
|
||||||
with open(dsv_path, 'r') as h:
|
with open(dsv_path, 'r') as h:
|
||||||
content = h.read()
|
content = h.read()
|
||||||
lines = content.splitlines()
|
lines = content.splitlines()
|
||||||
|
|
||||||
basename_map = OrderedDict()
|
basenames = OrderedDict()
|
||||||
for i, line in enumerate(lines):
|
for i, line in enumerate(lines):
|
||||||
# skip over empty or whitespace-only lines
|
# skip over empty or whitespace-only lines
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
|
|
@ -224,21 +223,21 @@ def process_dsv_file(
|
||||||
else:
|
else:
|
||||||
# group remaining source lines by basename
|
# group remaining source lines by basename
|
||||||
path_without_ext, ext = os.path.splitext(remainder)
|
path_without_ext, ext = os.path.splitext(remainder)
|
||||||
if path_without_ext not in basename_map:
|
if path_without_ext not in basenames:
|
||||||
basename_map[path_without_ext] = set()
|
basenames[path_without_ext] = set()
|
||||||
assert ext.startswith('.')
|
assert ext.startswith('.')
|
||||||
ext = ext[1:]
|
ext = ext[1:]
|
||||||
if ext in (primary_extension, additional_extension):
|
if ext in (primary_extension, additional_extension):
|
||||||
basename_map[path_without_ext].add(ext)
|
basenames[path_without_ext].add(ext)
|
||||||
|
|
||||||
# add the dsv extension to each basename if the file exists
|
# add the dsv extension to each basename if the file exists
|
||||||
for basename, extensions in basename_map.items():
|
for basename, extensions in basenames.items():
|
||||||
if not os.path.isabs(basename):
|
if not os.path.isabs(basename):
|
||||||
basename = os.path.join(prefix, basename)
|
basename = os.path.join(prefix, basename)
|
||||||
if os.path.exists(basename + '.dsv'):
|
if os.path.exists(basename + '.dsv'):
|
||||||
extensions.add('dsv')
|
extensions.add('dsv')
|
||||||
|
|
||||||
for basename, extensions in basename_map.items():
|
for basename, extensions in basenames.items():
|
||||||
if not os.path.isabs(basename):
|
if not os.path.isabs(basename):
|
||||||
basename = os.path.join(prefix, basename)
|
basename = os.path.join(prefix, basename)
|
||||||
if 'dsv' in extensions:
|
if 'dsv' in extensions:
|
||||||
|
|
@ -305,8 +304,8 @@ def handle_dsv_types_except_source(type_, remainder, prefix):
|
||||||
comment = f'skip extending {env_name} with not existing ' \
|
comment = f'skip extending {env_name} with not existing ' \
|
||||||
f'path: {value}'
|
f'path: {value}'
|
||||||
if _include_comments():
|
if _include_comments():
|
||||||
commands.append(FORMAT_STR_COMMENT_LINE.format_map({
|
commands.append(
|
||||||
'comment': comment}))
|
FORMAT_STR_COMMENT_LINE.format_map({'comment': comment}))
|
||||||
elif type_ == DSV_TYPE_APPEND_NON_DUPLICATE:
|
elif type_ == DSV_TYPE_APPEND_NON_DUPLICATE:
|
||||||
commands += _append_unique_value(env_name, value)
|
commands += _append_unique_value(env_name, value)
|
||||||
else:
|
else:
|
||||||
|
|
@ -321,15 +320,15 @@ env_state = {}
|
||||||
|
|
||||||
|
|
||||||
def _append_unique_value(name, value):
|
def _append_unique_value(name, value):
|
||||||
|
global env_state
|
||||||
if name not in env_state:
|
if name not in env_state:
|
||||||
if os.environ.get(name):
|
if os.environ.get(name):
|
||||||
env_state[name] = set(os.environ[name].split(os.pathsep))
|
env_state[name] = set(os.environ[name].split(os.pathsep))
|
||||||
else:
|
else:
|
||||||
env_state[name] = set()
|
env_state[name] = set()
|
||||||
# Append even if the variable has not been set yet, in case a shell script
|
# append even if the variable has not been set yet, in case a shell script sets the
|
||||||
# sets the same variable without the knowledge of this Python script.
|
# same variable without the knowledge of this Python script.
|
||||||
# Later, _remove_ending_separators() will cleanup any unintentional
|
# later _remove_ending_separators() will cleanup any unintentional leading separator
|
||||||
# leading separator.
|
|
||||||
extend = FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + os.pathsep
|
extend = FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + os.pathsep
|
||||||
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
||||||
{'name': name, 'value': extend + value})
|
{'name': name, 'value': extend + value})
|
||||||
|
|
@ -343,15 +342,15 @@ def _append_unique_value(name, value):
|
||||||
|
|
||||||
|
|
||||||
def _prepend_unique_value(name, value):
|
def _prepend_unique_value(name, value):
|
||||||
|
global env_state
|
||||||
if name not in env_state:
|
if name not in env_state:
|
||||||
if os.environ.get(name):
|
if os.environ.get(name):
|
||||||
env_state[name] = set(os.environ[name].split(os.pathsep))
|
env_state[name] = set(os.environ[name].split(os.pathsep))
|
||||||
else:
|
else:
|
||||||
env_state[name] = set()
|
env_state[name] = set()
|
||||||
# Prepend even if the variable has not been set yet, in case a shell script
|
# prepend even if the variable has not been set yet, in case a shell script sets the
|
||||||
# sets the same variable without the knowledge of this Python script.
|
# same variable without the knowledge of this Python script.
|
||||||
# Later, _remove_ending_separators() will cleanup any unintentional
|
# later _remove_ending_separators() will cleanup any unintentional trailing separator
|
||||||
# trailing separator.
|
|
||||||
extend = os.pathsep + FORMAT_STR_USE_ENV_VAR.format_map({'name': name})
|
extend = os.pathsep + FORMAT_STR_USE_ENV_VAR.format_map({'name': name})
|
||||||
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
||||||
{'name': name, 'value': value + extend})
|
{'name': name, 'value': value + extend})
|
||||||
|
|
@ -370,10 +369,10 @@ def _remove_ending_separators():
|
||||||
if FORMAT_STR_REMOVE_TRAILING_SEPARATOR is None:
|
if FORMAT_STR_REMOVE_TRAILING_SEPARATOR is None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
global env_state
|
||||||
commands = []
|
commands = []
|
||||||
for name in env_state:
|
for name in env_state:
|
||||||
# skip variables that already had values before this script started
|
# skip variables that already had values before this script started prepending
|
||||||
# appending/prepending
|
|
||||||
if name in os.environ:
|
if name in os.environ:
|
||||||
continue
|
continue
|
||||||
commands += [
|
commands += [
|
||||||
|
|
@ -383,6 +382,7 @@ def _remove_ending_separators():
|
||||||
|
|
||||||
|
|
||||||
def _set(name, value):
|
def _set(name, value):
|
||||||
|
global env_state
|
||||||
env_state[name] = value
|
env_state[name] = value
|
||||||
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
||||||
{'name': name, 'value': value})
|
{'name': name, 'value': value})
|
||||||
|
|
@ -390,6 +390,7 @@ def _set(name, value):
|
||||||
|
|
||||||
|
|
||||||
def _set_if_unset(name, value):
|
def _set_if_unset(name, value):
|
||||||
|
global env_state
|
||||||
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
line = FORMAT_STR_SET_ENV_VAR.format_map(
|
||||||
{'name': name, 'value': value})
|
{'name': name, 'value': value})
|
||||||
if env_state.get(name, os.environ.get(name)):
|
if env_state.get(name, os.environ.get(name)):
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
/workspace/install/bcr_bot:/opt/ros/humble
|
/opt/ros/humble
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
<xacro:if value="$(arg camera_enabled)">
|
<xacro:if value="$(arg camera_enabled)">
|
||||||
<gazebo reference="kinect_camera">
|
<gazebo reference="kinect_camera">
|
||||||
<sensor type="depth_camera" name="kinect_camera">
|
<sensor type="depth_camera" name="kinect_camera">
|
||||||
<update_rate>30.0</update_rate>
|
<update_rate>10.0</update_rate>
|
||||||
<topic>kinect_camera</topic>
|
<topic>kinect_camera</topic>
|
||||||
<gz_frame_id>kinect_camera</gz_frame_id>
|
<gz_frame_id>kinect_camera</gz_frame_id>
|
||||||
<camera>
|
<camera>
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
<xacro:if value="$(arg camera_enabled)">
|
<xacro:if value="$(arg camera_enabled)">
|
||||||
<gazebo reference="kinect_camera">
|
<gazebo reference="kinect_camera">
|
||||||
<sensor type="depth_camera" name="kinect_camera">
|
<sensor type="depth_camera" name="kinect_camera">
|
||||||
<update_rate>30.0</update_rate>
|
<update_rate>10.0</update_rate>
|
||||||
<topic>kinect_camera</topic>
|
<topic>kinect_camera</topic>
|
||||||
<gz_frame_id>kinect_camera</gz_frame_id>
|
<gz_frame_id>kinect_camera</gz_frame_id>
|
||||||
<camera>
|
<camera>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue