4 from .source_code_file
import is_python_hashbang_line
6 KEY = [
'package.xml',
'CMakeLists.txt',
'setup.py']
7 SRC_EXTS = [
'.py',
'.cpp',
'.h',
'.hpp',
'.c']
8 GENERATORS = [
'.msg',
'.srv',
'.action']
12 with open(filename)
as f:
14 first_line = f.readline()
15 except UnicodeDecodeError:
19 elif '<launch' in first_line:
21 elif ext ==
'.xml' and (
'<library' in first_line
or '<class_libraries' in first_line):
22 return 'plugin_config' 26 structure = collections.defaultdict(dict)
28 for root, dirs, files
in os.walk(pkg_root):
29 if '.git' in root
or '.svn' in root:
32 ext = os.path.splitext(fn)[-1]
33 full =
'%s/%s' % (root, fn)
34 rel_fn = full.replace(pkg_root +
'/',
'')
36 if fn[-1] ==
'~' or fn[-4:] ==
'.pyc':
39 structure[
'key'][rel_fn] = full
41 structure[
'source'][rel_fn] = full
42 elif ext ==
'.launch':
43 structure[
'launch'][rel_fn] = full
44 elif ext
in GENERATORS:
45 structure[
'generators'][rel_fn] = full
46 elif ext ==
'.cfg' and 'cfg/' in full:
47 structure[
'cfg'][rel_fn] = full
48 elif ext
in [
'.urdf',
'.xacro']:
49 structure[
'urdf'][rel_fn] = full
def is_python_hashbang_line(s)
def get_filetype_by_contents(filename, ext)
def get_package_structure(pkg_root)