Skip to content

Commit bab3c3f

Browse files
argilomarcusmueller
authored andcommittedNov 1, 2018
Fix invalid escape sequences.
1 parent 63d4bb4 commit bab3c3f

File tree

14 files changed

+57
-61
lines changed

14 files changed

+57
-61
lines changed
 

‎docs/doxygen/other/doxypy.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,22 @@ class Doxypy(object):
9797
def __init__(self):
9898
string_prefixes = "[uU]?[rR]?"
9999

100-
self.start_single_comment_re = re.compile("^\s*%s(''')" % string_prefixes)
101-
self.end_single_comment_re = re.compile("(''')\s*$")
100+
self.start_single_comment_re = re.compile(r"^\s*%s(''')" % string_prefixes)
101+
self.end_single_comment_re = re.compile(r"(''')\s*$")
102102

103-
self.start_double_comment_re = re.compile("^\s*%s(\"\"\")" % string_prefixes)
104-
self.end_double_comment_re = re.compile("(\"\"\")\s*$")
103+
self.start_double_comment_re = re.compile(r'^\s*%s(""")' % string_prefixes)
104+
self.end_double_comment_re = re.compile(r'(""")\s*$')
105105

106-
self.single_comment_re = re.compile("^\s*%s(''').*(''')\s*$" % string_prefixes)
107-
self.double_comment_re = re.compile("^\s*%s(\"\"\").*(\"\"\")\s*$" % string_prefixes)
106+
self.single_comment_re = re.compile(r"^\s*%s(''').*(''')\s*$" % string_prefixes)
107+
self.double_comment_re = re.compile(r'^\s*%s(""").*(""")\s*$' % string_prefixes)
108108

109-
self.defclass_re = re.compile("^(\s*)(def .+:|class .+:)")
110-
self.empty_re = re.compile("^\s*$")
111-
self.hashline_re = re.compile("^\s*#.*$")
112-
self.importline_re = re.compile("^\s*(import |from .+ import)")
109+
self.defclass_re = re.compile(r"^(\s*)(def .+:|class .+:)")
110+
self.empty_re = re.compile(r"^\s*$")
111+
self.hashline_re = re.compile(r"^\s*#.*$")
112+
self.importline_re = re.compile(r"^\s*(import |from .+ import)")
113113

114-
self.multiline_defclass_start_re = re.compile("^(\s*)(def|class)(\s.*)?$")
115-
self.multiline_defclass_end_re = re.compile(":\s*$")
114+
self.multiline_defclass_start_re = re.compile(r"^(\s*)(def|class)(\s.*)?$")
115+
self.multiline_defclass_end_re = re.compile(r":\s*$")
116116

117117
## Transition list format
118118
# ["FROM", "TO", condition, action]

‎docs/sphinx/hieroglyph/test/test_comments.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def test_comment6(self):
269269
u' A Record which has a named attribute for each of the keyword arguments.',
270270
u'']
271271

