diff options
author | Clayton Smith <argilo@gmail.com> | 2018-09-26 08:16:08 -0400 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-11-01 13:56:52 +0100 |
commit | bab3c3fbc1e4a0bc303b88077514144fd6e3a434 (patch) | |
tree | cba3a098c823f298e05dca691ac2fb2b5ba197a7 /gr-utils/python | |
parent | 63d4bb4b47a2b66be05b16cf0164f3cd57ca92fa (diff) |
Fix invalid escape sequences.
Diffstat (limited to 'gr-utils/python')
-rw-r--r-- | gr-utils/python/modtool/cmakefile_editor.py | 9 | ||||
-rw-r--r-- | gr-utils/python/modtool/modtool_disable.py | 3 | ||||
-rw-r--r-- | gr-utils/python/modtool/parser_cc_block.py | 15 | ||||
-rw-r--r-- | gr-utils/python/modtool/templates.py | 16 |
4 files changed, 20 insertions, 23 deletions
diff --git a/gr-utils/python/modtool/cmakefile_editor.py b/gr-utils/python/modtool/cmakefile_editor.py index 1b644287f9..40d88fac18 100644 --- a/gr-utils/python/modtool/cmakefile_editor.py +++ b/gr-utils/python/modtool/cmakefile_editor.py @@ -35,7 +35,7 @@ class CMakeFileEditor(object): def append_value(self, entry, value, to_ignore_start='', to_ignore_end=''): """ Add a value to an entry. """ - regexp = re.compile('(%s\(%s[^()]*?)\s*?(\s?%s)\)' % (entry, to_ignore_start, to_ignore_end), + regexp = re.compile(r'(%s\(%s[^()]*?)\s*?(\s?%s)\)' % (entry, to_ignore_start, to_ignore_end), re.MULTILINE) substi = r'\1' + self.separator + value + r'\2)' (self.cfile, nsubs) = regexp.subn(substi, self.cfile, count=1) @@ -80,7 +80,7 @@ class CMakeFileEditor(object): def delete_entry(self, entry, value_pattern=''): """Remove an entry from the current buffer.""" - regexp = '%s\s*\([^()]*%s[^()]*\)[^\n]*\n' % (entry, value_pattern) + regexp = r'%s\s*\([^()]*%s[^()]*\)[^\n]*\n' % (entry, value_pattern) regexp = re.compile(regexp, re.MULTILINE) (self.cfile, nsubs) = re.subn(regexp, '', self.cfile, count=1) return nsubs @@ -98,7 +98,7 @@ class CMakeFileEditor(object): on lines that aren't comments """ filenames = [] reg = re.compile(regex) - fname_re = re.compile('[a-zA-Z]\w+\.\w{1,5}$') + fname_re = re.compile(r'[a-zA-Z]\w+\.\w{1,5}$') for line in self.cfile.splitlines(): if len(line.strip()) == 0 or line.strip()[0] == '#': continue @@ -141,6 +141,5 @@ class CMakeFileEditor(object): def check_for_glob(self, globstr): """ Returns true if a glob as in globstr is found in the cmake file """ - glob_re = r'GLOB\s[a-z_]+\s"%s"' % globstr.replace('*', '\*') + glob_re = r'GLOB\s[a-z_]+\s"%s"' % globstr.replace('*', r'\*') return re.search(glob_re, self.cfile, flags=re.MULTILINE|re.IGNORECASE) is not None - diff --git a/gr-utils/python/modtool/modtool_disable.py b/gr-utils/python/modtool/modtool_disable.py index 3a105e407c..ed55389fb7 100644 --- a/gr-utils/python/modtool/modtool_disable.py +++ b/gr-utils/python/modtool/modtool_disable.py @@ -117,7 +117,7 @@ class ModToolDisable(ModTool): blockname = os.path.splitext(fname[len(self._info['modname'])+1:])[0] if self._info['version'] in ('37', '38'): blockname = os.path.splitext(fname)[0] - swigfile = re.sub('(%include\s+"'+fname+'")', r'//\1', swigfile) + swigfile = re.sub(r'(%include\s+"'+fname+r'")', r'//\1', swigfile) print("Changing %s..." % self._file['swig']) swigfile = re.sub('(GR_SWIG_BLOCK_MAGIC2?.+'+blockname+'.+;)', r'//\1', swigfile) open(self._file['swig'], 'w').write(swigfile) @@ -163,4 +163,3 @@ class ModToolDisable(ModTool): cmake.write() self.scm.mark_files_updated((os.path.join(subdir, 'CMakeLists.txt'),)) print("Careful: 'gr_modtool disable' does not resolve dependencies.") - diff --git a/gr-utils/python/modtool/parser_cc_block.py b/gr-utils/python/modtool/parser_cc_block.py index dd5bbb6be7..766b063ccd 100644 --- a/gr-utils/python/modtool/parser_cc_block.py +++ b/gr-utils/python/modtool/parser_cc_block.py @@ -53,7 +53,7 @@ class ParserCCBlock(object): } def _typestr_to_iotype(typestr): """ Convert a type string (e.g. sizeof(int) * vlen) to the type (e.g. 'int'). """ - type_match = re.search('sizeof\s*\(([^)]*)\)', typestr) + type_match = re.search(r'sizeof\s*\(([^)]*)\)', typestr) if type_match is None: return self.type_trans('char') return self.type_trans(type_match.group(1)) @@ -76,10 +76,10 @@ class ParserCCBlock(object): elif len(vlen_parts) > 1: return '*'.join(vlen_parts).strip() iosig = {} - iosig_regex = '(?P<incall>gr::io_signature::make[23v]?)\s*\(\s*(?P<inmin>[^,]+),\s*(?P<inmax>[^,]+),' + \ - '\s*(?P<intype>(\([^\)]*\)|[^)])+)\),\s*' + \ - '(?P<outcall>gr::io_signature::make[23v]?)\s*\(\s*(?P<outmin>[^,]+),\s*(?P<outmax>[^,]+),' + \ - '\s*(?P<outtype>(\([^\)]*\)|[^)])+)\)' + iosig_regex = r'(?P<incall>gr::io_signature::make[23v]?)\s*\(\s*(?P<inmin>[^,]+),\s*(?P<inmax>[^,]+),' + \ + r'\s*(?P<intype>(\([^\)]*\)|[^)])+)\),\s*' + \ + r'(?P<outcall>gr::io_signature::make[23v]?)\s*\(\s*(?P<outmin>[^,]+),\s*(?P<outmax>[^,]+),' + \ + r'\s*(?P<outtype>(\([^\)]*\)|[^)])+)\)' iosig_match = re.compile(iosig_regex, re.MULTILINE).search(self.code_cc) try: iosig['in'] = _figure_out_iotype_and_vlen(iosig_match.group('incall'), @@ -210,9 +210,9 @@ class ParserCCBlock(object): return param_list # Go, go, go! if self.version in ('37', '38'): - make_regex = 'static\s+sptr\s+make\s*' + make_regex = r'static\s+sptr\s+make\s*' else: - make_regex = '(?<=_API)\s+\w+_sptr\s+\w+_make_\w+\s*' + make_regex = r'(?<=_API)\s+\w+_sptr\s+\w+_make_\w+\s*' make_match = re.compile(make_regex, re.MULTILINE).search(self.code_h) try: params_list = _scan_param_list(make_match.end(0)) @@ -226,4 +226,3 @@ class ParserCCBlock(object): 'default': plist[2], 'in_constructor': True}) return params - diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py index 0f6dcb500e..1ba7732d7c 100644 --- a/gr-utils/python/modtool/templates.py +++ b/gr-utils/python/modtool/templates.py @@ -276,7 +276,7 @@ namespace gr { ''' # Block definition header file (for include/) -Templates['block_def_h'] = '''/* -*- c++ -*- */ +Templates['block_def_h'] = r'''/* -*- c++ -*- */ ${str_to_fancyc_comment(license)} #ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H @@ -292,7 +292,7 @@ namespace gr { % if blocktype == 'noblock': /*! - * \\brief <+description+> + * \brief <+description+> * */ class ${modname.upper()}_API ${blockname} @@ -304,7 +304,7 @@ namespace gr { }; % else: /*! - * \\brief <+description of block+> + * \brief <+description of block+> * \ingroup ${modname} * */ @@ -314,7 +314,7 @@ namespace gr { typedef boost::shared_ptr<${blockname}> sptr; /*! - * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}. + * \brief Return a shared_ptr to a new instance of ${modname}::${blockname}. * * To avoid accidental use of raw pointers, ${modname}::${blockname}'s * constructor is in a private implementation @@ -417,7 +417,7 @@ class ${blockname}(${parenttype}): def general_work(self, input_items, output_items): output_items[0][:] = input_items[0] consume(0, len(input_items[0])) - \#self.consume_each(len(input_items[0])) + \\#self.consume_each(len(input_items[0])) return len(output_items[0]) <% return %> % endif @@ -547,7 +547,7 @@ if __name__ == '__main__': gr_unittest.run(qa_${blockname}, "qa_${blockname}.xml") ''' -Templates['grc_xml'] = '''<?xml version="1.0"?> +Templates['grc_xml'] = r'''<?xml version="1.0"?> <block> <name>${blockname}</name> <key>${modname}_${blockname}</key> @@ -724,7 +724,7 @@ ${modname}_${blockname}::work(int noutput_items, ''' # Block definition header file (for include/) -Templates['block_h36'] = '''/* -*- c++ -*- */ +Templates['block_h36'] = r'''/* -*- c++ -*- */ ${str_to_fancyc_comment(license)} #ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H @@ -749,7 +749,7 @@ typedef boost::shared_ptr<${modname}_${blockname}> ${modname}_${blockname}_sptr; ${modname.upper()}_API ${modname}_${blockname}_sptr ${modname}_make_${blockname} (${arglist}); /*! - * \\brief <+description+> + * \brief <+description+> * \ingroup ${modname} * */ |