misc.py
Go to the documentation of this file.
1 import os
2 import re
3 
4 from ros_introspection.util import get_sibling_packages
5 
6 from .util import make_executable, roscompile
7 
8 MAINPAGE_S = r'/\*\*\s+\\mainpage\s+\\htmlinclude manifest.html\s+\\b %s\s+<!--\s+' + \
9  r'Provide an overview of your package.\s+-->\s+-->\s+[^\*]*\*/'
10 
11 
12 @roscompile
14  cfgs = package.dynamic_reconfigs
15  if len(cfgs) == 0:
16  return
17  pkg_list = {'dynamic_reconfigure'}
18  package.manifest.add_packages(pkg_list, pkg_list)
19  package.cmake.section_check(cfgs, 'generate_dynamic_reconfigure_options', '')
20  package.cmake.section_check(pkg_list, 'find_package', 'COMPONENTS')
21 
22  for fn in cfgs:
23  make_executable(os.path.join(package.root, fn))
24 
25 
26 @roscompile
27 def remove_useless_files(package):
28  mainpage_pattern = re.compile(MAINPAGE_S % package.name)
29  for fn in package.misc_files:
30  if 'mainpage.dox' in fn:
31  full_path = os.path.join(package.root, fn)
32  s = open(full_path).read()
33  if mainpage_pattern.match(s):
34  os.remove(full_path)
35 
36 
37 @roscompile
38 def update_metapackage(package, sibling_packages=None, require_matching_name=False):
39  # Check if there is indication in package.xml or CMake of being a metapackage
40  if not package.is_metapackage():
41  return False
42 
43  if require_matching_name:
44  parent_path = os.path.abspath(os.path.join(package.root, '..'))
45 
46  if os.path.split(parent_path)[1] != package.name:
47  return False
48 
49  if sibling_packages is None:
50  sibling_packages = get_sibling_packages(package)
51 
52  existing_sub_packages = package.manifest.get_packages('run')
53  package.manifest.add_packages(set(), sibling_packages, prefer_depend_tag=False)
54 
55  if package.manifest.format == 1:
56  pkg_type = 'run_depend'
57  else:
58  pkg_type = 'exec_depend'
59 
60  package.manifest.remove_dependencies(pkg_type, existing_sub_packages - sibling_packages)
61 
62  # Ensure proper commands in CMake
63  package.cmake.section_check([], 'catkin_metapackage', zero_okay=True)
64 
65  # Ensure proper tags in package.xml
66  if not package.manifest.is_metapackage():
67  export_tag = package.manifest.get_export_tag()
68  meta_tag = package.manifest.tree.createElement('metapackage')
69  package.manifest.insert_new_tag_inside_another(export_tag, meta_tag)
70 
71 
72 @roscompile
73 def misc_xml_formatting(package):
74  package.manifest.changed = True
75  for config in package.plugin_configs:
76  config.changed = True
def remove_useless_files(package)
Definition: misc.py:27
def check_dynamic_reconfigure(package)
Definition: misc.py:13
def update_metapackage(package, sibling_packages=None, require_matching_name=False)
Definition: misc.py:38
def make_executable(fn)
Definition: util.py:44
def misc_xml_formatting(package)
Definition: misc.py:73


roscompile
Author(s):
autogenerated on Wed Mar 3 2021 03:56:01