272-
expected = """A convenience factory for creating Records.
272+
expected = r"""A convenience factory for creating Records.
273273
274274
:param \*\*kwargs: Each keyword argument will be used to initialise an
275275
attribute with the same name as the argument and the given
@@ -382,7 +382,7 @@ def test_comment8(self):
382382
A Record which has a named attribute for each of the keyword arguments.
383383
"""
384384

385-
expected = """A convenience factory for creating Records.
385+
expected = r"""A convenience factory for creating Records.
386386
387387
:param \*\*kwargs: Each keyword argument will be used to initialise an
388388
attribute with the same name as the argument and the given
@@ -584,4 +584,3 @@ def test_comment12(self):
584584

585585
source_lines = source.splitlines()
586586
self.assertRaises(HieroglyphError, lambda: parse_hieroglyph_text(source_lines))
587-

‎gnuradio-runtime/python/gnuradio/ctrlport/monitor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def start(self):
5151
print("monitor::endpoints() = %s" % (gr.rpcmanager_get().endpoints()))
5252
try:
5353
cmd = map(lambda a: [self.tool,
54-
re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)",a).group(1),
55-
re.search("-p (\d+)",a).group(1)],
54+
re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)",a).group(1),
55+
re.search(r"-p (\d+)",a).group(1)],
5656
gr.rpcmanager_get().endpoints())[0]
5757
print("running: %s"%(str(cmd)))
5858
self.proc = subprocess.Popen(cmd);

‎gr-blocks/python/blocks/qa_cpp_py_binding.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def test_002(self):
153153

154154
# Get available endpoint
155155
ep = gr.rpcmanager_get().endpoints()[0]
156-
hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
157-
portnum = re.search("-p (\d+)", ep).group(1)
156+
hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
157+
portnum = re.search(r"-p (\d+)", ep).group(1)
158158
argv = [None, hostname, portnum]
159159

160160
# Initialize a simple ControlPort client from endpoint

‎gr-blocks/python/blocks/qa_cpp_py_binding_set.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def test_002(self):
120120

121121
# Get available endpoint
122122
ep = gr.rpcmanager_get().endpoints()[0]
123-
hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
124-
portnum = re.search("-p (\d+)", ep).group(1)
123+
hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
124+
portnum = re.search(r"-p (\d+)", ep).group(1)
125125
argv = [None, hostname, portnum]
126126

127127
# Initialize a simple ControlPort client from endpoint

‎gr-blocks/python/blocks/qa_ctrlport_probes.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def test_001(self):
5858

5959
# Get available endpoint
6060
ep = gr.rpcmanager_get().endpoints()[0]
61-
hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
62-
portnum = re.search("-p (\d+)", ep).group(1)
61+
hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
62+
portnum = re.search(r"-p (\d+)", ep).group(1)
6363
argv = [None, hostname, portnum]
6464

6565
# Initialize a simple ControlPort client from endpoint
@@ -99,8 +99,8 @@ def test_002(self):
9999

100100
# Get available endpoint
101101
ep = gr.rpcmanager_get().endpoints()[0]
102-
hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
103-
portnum = re.search("-p (\d+)", ep).group(1)
102+
hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
103+
portnum = re.search(r"-p (\d+)", ep).group(1)
104104
argv = [None, hostname, portnum]
105105

106106
# Initialize a simple ControlPort client from endpoint
@@ -139,8 +139,8 @@ def test_003(self):
139139

140140
# Get available endpoint
141141
ep = gr.rpcmanager_get().endpoints()[0]
142-
hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
143-
portnum = re.search("-p (\d+)", ep).group(1)
142+
hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
143+
portnum = re.search(r"-p (\d+)", ep).group(1)
144144
argv = [None, hostname, portnum]
145145

146146
# Initialize a simple ControlPort client from endpoint
@@ -180,8 +180,8 @@ def test_004(self):
180180

181181
# Get available endpoint
182182
ep = gr.rpcmanager_get().endpoints()[0]
183-
hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
184-
portnum = re.search("-p (\d+)", ep).group(1)
183+
hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
184+
portnum = re.search(r"-p (\d+)", ep).group(1)
185185
argv = [None, hostname, portnum]
186186

187187
# Initialize a simple ControlPort client from endpoint
@@ -220,8 +220,8 @@ def test_005(self):
220220

221221
# Get available endpoint
222222
ep = gr.rpcmanager_get().endpoints()[0]
223-
hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
224-
portnum = re.search("-p (\d+)", ep).group(1)
223+
hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
224+
portnum = re.search(r"-p (\d+)", ep).group(1)
225225
argv = [None, hostname, portnum]
226226

227227
# Initialize a simple ControlPort client from endpoint

‎gr-digital/python/digital/qam_constellations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
For 16QAM:
7474
- n = 4
7575
- (2^n)*(n!) = 384
76-
- k \in [0x0, 0xF]
76+
- k \\in [0x0, 0xF]
7777
- pi = 0, 1, 2, 3
7878
0, 1, 3, 2
7979
0, 2, 1, 3

‎gr-filter/python/filter/design/filter_design.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2094,19 +2094,19 @@ def action_open_dialog(self):
20942094
if (row[0] == "restype"):
20952095
restype = row[1]
20962096
elif(row[0] == "taps"):
2097-
testcpx = re.findall("[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1])
2097+
testcpx = re.findall(r"[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1])
20982098
if(len(testcpx) > 0): # it's a complex
20992099
taps = [complex(r) for r in row[1:]]
21002100
else:
21012101
taps = [float(r) for r in row[1:]]
21022102
elif(row[0] == "b" or row[0] == "a"):
2103-
testcpx = re.findall("[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1])
2103+
testcpx = re.findall(r"[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1])
21042104
if(len(testcpx) > 0): # it's a complex
21052105
b_a[row[0]] = [complex(r) for r in row[1:]]
21062106
else:
21072107
b_a[row[0]]= [float(r) for r in row[1:]]
21082108
else:
2109-
testcpx = re.findall("[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1])
2109+
testcpx = re.findall(r"[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1])
21102110
if(len(testcpx) > 0): # it's a complex
21112111
params[row[0]] = complex(row[1])
21122112
else: # assume it's a float

‎gr-utils/python/modtool/cmakefile_editor.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, filename, separator='\n ', indent=' '):
3535

3636
def append_value(self, entry, value, to_ignore_start='', to_ignore_end=''):
3737
""" Add a value to an entry. """
38-
regexp = re.compile('(%s\(%s[^()]*?)\s*?(\s?%s)\)' % (entry, to_ignore_start, to_ignore_end),
38+
regexp = re.compile(r'(%s\(%s[^()]*?)\s*?(\s?%s)\)' % (entry, to_ignore_start, to_ignore_end),
3939
re.MULTILINE)
4040
substi = r'\1' + self.separator + value + r'\2)'
4141
(self.cfile, nsubs) = regexp.subn(substi, self.cfile, count=1)
@@ -80,7 +80,7 @@ def remove_value(self, entry, value, to_ignore_start='', to_ignore_end=''):
8080

8181
def delete_entry(self, entry, value_pattern=''):
8282
"""Remove an entry from the current buffer."""
83-
regexp = '%s\s*\([^()]*%s[^()]*\)[^\n]*\n' % (entry, value_pattern)
83+
regexp = r'%s\s*\([^()]*%s[^()]*\)[^\n]*\n' % (entry, value_pattern)
8484
regexp = re.compile(regexp, re.MULTILINE)
8585
(self.cfile, nsubs) = re.subn(regexp, '', self.cfile, count=1)
8686
return nsubs
@@ -98,7 +98,7 @@ def find_filenames_match(self, regex):
9898
on lines that aren't comments """
9999
filenames = []
100100
reg = re.compile(regex)
101-
fname_re = re.compile('[a-zA-Z]\w+\.\w{1,5}$')
101+
fname_re = re.compile(r'[a-zA-Z]\w+\.\w{1,5}$')
102102
for line in self.cfile.splitlines():
103103
if len(line.strip()) == 0 or line.strip()[0] == '#':
104104
continue
@@ -141,6 +141,5 @@ def comment_out_lines(self, pattern, comment_str='#'):
141141

