util.py
Go to the documentation of this file.
1 import collections
2 import rospkg
3 import os
4 import stat
5 import yaml
6 
7 CONFIG_PATH = os.path.expanduser('~/.ros/roscompile.yaml')
8 CONFIG = None
9 PKG_PATH = rospkg.RosPack().get_path('roscompile')
10 
11 roscompile_functions = collections.OrderedDict()
12 
13 
14 def roscompile(f):
15  roscompile_functions[f.__name__] = f
16  return f
17 
18 
19 def get_ignore_data_helper(basename, add_newline=True):
20  fn = os.path.join(PKG_PATH, 'data', basename + '.ignore')
21  lines = []
22  for s in open(fn):
23  if s == '\n':
24  continue
25  if add_newline:
26  lines.append(s)
27  else:
28  lines.append(s[:-1])
29  return lines
30 
31 
32 def get_ignore_data(name, variables=None, add_newline=True):
33  ignore_lines = get_ignore_data_helper(name, add_newline)
34  if not variables:
35  return ignore_lines
36  for pattern in get_ignore_data_helper(name + '_patterns', add_newline):
37  ignore_lines.append(pattern % variables)
38  return ignore_lines
39 
40 
42  existing_permissions = stat.S_IMODE(os.lstat(fn).st_mode)
43  os.chmod(fn, existing_permissions | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
44 
45 
46 def get_config():
47  global CONFIG
48  if CONFIG is None:
49  if os.path.exists(CONFIG_PATH):
50  CONFIG = yaml.load(open(CONFIG_PATH))
51  else:
52  CONFIG = {}
53  return CONFIG
def get_ignore_data(name, variables=None, add_newline=True)
Definition: util.py:32
def make_executable(fn)
Definition: util.py:41
def get_ignore_data_helper(basename, add_newline=True)
Definition: util.py:19
def roscompile(f)
Definition: util.py:14
def get_config()
Definition: util.py:46


roscompile
Author(s):
autogenerated on Wed Jun 19 2019 19:56:53