4 AT_LEAST_THREE_DASHES = re.compile(
r'^\-{3,}\r?$')
5 FIELD_LINE = re.compile(
r'([\w_/]+)(\[\d*\])?\s+([\w_]+)\s*(=.*)?(\s*\#.*)?$', re.DOTALL)
6 PRIMITIVES = [
'bool',
'int8',
'uint8',
'int16',
'uint16',
'int32',
'uint32',
'int64',
'uint64',
7 'float32',
'float64',
'string',
'time',
'duration']
11 def __init__(self, field_type, is_array, name, value):
35 stripped = line.strip()
36 if not stripped
or stripped[0] ==
'#':
37 self.contents.append(line)
39 m = FIELD_LINE.match(line)
41 field_type, is_array, name, value, comment = m.groups()
43 self.contents.append(field)
44 self.fields.append(field)
46 self.contents.append(comment)
48 self.contents.append(
'\n')
50 raise Exception(
'Unable to parse generator line: ' + repr(line))
53 return ''.join(map(str, self.
contents))
59 parts = os.path.splitext(rel_fn)
62 self.
name = os.path.basename(rel_fn)
68 with open(file_path)
as f:
70 if AT_LEAST_THREE_DASHES.match(line):
77 for field
in section.fields:
78 if '/' not in field.type:
80 package, part = field.type.split(
'/')
81 if package != self.
name:
82 self.dependencies.add(package)
84 if self.
type ==
'action':
85 self.dependencies.add(
'actionlib_msgs')
88 return '---\n'.join(map(str, self.
sections))
def __init__(self, rel_fn, file_path)
def __init__(self, field_type, is_array, name, value)