142142
def check_for_glob(self, globstr):
143143
""" Returns true if a glob as in globstr is found in the cmake file """
144-
glob_re = r'GLOB\s[a-z_]+\s"%s"' % globstr.replace('*', '\*')
144+
glob_re = r'GLOB\s[a-z_]+\s"%s"' % globstr.replace('*', r'\*')
145145
return re.search(glob_re, self.cfile, flags=re.MULTILINE|re.IGNORECASE) is not None
146-

‎gr-utils/python/modtool/modtool_disable.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def _handle_i_swig(cmake, fname):
117117
blockname = os.path.splitext(fname[len(self._info['modname'])+1:])[0]
118118
if self._info['version'] in ('37', '38'):
119119
blockname = os.path.splitext(fname)[0]
120-
swigfile = re.sub('(%include\s+"'+fname+'")', r'//\1', swigfile)
120+
swigfile = re.sub(r'(%include\s+"'+fname+r'")', r'//\1', swigfile)
121121
print("Changing %s..." % self._file['swig'])
122122
swigfile = re.sub('(GR_SWIG_BLOCK_MAGIC2?.+'+blockname+'.+;)', r'//\1', swigfile)
123123
open(self._file['swig'], 'w').write(swigfile)
@@ -163,4 +163,3 @@ def _handle_i_swig(cmake, fname):
163163
cmake.write()
164164
self.scm.mark_files_updated((os.path.join(subdir, 'CMakeLists.txt'),))
165165
print("Careful: 'gr_modtool disable' does not resolve dependencies.")
166-

