Skip to content

Commit 34a003b

Browse files
Small cleanup (#750)
2 parents cc77100 + 341b4cf commit 34a003b

File tree

4 files changed

+38
-36
lines changed

4 files changed

+38
-36
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.27.0
1+
1.27.1

installer/parse_install_yaml.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ def show_error(error: str) -> int:
1717

1818
def type_git(install_item: Mapping, allowed_keys: Optional[List[str]] = None) -> str:
1919
"""
20-
Function to check the parsed yaml for install type git and generate the command string.
20+
Function to check the parsed YAML for install type git and generate the command string.
2121
2222
The structure of a git install type is:
2323
- type: git
2424
url: <REPOSITORY_URL>
2525
path: [LOCAL_CLONE_PATH]
2626
version: [BRANCH_COMMIT_TAG]
2727
28-
:param install_item: Extracted yaml component corresponding to install type git
28+
:param install_item: Extracted YAML component corresponding to install type git
2929
:param allowed_keys: Additional keys to allow apart from the keys defined in install type git
3030
:return: Command string containing repository url and optional arguments target-dir and version
3131
"""
@@ -94,7 +94,7 @@ def type_apt_key_source(install_item: Mapping) -> str:
9494

9595
def catkin_git(source: Mapping) -> str:
9696
"""
97-
Function to generate installation command for catkin git targets from the extracted yaml
97+
Function to generate installation command for catkin git targets from the extracted YAML
9898
9999
The structure of a catkin git install type is:
100100
- type: catkin/ros
@@ -105,7 +105,7 @@ def catkin_git(source: Mapping) -> str:
105105
version: [BRANCH_COMMIT_TAG]
106106
sub-dir: [PACKAGE_SUB_DIRECTORY]
107107
108-
:param source: Extracted yaml component for the key 'source' corresponding to install type catkin/ros
108+
:param source: Extracted YAML component for the key 'source' corresponding to install type catkin/ros
109109
:return: Command string containing arguments to the primary catkin target installation command
110110
"""
111111

@@ -119,28 +119,6 @@ def catkin_git(source: Mapping) -> str:
119119
return command
120120

121121

122-
def main() -> int:
123-
if not 2 <= len(sys.argv) <= 3:
124-
return show_error("Usage: parse_install_yaml install.yaml [--now]")
125-
126-
now = False
127-
if len(sys.argv) == 3:
128-
if sys.argv[2] == "--now":
129-
now = True
130-
else:
131-
return show_error(f"Unknown option: {sys.argv[2]}")
132-
133-
try:
134-
result = install_yaml_parser(sys.argv[1], now)
135-
except Exception as e:
136-
return show_error(str(e))
137-
138-
if result["commands"]:
139-
print(result["commands"])
140-
141-
return 0
142-
143-
144122
def install_yaml_parser(path: str, now: bool = False) -> Mapping[str, str]:
145123
with open(path) as f:
146124
try:
@@ -202,7 +180,7 @@ def get_distro_item(
202180
# TODO(anyone): Remove the use of TUE_XXX, when migration to TUE_ENV_XXX is complete
203181
try:
204182
ros_release = environ["TUE_ENV_ROS_DISTRO"]
205-
except KeyError as e:
183+
except KeyError:
206184
try:
207185
ros_release = environ["TUE_ROS_DISTRO"]
208186
except KeyError:
@@ -311,5 +289,27 @@ def get_distro_item(
311289
return {"system_packages": system_packages, "commands": " ".join(commands)}
312290

313291

292+
def main() -> int:
293+
if not 2 <= len(sys.argv) <= 3:
294+
return show_error("Usage: parse_install_yaml install.yaml [--now]")
295+
296+
now: bool = False
297+
if len(sys.argv) == 3:
298+
if sys.argv[2] == "--now":
299+
now = True
300+
else:
301+
return show_error(f"Unknown option: {sys.argv[2]}")
302+
303+
try:
304+
result = install_yaml_parser(sys.argv[1], now)
305+
except Exception as e:
306+
return show_error(str(e))
307+
308+
if result["commands"]:
309+
print(result["commands"])
310+
311+
return 0
312+
313+
314314
if __name__ == "__main__":
315315
sys.exit(main())

setup.bash

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function _tue-check-env-vars
1111
}
1212
export -f _tue-check-env-vars
1313

14-
function main
14+
function _tue-env-main
1515
{
1616
# -----------------------------------------
1717
# Set the TUE_DIR variable
@@ -108,4 +108,6 @@ function main
108108
fi
109109
}
110110

111-
main "$@"
111+
_tue-env-main "$@"
112+
113+
unset -f _tue-env-main

setup/tue-functions.bash

+6-6
Original file line numberDiff line numberDiff line change
@@ -873,18 +873,18 @@ function _remove_recursively
873873
return 1
874874
fi
875875

876-
local target tue_dependencies_dir tue_dependencies_on_dir error_code
877-
target=$1
878-
tue_dependencies_dir="$TUE_ENV_DIR"/.env/dependencies
879-
tue_dependencies_on_dir="$TUE_ENV_DIR"/.env/dependencies-on
876+
local error_code target tue_dependencies_dir tue_dependencies_on_dir
880877
error_code=0
878+
target=$1
879+
tue_dependencies_dir="${TUE_ENV_DIR}"/.env/dependencies
880+
tue_dependencies_on_dir="${TUE_ENV_DIR}"/.env/dependencies-on
881881

882882
# If packages depend on the target to be removed, just remove the installed status.
883883
if [ -f "$tue_dependencies_on_dir"/"$target" ]
884884
then
885885
if [[ -n $(cat "$tue_dependencies_on_dir"/"$target") ]]
886886
then
887-
# depend-on is not empty, so removing the installed status
887+
# depend-on is not empty, so only removing the installed status
888888
echo "[tue-get] Other targets still depend on $target, so ignoring it"
889889
return 0
890890
else
@@ -909,7 +909,7 @@ function _remove_recursively
909909
while read -r line
910910
do
911911
[[ $line != "$target" ]] && echo "$line"
912-
done <"$dep_dep_on_file" >"$tmp_file"
912+
done < "${dep_dep_on_file}" > "${tmp_file}"
913913
mv "$tmp_file" "$dep_dep_on_file"
914914
echo "[tue-get] Removed '$target' from depend-on file of '$dep'"
915915
else

0 commit comments

Comments
 (0)