mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-09-29 23:41:05 +00:00
Make sure that regexp are raw strings
This commit is contained in:
parent
2cf690d88e
commit
3d2f10dae7
@ -53,7 +53,7 @@ def split_into_nested_ifdef_sections(code):
|
|||||||
header = 'text'
|
header = 'text'
|
||||||
in_section_depth = 0
|
in_section_depth = 0
|
||||||
for i, line in enumerate(code.splitlines()):
|
for i, line in enumerate(code.splitlines()):
|
||||||
m = re.match('^(\s*)#(\s*)(\w+)(.*)$', line)
|
m = re.match(r'^(\s*)#(\s*)(\w+)(.*)$', line)
|
||||||
line_is = 'normal'
|
line_is = 'normal'
|
||||||
if m:
|
if m:
|
||||||
p0, p1, fcn, stuff = m.groups()
|
p0, p1, fcn, stuff = m.groups()
|
||||||
@ -121,11 +121,11 @@ def flatten_section_text(sections):
|
|||||||
class impl_class(object):
|
class impl_class(object):
|
||||||
def __init__(self, kern_name, header, body):
|
def __init__(self, kern_name, header, body):
|
||||||
#extract LV_HAVE_*
|
#extract LV_HAVE_*
|
||||||
self.deps = set(res.lower() for res in re.findall('LV_HAVE_(\w+)', header))
|
self.deps = set(res.lower() for res in re.findall(r'LV_HAVE_(\w+)', header))
|
||||||
#extract function suffix and args
|
#extract function suffix and args
|
||||||
body = flatten_section_text(body)
|
body = flatten_section_text(body)
|
||||||
try:
|
try:
|
||||||
fcn_matcher = re.compile('^.*(%s\\w*)\\s*\\((.*)$'%kern_name, re.DOTALL | re.MULTILINE)
|
fcn_matcher = re.compile(r'^.*(%s\w*)\s*\((.*)$'%kern_name, re.DOTALL | re.MULTILINE)
|
||||||
body = body.split('{')[0].rsplit(')', 1)[0] #get the part before the open ){ bracket
|
body = body.split('{')[0].rsplit(')', 1)[0] #get the part before the open ){ bracket
|
||||||
m = fcn_matcher.match(body)
|
m = fcn_matcher.match(body)
|
||||||
impl_name, the_rest = m.groups()
|
impl_name, the_rest = m.groups()
|
||||||
@ -133,7 +133,7 @@ class impl_class(object):
|
|||||||
self.args = list()
|
self.args = list()
|
||||||
fcn_args = the_rest.split(',')
|
fcn_args = the_rest.split(',')
|
||||||
for fcn_arg in fcn_args:
|
for fcn_arg in fcn_args:
|
||||||
arg_matcher = re.compile('^\s*(.*\\W)\s*(\w+)\s*$', re.DOTALL | re.MULTILINE)
|
arg_matcher = re.compile(r'^\s*(.*\W)\s*(\w+)\s*$', re.DOTALL | re.MULTILINE)
|
||||||
m = arg_matcher.match(fcn_arg)
|
m = arg_matcher.match(fcn_arg)
|
||||||
arg_type, arg_name = m.groups()
|
arg_type, arg_name = m.groups()
|
||||||
self.args.append((arg_type, arg_name))
|
self.args.append((arg_type, arg_name))
|
||||||
@ -153,7 +153,7 @@ def extract_lv_haves(code):
|
|||||||
haves = list()
|
haves = list()
|
||||||
for line in code.splitlines():
|
for line in code.splitlines():
|
||||||
if not line.strip().startswith('#'): continue
|
if not line.strip().startswith('#'): continue
|
||||||
have_set = set(res.lower() for res in re.findall('LV_HAVE_(\w+)', line))
|
have_set = set(res.lower() for res in re.findall(r'LV_HAVE_(\w+)', line))
|
||||||
if have_set: haves.append(have_set)
|
if have_set: haves.append(have_set)
|
||||||
return haves
|
return haves
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ from six.moves import configparser, input
|
|||||||
|
|
||||||
class volk_gnsssdr_modtool_config(object):
|
class volk_gnsssdr_modtool_config(object):
|
||||||
def key_val_sub(self, num, stuff, section):
|
def key_val_sub(self, num, stuff, section):
|
||||||
return re.sub('\$' + 'k' + str(num), stuff[num][0], (re.sub('\$' + str(num), stuff[num][1], section[1][num])));
|
return re.sub(r'\$' + 'k' + str(num), stuff[num][0], (re.sub(r'\$' + str(num), stuff[num][1], section[1][num])));
|
||||||
|
|
||||||
def verify(self):
|
def verify(self):
|
||||||
for i in self.verification:
|
for i in self.verification:
|
||||||
@ -95,4 +95,3 @@ class volk_gnsssdr_modtool_config(object):
|
|||||||
for i in stuff:
|
for i in stuff:
|
||||||
retval[i[0]] = i[1]
|
retval[i[0]] = i[1]
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@ class volk_gnsssdr_modtool(object):
|
|||||||
def __init__(self, cfg):
|
def __init__(self, cfg):
|
||||||
self.volk_gnsssdr = re.compile('volk_gnsssdr');
|
self.volk_gnsssdr = re.compile('volk_gnsssdr');
|
||||||
self.remove_after_underscore = re.compile("_.*");
|
self.remove_after_underscore = re.compile("_.*");
|
||||||
self.volk_gnsssdr_run_tests = re.compile('^\s*VOLK_RUN_TESTS.*\n', re.MULTILINE);
|
self.volk_gnsssdr_run_tests = re.compile(r'^\s*VOLK_RUN_TESTS.*\n', re.MULTILINE);
|
||||||
self.volk_gnsssdr_profile = re.compile('^\s*(VOLK_PROFILE|VOLK_PUPPET_PROFILE).*\n', re.MULTILINE);
|
self.volk_gnsssdr_profile = re.compile(r'^\s*(VOLK_PROFILE|VOLK_PUPPET_PROFILE).*\n', re.MULTILINE);
|
||||||
self.my_dict = cfg;
|
self.my_dict = cfg;
|
||||||
self.lastline = re.compile('\s*char path\[1024\];.*');
|
self.lastline = re.compile(r'\s*char path\[1024\];.*');
|
||||||
self.badassert = re.compile('^\s*assert\(toked\[0\] == "volk_gnsssdr_.*\n', re.MULTILINE);
|
self.badassert = re.compile(r'^\s*assert\(toked\[0\] == "volk_gnsssdr_.*\n', re.MULTILINE);
|
||||||
self.goodassert = ' assert(toked[0] == "volk_gnsssdr");\n'
|
self.goodassert = ' assert(toked[0] == "volk_gnsssdr");\n'
|
||||||
self.baderase = re.compile('^\s*toked.erase\(toked.begin\(\)\);.*\n', re.MULTILINE);
|
self.baderase = re.compile(r'^\s*toked.erase\(toked.begin\(\)\);.*\n', re.MULTILINE);
|
||||||
self.gooderase = ' toked.erase(toked.begin());\n toked.erase(toked.begin());\n';
|
self.gooderase = ' toked.erase(toked.begin());\n toked.erase(toked.begin());\n';
|
||||||
|
|
||||||
def get_basename(self, base=None):
|
def get_basename(self, base=None):
|
||||||
@ -65,7 +65,7 @@ class volk_gnsssdr_modtool(object):
|
|||||||
|
|
||||||
for line in hdr_files:
|
for line in hdr_files:
|
||||||
|
|
||||||
subline = re.search(".*\.h.*", os.path.basename(line))
|
subline = re.search(r".*\.h.*", os.path.basename(line))
|
||||||
if subline:
|
if subline:
|
||||||
subsubline = begins.search(subline.group(0));
|
subsubline = begins.search(subline.group(0));
|
||||||
if subsubline:
|
if subsubline:
|
||||||
@ -81,7 +81,7 @@ class volk_gnsssdr_modtool(object):
|
|||||||
for dt in datatypes:
|
for dt in datatypes:
|
||||||
if dt in line:
|
if dt in line:
|
||||||
#subline = re.search("(?<=volk_gnsssdr_)" + dt + ".*(?=\.h)", line);
|
#subline = re.search("(?<=volk_gnsssdr_)" + dt + ".*(?=\.h)", line);
|
||||||
subline = re.search(begins.pattern[:-2] + dt + ".*(?=\.h)", line);
|
subline = re.search(begins.pattern[:-2] + dt + r".*(?=\.h)", line);
|
||||||
if subline:
|
if subline:
|
||||||
functions.append(subline.group(0));
|
functions.append(subline.group(0));
|
||||||
|
|
||||||
@ -188,8 +188,8 @@ class volk_gnsssdr_modtool(object):
|
|||||||
inpath = os.path.abspath(base);
|
inpath = os.path.abspath(base);
|
||||||
kernel = re.compile(name)
|
kernel = re.compile(name)
|
||||||
search_kernels = set([kernel])
|
search_kernels = set([kernel])
|
||||||
profile = re.compile('^\s*VOLK_PROFILE')
|
profile = re.compile(r'^\s*VOLK_PROFILE')
|
||||||
puppet = re.compile('^\s*VOLK_PUPPET')
|
puppet = re.compile(r'^\s*VOLK_PUPPET')
|
||||||
src_dest = os.path.join(inpath, 'apps/', top[:-1] + '_profile.cc');
|
src_dest = os.path.join(inpath, 'apps/', top[:-1] + '_profile.cc');
|
||||||
infile = open(src_dest);
|
infile = open(src_dest);
|
||||||
otherlines = infile.readlines();
|
otherlines = infile.readlines();
|
||||||
@ -257,8 +257,8 @@ class volk_gnsssdr_modtool(object):
|
|||||||
kernel = re.compile(name)
|
kernel = re.compile(name)
|
||||||
search_kernels = set([kernel])
|
search_kernels = set([kernel])
|
||||||
|
|
||||||
profile = re.compile('^\s*VOLK_PROFILE')
|
profile = re.compile(r'^\s*VOLK_PROFILE')
|
||||||
puppet = re.compile('^\s*VOLK_PUPPET')
|
puppet = re.compile(r'^\s*VOLK_PUPPET')
|
||||||
infile = open(os.path.join(inpath, 'apps/', oldvolk_gnsssdr.pattern + '_profile.cc'));
|
infile = open(os.path.join(inpath, 'apps/', oldvolk_gnsssdr.pattern + '_profile.cc'));
|
||||||
otherinfile = open(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'apps/volk_gnsssdr_' + self.my_dict['name'] + '_profile.cc'));
|
otherinfile = open(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'apps/volk_gnsssdr_' + self.my_dict['name'] + '_profile.cc'));
|
||||||
dest = os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'apps/volk_gnsssdr_' + self.my_dict['name'] + '_profile.cc');
|
dest = os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'apps/volk_gnsssdr_' + self.my_dict['name'] + '_profile.cc');
|
||||||
|
Loading…
Reference in New Issue
Block a user