‎gr-utils/python/modtool/parser_cc_block.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _figure_out_iotype_and_vlen(iosigcall, typestr):
5353
}
5454
def _typestr_to_iotype(typestr):
5555
""" Convert a type string (e.g. sizeof(int) * vlen) to the type (e.g. 'int'). """
56-
type_match = re.search('sizeof\s*\(([^)]*)\)', typestr)
56+
type_match = re.search(r'sizeof\s*\(([^)]*)\)', typestr)
5757
if type_match is None:
5858
return self.type_trans('char')
5959
return self.type_trans(type_match.group(1))
@@ -76,10 +76,10 @@ def _typestr_to_vlen(typestr):
7676
elif len(vlen_parts) > 1:
7777
return '*'.join(vlen_parts).strip()
7878
iosig = {}
79-
iosig_regex = '(?P<incall>gr::io_signature::make[23v]?)\s*\(\s*(?P<inmin>[^,]+),\s*(?P<inmax>[^,]+),' + \
80-
'\s*(?P<intype>(\([^\)]*\)|[^)])+)\),\s*' + \
81-
'(?P<outcall>gr::io_signature::make[23v]?)\s*\(\s*(?P<outmin>[^,]+),\s*(?P<outmax>[^,]+),' + \
82-
'\s*(?P<outtype>(\([^\)]*\)|[^)])+)\)'
79+
iosig_regex = r'(?P<incall>gr::io_signature::make[23v]?)\s*\(\s*(?P<inmin>[^,]+),\s*(?P<inmax>[^,]+),' + \
80+
r'\s*(?P<intype>(\([^\)]*\)|[^)])+)\),\s*' + \
81+
r'(?P<outcall>gr::io_signature::make[23v]?)\s*\(\s*(?P<outmin>[^,]+),\s*(?P<outmax>[^,]+),' + \
82+
r'\s*(?P<outtype>(\([^\)]*\)|[^)])+)\)'
8383
iosig_match = re.compile(iosig_regex, re.MULTILINE).search(self.code_cc)
8484
try:
8585
iosig['in'] = _figure_out_iotype_and_vlen(iosig_match.group('incall'),
@@ -210,9 +210,9 @@ def _scan_param_list(start_idx):
210210
return param_list
211211
# Go, go, go!
212212
if self.version in ('37', '38'):
213-
make_regex = 'static\s+sptr\s+make\s*'
213+
make_regex = r'static\s+sptr\s+make\s*'
214214
else:
215-
make_regex = '(?<=_API)\s+\w+_sptr\s+\w+_make_\w+\s*'
215+
make_regex = r'(?<=_API)\s+\w+_sptr\s+\w+_make_\w+\s*'
216216
make_match = re.compile(make_regex, re.MULTILINE).search(self.code_h)
217217
try:
218218
params_list = _scan_param_list(make_match.end(0))
@@ -226,4 +226,3 @@ def _scan_param_list(start_idx):
226226
'default': plist[2],
227227
'in_constructor': True})
228228
return params
229-

