@@ -17,15 +17,15 @@ def show_error(error: str) -> int:
17
17
18
18
def type_git (install_item : Mapping , allowed_keys : Optional [List [str ]] = None ) -> str :
19
19
"""
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.
21
21
22
22
The structure of a git install type is:
23
23
- type: git
24
24
url: <REPOSITORY_URL>
25
25
path: [LOCAL_CLONE_PATH]
26
26
version: [BRANCH_COMMIT_TAG]
27
27
28
- :param install_item: Extracted yaml component corresponding to install type git
28
+ :param install_item: Extracted YAML component corresponding to install type git
29
29
:param allowed_keys: Additional keys to allow apart from the keys defined in install type git
30
30
:return: Command string containing repository url and optional arguments target-dir and version
31
31
"""
@@ -94,7 +94,7 @@ def type_apt_key_source(install_item: Mapping) -> str:
94
94
95
95
def catkin_git (source : Mapping ) -> str :
96
96
"""
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
98
98
99
99
The structure of a catkin git install type is:
100
100
- type: catkin/ros
@@ -105,7 +105,7 @@ def catkin_git(source: Mapping) -> str:
105
105
version: [BRANCH_COMMIT_TAG]
106
106
sub-dir: [PACKAGE_SUB_DIRECTORY]
107
107
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
109
109
:return: Command string containing arguments to the primary catkin target installation command
110
110
"""
111
111
@@ -119,28 +119,6 @@ def catkin_git(source: Mapping) -> str:
119
119
return command
120
120
121
121
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
-
144
122
def install_yaml_parser (path : str , now : bool = False ) -> Mapping [str , str ]:
145
123
with open (path ) as f :
146
124
try :
@@ -202,7 +180,7 @@ def get_distro_item(
202
180
# TODO(anyone): Remove the use of TUE_XXX, when migration to TUE_ENV_XXX is complete
203
181
try :
204
182
ros_release = environ ["TUE_ENV_ROS_DISTRO" ]
205
- except KeyError as e :
183
+ except KeyError :
206
184
try :
207
185
ros_release = environ ["TUE_ROS_DISTRO" ]
208
186
except KeyError :
@@ -311,5 +289,27 @@ def get_distro_item(
311
289
return {"system_packages" : system_packages , "commands" : " " .join (commands )}
312
290
313
291
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
+
314
314
if __name__ == "__main__" :
315
315
sys .exit (main ())
0 commit comments