4 AT_LEAST_THREE_DASHES = re.compile(
'^\-{3,}\r?$')
5 FIELD_LINE = re.compile(
'([\w_/]+)(\[\d*\])?\s+([\w_]+)\s*(=.*)?(\s*\#.*)?$', re.DOTALL)
9 def __init__(self, type, is_array, name, value):
33 stripped = line.strip()
34 if not stripped
or stripped[0] ==
'#':
35 self.contents.append(line)
37 m = FIELD_LINE.match(line)
39 type, is_array, name, value, comment = m.groups()
41 self.contents.append(field)
42 self.fields.append(field)
44 self.contents.append(comment)
46 self.contents.append(
'\n')
48 raise Exception(
'Unable to parse generator line: ' + repr(line))
51 return ''.join(map(str, self.
contents))
57 parts = os.path.splitext(rel_fn)
60 self.
name = os.path.basename(rel_fn)
66 with open(file_path)
as f:
68 if AT_LEAST_THREE_DASHES.match(line):
75 for field
in section.fields:
76 if '/' not in field.type:
78 package, part = field.type.split(
'/')
79 if package != self.
name:
80 self.dependencies.add(package)
82 if self.
type ==
'action':
83 self.dependencies.add(
'actionlib_msgs')
86 return '---\n'.join(map(str, self.
sections))
def __init__(self, type, is_array, name, value)
def __init__(self, rel_fn, file_path)