2 from util
import get_ignore_data, roscompile, get_config
7 build_depends = package.get_build_dependencies()
8 run_depends = package.get_run_dependencies()
9 test_depends = package.get_test_dependencies()
10 package.manifest.add_packages(build_depends, run_depends, test_depends)
12 if package.generators:
13 md = package.get_dependencies_from_msgs()
14 package.manifest.add_packages(md, md)
16 if package.manifest.format == 1:
17 pairs = [(
'build_depend',
'message_generation'),
18 (
'run_depend',
'message_runtime')]
20 pairs = [(
'build_depend',
'message_generation'),
21 (
'build_export_depend',
'message_runtime'),
22 (
'exec_depend',
'message_runtime')]
23 package.manifest.remove_dependencies(
'depend', [
'message_generation',
'message_runtime'])
24 for tag, msg_pkg
in pairs:
25 existing = package.manifest.get_packages_by_tag(tag)
26 if msg_pkg
not in existing:
27 package.manifest.insert_new_packages(tag, [msg_pkg])
32 run_depends = package.source_code.get_external_python_dependencies()
33 package.manifest.add_packages(set(), run_depends, prefer_depend_tag=
False)
37 for child
in node.childNodes:
38 if child.nodeType == child.ELEMENT_NODE:
45 exports = package.manifest.root.getElementsByTagName(
'export')
48 for export
in exports:
50 package.manifest.remove_element(export)
56 Find the set of packages that are defined in the manifest using all of the tags listed in source_tags. 57 Remove all those elements and replace them with the new_tag. 60 for tag
in source_tags:
61 pkgs = set(manifest.get_packages_by_tag(tag))
62 if intersection
is None:
65 intersection = intersection.intersection(pkgs)
66 for tag
in source_tags:
67 manifest.remove_dependencies(tag, intersection)
68 manifest.insert_new_packages(new_tag, intersection)
73 if package.manifest.format == 1:
75 replace_package_set(package.manifest, [
'build_depend',
'build_export_depend',
'exec_depend'],
'depend')
79 ideal_length = manifest.std_tab * tabs
81 insert_before_list = []
85 for c
in node.childNodes:
86 if c.nodeType == c.TEXT_NODE:
88 if c == node.childNodes[-1]:
90 spaces = count_trailing_spaces(c.data)
91 if spaces > ideal_length:
92 c.data = c.data[: ideal_length - spaces]
94 elif spaces < ideal_length:
95 c.data = c.data +
' ' * (ideal_length - spaces)
97 if '\n' not in c.data:
98 c.data =
'\n' + c.data
102 insert_before_list.append(c)
106 for c
in insert_before_list:
107 node.insertBefore(manifest.get_tab_element(tabs), c)
109 manifest.changed = manifest.changed
or changed
111 if len(node.childNodes) == 0:
113 last = node.childNodes[-1]
114 if last.nodeType != last.TEXT_NODE:
115 node.appendChild(manifest.get_tab_element(tabs - 1))
116 manifest.changed =
True 130 index = get_ordering_index(name)
132 if not alphabetize_depends:
134 if name
and 'depend' in name:
135 return index, node.firstChild.data
141 """ Given the children, group the elements into tuples that are 142 (an element node, [(some number of text nodes), that element node again]) 146 for child_node
in children:
147 current.append(child_node)
148 if child_node.nodeType == child_node.ELEMENT_NODE:
149 chunks.append((child_node, current))
152 chunks.append((
None, current))
158 root = package.manifest.root
163 for a, b
in sorted(chunks, key=
lambda d:
get_sort_key(d[0], alphabetize)):
166 if root.childNodes != new_children:
167 package.manifest.changed =
True 168 root.childNodes = new_children
175 for child
in node.childNodes:
176 if child.nodeType == child.TEXT_NODE
and len(new_children)
and new_children[-1].nodeType == child.TEXT_NODE:
178 new_children[-1].data += child.data
179 elif child.nodeType == child.TEXT_NODE
and child.data ==
'':
182 new_children.append(child)
184 node.childNodes = new_children
191 for i, c
in enumerate(node.childNodes):
192 if c.nodeType == c.TEXT_NODE:
194 elif c.nodeType == c.COMMENT_NODE:
195 short = c.data.strip()
196 if short
in ignorables:
202 for node_index
in reversed(removable):
204 before = node.childNodes[node_index - 1]
205 if before.nodeType == c.TEXT_NODE:
206 trailing = count_trailing_spaces(before.data)
207 before.data = before.data[:-trailing]
209 if node_index < len(node.childNodes) - 1:
210 after = node.childNodes[node_index + 1]
211 if after.nodeType == c.TEXT_NODE:
212 while len(after.data)
and after.data[0] ==
' ':
213 after.data = after.data[1:]
214 if len(after.data)
and after.data[0] ==
'\n':
215 after.data = after.data[1:]
217 node.childNodes.remove(node.childNodes[node_index])
224 ignorables =
get_ignore_data(
'package', {
'package': package.name}, add_newline=
False)
227 package.manifest.changed = changed
233 for child
in node.childNodes:
234 if child.nodeType == child.TEXT_NODE:
235 while '\n\n\n' in child.data:
236 child.data = child.data.replace(
'\n\n\n',
'\n\n')
246 package.manifest.changed =
True 253 for d
in config.get(
'replace_rules', []):
254 package.manifest.update_people(d[
'to'][
'name'], d[
'to'][
'email'],
255 d[
'from'].get(
'name',
None), d[
'from'].get(
'email',
None))
262 if 'default_license' not in config
or package.manifest.get_license() !=
'TODO':
265 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 replace_package_set(manifest, source_tags, new_tag)
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)