Go to the documentation of this file.00001 import collections
00002 import rospkg
00003 import os
00004 import stat
00005 import yaml
00006
00007 CONFIG_PATH = os.path.expanduser('~/.ros/roscompile.yaml')
00008 CONFIG = None
00009 PKG_PATH = rospkg.RosPack().get_path('roscompile')
00010
00011 roscompile_functions = collections.OrderedDict()
00012
00013
00014 def roscompile(f):
00015 roscompile_functions[f.__name__] = f
00016 return f
00017
00018
00019 def get_ignore_data_helper(basename, add_newline=True):
00020 fn = os.path.join(PKG_PATH, 'data', basename + '.ignore')
00021 lines = []
00022 for s in open(fn):
00023 if s == '\n':
00024 continue
00025 if add_newline:
00026 lines.append(s)
00027 else:
00028 lines.append(s[:-1])
00029 return lines
00030
00031
00032 def get_ignore_data(name, variables=None, add_newline=True):
00033 ignore_lines = get_ignore_data_helper(name, add_newline)
00034 if not variables:
00035 return ignore_lines
00036 for pattern in get_ignore_data_helper(name + '_patterns', add_newline):
00037 ignore_lines.append(pattern % variables)
00038 return ignore_lines
00039
00040
00041 def make_executable(fn):
00042 existing_permissions = stat.S_IMODE(os.lstat(fn).st_mode)
00043 os.chmod(fn, existing_permissions | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
00044
00045
00046 def get_config():
00047 global CONFIG
00048 if CONFIG is None:
00049 if os.path.exists(CONFIG_PATH):
00050 CONFIG = yaml.load(open(CONFIG_PATH))
00051 else:
00052 CONFIG = {}
00053 return CONFIG