@@ -117,52 +117,56 @@ def draw_folder(g,folder):
117
117
if root != working_directory :
118
118
working_directory = root
119
119
f = open (filepath ,'rt' )
120
- tree = ElementTree .parse (f )
121
- node_name = os .path .splitext (filename )[0 ] #remove extension
122
- it = tree .iter ()
123
- #Iterate
124
- node_args = []
125
- node_includes = []
126
- node_nodes = []
127
- for node in it :
128
- if node .tag == "arg" :
129
- #save arguments and default values
130
- arg_name = node .attrib .get ('name' )
131
- default_value = node .attrib .get ('default' )
132
- value = node .attrib .get ('value' )
133
- if_clause = node .attrib .get ('if' )
134
- if default_value :
135
- #add to the node_args list with default
136
- node_args .append ((arg_name ,default_value ))
137
- elif not value :
138
- #add to the node_args list with REQUIRED
139
- node_args .append ((arg_name ,"REQUIRED" ))
140
- elif if_clause :
141
- nodelet_args = value .split ()[1 ]
142
- if node .tag == "include" :
143
- #remove extension and path to file
144
- incl_ext = os .path .basename (node .attrib .get ('file' ))
145
- incl = os .path .splitext (incl_ext )[0 ]
146
- node_includes .append (incl )
147
- if node .tag == "node" :
148
- node_type = node .attrib .get ('type' )
149
- if node_type == "nodelet" :
150
- node_type = node .attrib .get ('args' )
151
- if len (node_type .split ())> 1 :
152
- node_type = node_type .split ()[1 ]
153
- if node_type [len (node_type )- 1 ] == ")" :
154
- node_type = nodelet_args
155
- node_nodes .append (node_type )
156
- else :
157
- node_nodes .append (node_type )
120
+ try :
121
+ tree = ElementTree .parse (f )
122
+ node_name = os .path .splitext (filename )[0 ] #remove extension
123
+ it = tree .iter ()
124
+ #Iterate
125
+ node_args = []
126
+ node_includes = []
127
+ node_nodes = []
128
+ for node in it :
129
+ if node .tag == "arg" :
130
+ #save arguments and default values
131
+ arg_name = node .attrib .get ('name' )
132
+ default_value = node .attrib .get ('default' )
133
+ value = node .attrib .get ('value' )
134
+ if_clause = node .attrib .get ('if' )
135
+ if default_value :
136
+ #add to the node_args list with default
137
+ node_args .append ((arg_name ,default_value ))
138
+ elif not value :
139
+ #add to the node_args list with REQUIRED
140
+ node_args .append ((arg_name ,"REQUIRED" ))
141
+ elif if_clause :
142
+ nodelet_args = value .split ()[1 ]
143
+ if node .tag == "include" :
144
+ #remove extension and path to file
145
+ incl_ext = os .path .basename (node .attrib .get ('file' ))
146
+ incl = os .path .splitext (incl_ext )[0 ]
147
+ node_includes .append (incl )
148
+ if node .tag == "node" :
149
+ node_type = node .attrib .get ('type' )
150
+ if node_type == "nodelet" :
151
+ node_type = node .attrib .get ('args' )
152
+ if len (node_type .split ())> 1 :
153
+ node_type = node_type .split ()[1 ]
154
+ if node_type [len (node_type )- 1 ] == ")" :
155
+ node_type = nodelet_args
156
+ node_nodes .append (node_type )
157
+ else :
158
+ node_nodes .append (node_type )
159
+
160
+
161
+ write_information (g ,node_name ,node_args )
162
+ write_information (g ,node_nodes )
163
+ for dest in node_nodes :
164
+ write_connection (g ,node_name ,dest ,True )
165
+ for dest in node_includes :
166
+ write_connection (g ,node_name ,dest )
167
+ except ElementTree .ParseError :
168
+ print "Error parsing {}" .format (filepath )
158
169
159
-
160
- write_information (g ,node_name ,node_args )
161
- write_information (g ,node_nodes )
162
- for dest in node_nodes :
163
- write_connection (g ,node_name ,dest ,True )
164
- for dest in node_includes :
165
- write_connection (g ,node_name ,dest )
166
170
return g
167
171
else :
168
172
print "[W]\t No launchfile was found in {0}" .format (os .path .basename (folder ))
0 commit comments