Skip to content

Commit 1b0e487

Browse files
committed
update the python API to support the new models format see ipa320/RosTooling#125
1 parent f811edc commit 1b0e487

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/ros_graph_parser/core_class.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_type(self, value):
137137
return 'String'
138138
elif itype == 'list' or itype == 'dict':
139139
if ":" in str(value):
140-
return 'Struc'
140+
return 'Struct'
141141
else:
142142
return 'List'
143143
else:
@@ -152,8 +152,8 @@ def set_value(self, value, indent):
152152
elif self.itype == "List":
153153
str_param_value += str(self.value).replace(
154154
"[", "{").replace("]", "}")
155-
elif self.itype == 'Struc':
156-
str_param_value += self.value_struc(self.value[0], indent+" ")
155+
elif self.itype == 'Struct':
156+
str_param_value += self.value_struct(self.value[0], indent+" ")
157157
else:
158158
str_param_value += str(value)
159159
return str_param_value
@@ -170,39 +170,39 @@ def str_format(self, indent=""):
170170
def java_format(self, indent="", value=""):
171171
str_param = "%sParameter { name '%s' type %s " % (
172172
indent, self.resolved, self.itype)
173-
if self.itype == 'Struc':
174-
str_param += self.types_struc(self.value[0], indent)
173+
if self.itype == 'Struct':
174+
str_param += self.types_struct(self.value[0], indent)
175175
#str_param = str_param[:-2]
176176
if self.itype == 'List':
177177
str_param += self.form_list(self.value)
178178
str_param += "}"
179179
return str_param
180180

181-
def types_struc(self, struc_dict, indent):
181+
def types_struct(self, struct_dict, indent):
182182
str_param = "{\n"
183183
indent_new = indent+" "
184-
for struc_element in struc_dict:
185-
sub_name = struc_element
186-
sub_value = struc_dict[struc_element]
184+
for struct_element in struct_dict:
185+
sub_name = struct_element
186+
sub_value = struct_dict[struct_element]
187187
sub_type = self.get_type(sub_value)
188188
str_param += "%s'%s' %s" % (indent_new, sub_name, sub_type)
189189
if sub_type == 'List':
190190
str_param += self.form_list(sub_value)
191191
if isinstance(sub_value, dict):
192-
str_param += self.types_struc(
193-
struc_dict[struc_element], indent_new)
192+
str_param += self.types_struct(
193+
struct_dict[struct_element], indent_new)
194194
str_param += ",\n"
195195
str_param = str_param[:-2]
196196
str_param += "}"
197197
indent_new = ""
198198
return str_param
199199

200-
def value_struc(self, struc_dict, indent):
200+
def value_struct(self, struct_dict, indent):
201201
str_param = "{\n"
202202
indent_new = indent+" "
203-
for struc_element in struc_dict:
204-
sub_name = struc_element
205-
sub_value = struc_dict[struc_element]
203+
for struct_element in struct_dict:
204+
sub_name = struct_element
205+
sub_value = struct_dict[struct_element]
206206
sub_type = self.get_type(sub_value)
207207
str_param += "%s{ '%s' { value " % (indent_new, sub_name)
208208
if sub_type == "String":
@@ -213,8 +213,8 @@ def value_struc(self, struc_dict, indent):
213213
if sub_type == "Boolean":
214214
sub_value = str(sub_value).lower()
215215
if isinstance(sub_value, dict):
216-
str_param += self.value_struc(
217-
struc_dict[struc_element], indent_new)
216+
str_param += self.value_struct(
217+
struct_dict[struct_element], indent_new)
218218
self.count = self.count + 1
219219
else:
220220
str_param += "%s}}" % (sub_value)
@@ -365,21 +365,21 @@ def dump_yaml(self):
365365

366366
def dump_java_ros_model(self):
367367
ros_model_str = " Artifact "+self.name+" {\n"
368-
ros_model_str += " node Node { name " + self.name+"\n"
368+
ros_model_str += " Node { name " + self.name
369369
ros_model_str += self.service_servers.java_format_ros_model(
370-
" ", "ServiceServer", "service", "serviceserver")
370+
" ", "ServiceServer", "service", "ServiceServers")
371371
ros_model_str += self.service_clients.java_format_ros_model(
372-
" ", "ServiceClients", "service", "serviceclient")
372+
" ", "ServiceClients", "service", "ServiceClients")
373373
ros_model_str += self.publishers.java_format_ros_model(
374-
" ", "Publisher", "message", "publisher")
374+
" ", "Publisher", "message", "Publishers")
375375
ros_model_str += self.subscribers.java_format_ros_model(
376-
" ", "Subscriber", "message", "subscriber")
376+
" ", "Subscriber", "message", "Subscribers")
377377
ros_model_str += self.action_servers.java_format_ros_model(
378-
" ", "ActionServer", "action", "actionserver")
378+
" ", "ActionServer", "action", "ActionServers")
379379
ros_model_str += self.action_clients.java_format_ros_model(
380-
" ", "ActionClient", "action", "actionclient")
380+
" ", "ActionClient", "action", "ActionClients")
381381
ros_model_str += self.params.java_format_ros_model(
382-
" ", "Parameters", "parameter")
382+
" ", "Parameters", "Parameters")
383383
ros_model_str += "}},\n"
384384
return ros_model_str
385385

0 commit comments

Comments
 (0)