3 from .util
import get_config, get_ignore_data, roscompile
8 build_depends = package.get_build_dependencies()
9 run_depends = package.get_run_dependencies()
10 test_depends = package.get_test_dependencies()
11 package.manifest.add_packages(build_depends, run_depends, test_depends)
13 if package.generators:
14 md = package.get_dependencies_from_msgs()
15 package.manifest.add_packages(md, md)
17 if package.manifest.format == 1:
18 pairs = [(
'build_depend',
'message_generation'),
19 (
'run_depend',
'message_runtime')]
21 pairs = [(
'build_depend',
'message_generation'),
22 (
'build_export_depend',
'message_runtime'),
23 (
'exec_depend',
'message_runtime')]
24 package.manifest.remove_dependencies(
'depend', [
'message_generation',
'message_runtime'])
25 for tag, msg_pkg
in pairs:
26 existing = package.manifest.get_packages_by_tag(tag)
27 if msg_pkg
not in existing:
28 package.manifest.insert_new_packages(tag, [msg_pkg])
33 run_depends = package.source_code.get_external_python_dependencies()
34 package.manifest.add_packages(set(), run_depends, prefer_depend_tag=
False)
38 for child
in node.childNodes:
39 if child.nodeType == child.ELEMENT_NODE:
46 exports = package.manifest.root.getElementsByTagName(
'export')
49 for export
in exports:
51 package.manifest.remove_element(export)
57 if package.manifest.format == 1:
59 replace_package_set(package.manifest, [
'build_depend',
'build_export_depend',
'exec_depend'],
'depend')
63 ideal_length = manifest.std_tab * tabs
65 insert_before_list = []
69 for c
in node.childNodes:
70 if c.nodeType == c.TEXT_NODE:
72 if c == node.childNodes[-1]:
74 spaces = count_trailing_spaces(c.data)
75 if spaces > ideal_length:
76 c.data = c.data[: ideal_length - spaces]
78 elif spaces < ideal_length:
79 c.data = c.data +
' ' * (ideal_length - spaces)
81 if '\n' not in c.data:
82 c.data =
'\n' + c.data
86 insert_before_list.append(c)
90 for c
in insert_before_list:
91 node.insertBefore(manifest.get_tab_element(tabs), c)
93 manifest.changed = manifest.changed
or changed
95 if len(node.childNodes) == 0:
97 last = node.childNodes[-1]
98 if last.nodeType != last.TEXT_NODE:
99 node.appendChild(manifest.get_tab_element(tabs - 1))
100 manifest.changed =
True 114 index = get_ordering_index(name)
116 if not alphabetize_depends:
118 if name
and 'depend' in name:
119 return index, node.firstChild.data
125 """Given the children, group the elements into tuples. 127 Tuple format: (an element node, [(some number of text nodes), that element node again]) 131 for child_node
in children:
132 current.append(child_node)
133 if child_node.nodeType == child_node.ELEMENT_NODE:
134 chunks.append((child_node, current))
137 chunks.append((
None, current))
143 root = package.manifest.root
148 for a, b
in sorted(chunks, key=
lambda d:
get_sort_key(d[0], alphabetize)):
151 if root.childNodes != new_children:
152 package.manifest.changed =
True 153 root.childNodes = new_children
160 for child
in node.childNodes:
161 if child.nodeType == child.TEXT_NODE
and len(new_children)
and new_children[-1].nodeType == child.TEXT_NODE:
163 new_children[-1].data += child.data
164 elif child.nodeType == child.TEXT_NODE
and child.data ==
'':
167 new_children.append(child)
169 node.childNodes = new_children
176 for i, c
in enumerate(node.childNodes):
177 if c.nodeType == c.TEXT_NODE:
179 elif c.nodeType == c.COMMENT_NODE:
180 short = c.data.strip()
181 if short
in ignorables:
187 for node_index
in reversed(removable):
189 before = node.childNodes[node_index - 1]
190 if before.nodeType == c.TEXT_NODE:
191 trailing = count_trailing_spaces(before.data)
192 before.data = before.data[:-trailing]
194 if node_index < len(node.childNodes) - 1:
195 after = node.childNodes[node_index + 1]
196 if after.nodeType == c.TEXT_NODE:
197 while len(after.data)
and after.data[0] ==
' ':
198 after.data = after.data[1:]
199 if len(after.data)
and after.data[0] ==
'\n':
200 after.data = after.data[1:]
202 node.childNodes.remove(node.childNodes[node_index])
209 ignorables =
get_ignore_data(
'package', {
'package': package.name}, add_newline=
False)
212 package.manifest.changed = changed
218 for child
in node.childNodes:
219 if child.nodeType == child.TEXT_NODE:
220 while '\n\n\n' in child.data:
221 child.data = child.data.replace(
'\n\n\n',
'\n\n')
231 package.manifest.changed =
True 238 for d
in config.get(
'replace_rules', []):
239 package.manifest.update_people(d[
'to'][
'name'], d[
'to'][
'email'],
240 d[
'from'].get(
'name',
None), d[
'from'].get(
'email',
None))
247 if 'default_license' not in config
or package.manifest.get_license() !=
'TODO':
250 package.manifest.set_license(config[
'default_license'])
def update_people(package, config=None)
def enforce_manifest_tabbing(package)
def remove_empty_manifest_lines(package)
def get_ignore_data(name, variables=None, add_newline=True)
def enforce_manifest_ordering(package, alphabetize=True)
def cleanup_text_elements(node)
def check_python_dependencies(package)
def update_license(package, config=None)
def replace_text_node_contents(node, ignorables)
def enforce_tabbing_helper(manifest, node, tabs=1)
def remove_boilerplate_manifest_comments(package)
def has_element_child(node)
def remove_empty_export_tag(package)
def greedy_depend_tag(package)
def check_manifest_dependencies(package)
def remove_empty_lines_helper(node)
def get_sort_key(node, alphabetize_depends=True)