glob_helper.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import fnmatch
5 
6 topics_glob = []
7 services_glob = []
8 params_glob = []
9 
10 
11 def get_globs():
12 
13  global topics_glob
14  global services_glob
15  global params_glob
16 
17  def get_param(param_name):
18  param = rospy.get_param(param_name, '')
19  # strips array delimiters in case of an array style value
20  return [
21  element.strip().strip("'")
22  for element in param.strip('[').strip(']').split(',')
23  if len(element.strip().strip("'")) > 0]
24 
25  topics_glob = get_param('~topics_glob')
26  services_glob = get_param('~services_glob')
27  params_glob = get_param('~params_glob')
28 
29 
30 def filter_globs(globs, full_list):
31  # If the globs are empty (weren't defined in the params), return the full list
32  if globs is not None and len(globs) > 0:
33  return filter(lambda x: any_match(x, globs), full_list)
34  else:
35  return full_list
36 
37 
38 def any_match(query, globs):
39  return globs is None or len(globs) == 0 or any(fnmatch.fnmatch(str(query), glob) for glob in globs)
40 
def filter_globs(globs, full_list)
Definition: glob_helper.py:30
def any_match(query, globs)
Definition: glob_helper.py:38
def get_param(name, default, params_glob)
Definition: params.py:62


rosapi
Author(s): Jonathan Mace
autogenerated on Wed Jun 3 2020 03:55:16