4 VAR_PATTERN = re.compile(
r'\*\*([\w_]+)\)')
5 EQ_PATTERN = re.compile(
r'([\w_]+)\s*=([^,]+)')
10 TEMPLATE =
"""#!/usr/bin/env python 12 from %(import_pkg)s import setup 13 from catkin_pkg.python_setup import generate_distutils_setup 15 %(var)s = generate_distutils_setup( 16 packages=['%(name)s'],%(exec)s 17 package_dir={'': 'src'} 28 self.
var =
'package_info' 33 original = open(self.
file_path,
'r').read() 36 self.
noetic =
'distutils.core' not in original
39 m = VAR_PATTERN.search(original)
44 key_s =
'generate_distutils_setup' 45 if key_s
not in original:
47 i = original.index(key_s) + len(key_s)
48 p_i = original.index(
'(', i)
49 ep_i = original.index(
')', p_i)
50 body = original[p_i + 1:ep_i]
51 for var_name, value
in EQ_PATTERN.findall(body):
52 if var_name ==
'scripts':
53 self.
execs = eval(value)
65 if len(self.
execs) > 0:
66 execs = EXEC_TEMPLATE % repr(self.
execs)
70 params = {
'name': self.
pkg_name,
'var': self.
var,
'exec': execs}
72 params[
'import_pkg'] =
'setuptools' 74 params[
'import_pkg'] =
'distutils.core' 75 return TEMPLATE % params
def __init__(self, pkg_name, file_path)