‎gr-utils/python/modtool/templates.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class ${blockname}_impl : public ${blockname}
276276
'''
277277

278278
# Block definition header file (for include/)
279-
Templates['block_def_h'] = '''/* -*- c++ -*- */
279+
Templates['block_def_h'] = r'''/* -*- c++ -*- */
280280
${str_to_fancyc_comment(license)}
281281
282282
#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H
@@ -292,7 +292,7 @@ class ${blockname}_impl : public ${blockname}
292292
293293
% if blocktype == 'noblock':
294294
/*!
295-
* \\brief <+description+>
295+
* \brief <+description+>
296296
*
297297
*/
298298
class ${modname.upper()}_API ${blockname}
@@ -304,7 +304,7 @@ class ${modname.upper()}_API ${blockname}
304304
};
305305
% else:
306306
/*!
307-
* \\brief <+description of block+>
307+
* \brief <+description of block+>
308308
* \ingroup ${modname}
309309
*
310310
*/
@@ -314,7 +314,7 @@ class ${modname.upper()}_API ${blockname} : virtual public gr::${grblocktype}
314314
typedef boost::shared_ptr<${blockname}> sptr;
315315
316316
/*!
317-
* \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}.
317+
* \brief Return a shared_ptr to a new instance of ${modname}::${blockname}.
318318
*
319319
* To avoid accidental use of raw pointers, ${modname}::${blockname}'s
320320
* constructor is in a private implementation
@@ -417,7 +417,7 @@ def forecast(self, noutput_items, ninput_items_required):
417417
def general_work(self, input_items, output_items):
418418
output_items[0][:] = input_items[0]
419419
consume(0, len(input_items[0]))
420-
\#self.consume_each(len(input_items[0]))
420+
\\#self.consume_each(len(input_items[0]))
421421
return len(output_items[0])
422422
<% return %>
423423
% endif
@@ -547,7 +547,7 @@ def test_001_t(self):
547547
gr_unittest.run(qa_${blockname}, "qa_${blockname}.xml")
548548
'''
549549

550-
Templates['grc_xml'] = '''<?xml version="1.0"?>
550+
Templates['grc_xml'] = r'''<?xml version="1.0"?>
551551
<block>
552552
<name>${blockname}</name>
553553
<key>${modname}_${blockname}</key>
@@ -724,7 +724,7 @@ def test_001_t(self):
724724
'''
725725

726726
# Block definition header file (for include/)
727-
Templates['block_h36'] = '''/* -*- c++ -*- */
727+
Templates['block_h36'] = r'''/* -*- c++ -*- */
728728
${str_to_fancyc_comment(license)}
729729
730730
#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H
@@ -749,7 +749,7 @@ class ${modname}_${blockname};
749749
${modname.upper()}_API ${modname}_${blockname}_sptr ${modname}_make_${blockname} (${arglist});
750750
751751
/*!
752-
* \\brief <+description+>
752+
* \brief <+description+>
753753
* \ingroup ${modname}
754754
*
755755
*/

‎grc/converter/cheetah_converter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def extra_close():
247247

248248
out = ''.join(out)
249249
# fix: eval stuff
250-
out = re.sub(r'(?P<arg>' + r'|'.join(self.extended) + r')\(\)', '\g<arg>', out)
250+
out = re.sub(r'(?P<arg>' + r'|'.join(self.extended) + r')\(\)', r'\g<arg>', out)
251251

252252
self.stats['hard'] += 1
253253
return spec.type(out)

‎tools/template_convert.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"GR_EXPAND_X_H", "GR_EXPAND_CC_H", "GR_EXPAND_X_CC_H_IMPL", "GR_EXPAND_X_CC_H"
99
]
1010
template_regex = re.compile(
11-
"^(?P<template_type>" + "|".join(template_keywords) + ")\(" +
12-
"(?P<category>\w+)\s+(?P<name>\w+_XX?X?)(_impl)?\s+(?P<types>[\w\s]+)" + "\)$")
11+
r"^(?P<template_type>" + "|".join(template_keywords) + r")\(" +
12+
r"(?P<category>\w+)\s+(?P<name>\w+_XX?X?)(_impl)?\s+(?P<types>[\w\s]+)" + r"\)$")
1313

1414
cpp_keywords = ["abs", "add", "and", "max", "min" "not" "xor"]
1515
types = {"s": "std::int16_t", "i": "std::int32_t", "b": "std::uint8_t", "c": "gr_complex", "f": "float"}

0 commit comments

Comments
 (0)