3 from source_code_file
import is_python_hashbang_line
5 KEY = [
'package.xml',
'CMakeLists.txt',
'setup.py']
6 SRC_EXTS = [
'.py',
'.cpp',
'.h',
'.hpp',
'.c']
7 GENERATORS = [
'.msg',
'.srv',
'.action']
11 with open(filename)
as f:
12 first_line = f.readline()
15 elif '<launch' in first_line:
17 elif ext ==
'.xml' and (
'<library' in first_line
or '<class_libraries' in first_line):
18 return 'plugin_config' 22 structure = collections.defaultdict(dict)
24 for root, dirs, files
in os.walk(pkg_root):
25 if '.git' in root
or '.svn' in root:
28 ext = os.path.splitext(fn)[-1]
29 full =
'%s/%s' % (root, fn)
30 rel_fn = full.replace(pkg_root +
'/',
'')
32 if fn[-1] ==
'~' or fn[-4:] ==
'.pyc':
35 structure[
'key'][rel_fn] = full
37 structure[
'source'][rel_fn] = full
38 elif ext ==
'.launch':
39 structure[
'launch'][rel_fn] = full
40 elif ext
in GENERATORS:
41 structure[
'generators'][rel_fn] = full
42 elif ext ==
'.cfg' and 'cfg/' in full:
43 structure[
'cfg'][rel_fn] = full
def is_python_hashbang_line(s)
def get_filetype_by_contents(filename, ext)
def get_package_structure(pkg_root)