diff options
-rwxr-xr-x | acprep | 10 | ||||
-rw-r--r-- | contrib/non-profit-audit-reports/ooolib2/__init__.py | 14 | ||||
-rw-r--r-- | test/CheckComments.py | 26 | ||||
-rwxr-xr-x | test/CheckOptions.py | 2 | ||||
-rwxr-xr-x | test/CheckTexinfo.py | 14 | ||||
-rwxr-xr-x | test/ConfirmTests.py | 16 | ||||
-rwxr-xr-x | test/GenerateTests.py | 2 | ||||
-rwxr-xr-x | test/RegressTests.py | 6 | ||||
-rwxr-xr-x | test/convert.py | 130 | ||||
-rwxr-xr-x | tools/genuuid | 6 |
10 files changed, 113 insertions, 113 deletions
@@ -413,16 +413,16 @@ class PrepareBuild(CommandLineApp): version_m4 = open('CMakeLists.txt', 'r') for line in version_m4.readlines(): - match = re.match('^set\(Ledger_VERSION_MAJOR ([0-9]+)\)', line) + match = re.match(r'^set\(Ledger_VERSION_MAJOR ([0-9]+)\)', line) if match: major = match.group(1) - match = re.match('^set\(Ledger_VERSION_MINOR ([0-9]+)\)', line) + match = re.match(r'^set\(Ledger_VERSION_MINOR ([0-9]+)\)', line) if match: minor = match.group(1) - match = re.match('^set\(Ledger_VERSION_PATCH ([0-9]+)\)', line) + match = re.match(r'^set\(Ledger_VERSION_PATCH ([0-9]+)\)', line) if match: patch = match.group(1) - match = re.match('^set\(Ledger_VERSION_DATE ([0-9]+)\)', line) + match = re.match(r'^set\(Ledger_VERSION_DATE ([0-9]+)\)', line) if match: date = match.group(1) break @@ -840,7 +840,7 @@ class PrepareBuild(CommandLineApp): PrepareBuild.__dict__['setup_flavor_' + self.current_flavor](self) def escape_string(self, data): - return re.sub('(["\\\\])', '\\\\\\1', data) + return re.sub(r'(['\\\\])', '\\\\\\1', data) def finalize_config(self): self.setup_flavor() diff --git a/contrib/non-profit-audit-reports/ooolib2/__init__.py b/contrib/non-profit-audit-reports/ooolib2/__init__.py index 0b149e54..5ee3bee9 100644 --- a/contrib/non-profit-audit-reports/ooolib2/__init__.py +++ b/contrib/non-profit-audit-reports/ooolib2/__init__.py @@ -437,11 +437,11 @@ class CalcStyles(object): self.property_cell_hyphenate = value elif name == 'color': self.property_cell_fg_color = 'default' - redata = re.search("^(#[\da-fA-F]{6})$", value) + redata = re.search(r'^(#[\da-fA-F]{6})$', value) if redata: self.property_cell_fg_color = value.lower() elif name == 'background': self.property_cell_bg_color = 'default' - redata = re.search("^(#[\da-fA-F]{6})$", value) + redata = re.search(r'^(#[\da-fA-F]{6})$', value) if redata: self.property_cell_bg_color = value.lower() elif name == 'backgroundimage': self.property_cell_bg_image = value @@ -460,7 +460,7 @@ class CalcStyles(object): property = getattr(self, 'property_cell_%s' % key) if name == key: setattr(self, 'property_cell_%s' % key, [value] * 4) - match = re.match('%s-(top|right|bottom|left)' % key, name) + match = re.match(r'%s-(top|right|bottom|left)' % key, name) if match: property[self.cardinal.index(match.group(1))] = value @@ -606,9 +606,9 @@ class CalcStyles(object): tagline.append(['element', 'style:repeat-content', 'false']) elif name == 'wrap-option': tagline.append(['element', 'fo:wrap-option', value]) - elif re.match('border', name): + elif re.match(r'border', name): tagline.append(['element', 'fo:%s' % name, value]) - elif re.match('padding', name): + elif re.match(r'padding', name): tagline.append(['element', 'fo:%s' % name, value]) # Add any additional internal tags @@ -691,11 +691,11 @@ class CalcSheet(object): # '=IF((A5>A4);A4;"")' # datavalue = 'oooc:=IF(([.A5]>[.A4]);[.A4];"")' data = clean_string(data) - redata = re.search('^=([A-Z]+)(\(.*)$', data) + redata = re.search(r'^=([A-Z]+)(\(.*)$', data) if redata: # funct is the function name. The rest if the string will be the funct_args funct = redata.group(1) - funct_args = re.sub('([A-Z]+\d+)', '[.\\1]', redata.group(2)) + funct_args = re.sub(r'([A-Z]+\d+)', '[.\\1]', redata.group(2)) data = 'oooc:=%s%s' % (funct, funct_args) return data diff --git a/test/CheckComments.py b/test/CheckComments.py index 9bcfcbb3..edc4aed1 100644 --- a/test/CheckComments.py +++ b/test/CheckComments.py @@ -30,34 +30,34 @@ for path in args.path: for line in fd.readlines(): linenum += 1 - match = re.search('/\*\*(.*)', line) + match = re.search(r'/\*\*(.*)', line) if match: - long_comment = re.sub('\s+', '', match.group(1)) + long_comment = re.sub(r'\s+', '', match.group(1)) continue elif long_comment: - match = re.search('(.*)\*/', line) + match = re.search(r'(.*)\*/', line) if match: - long_comment += re.sub('\s+', '', match.group(1)) + long_comment += re.sub(r'\s+', '', match.group(1)) comment_count = len(long_comment) long_comment = None else: - long_comment += re.sub('\s+', '', line[:-1]) + long_comment += re.sub(r'\s+', '', line[:-1]) continue if brace_depth == 0: - match = re.search('(namespace|enum|class|struct|union)', line) + match = re.search(r'(namespace|enum|class|struct|union)', line) if match: kind = match.group(1) if args.debug: print("kind =", kind) elif kind == "function": - match = re.search('(\S+)\(', line) + match = re.search(r'(\S+)\(', line) if match: function_name = match.group(1) long_comments[function_name] = comment_count comment_count = 0 if args.debug: print("name found %s" % function_name) - if re.search('{', line) and not re.search('@{', line): + if re.search(r'{', line) and not re.search('@{', line): if kind == "function": brace_depth += 1 if args.debug: print("brace_depth =", brace_depth) @@ -66,7 +66,7 @@ for path in args.path: kind = "function" if args.debug: print("other_depth =", other_depth) - if re.search('}', line) and not re.search('@}', line): + if re.search(r'}', line) and not re.search('@}', line): if brace_depth > 0: brace_depth -= 1 if args.debug: print("brace_depth =", brace_depth) @@ -101,15 +101,15 @@ for path in args.path: if args.debug: print("other_depth =", other_depth) if brace_depth > 0: - if re.search("TRACE_[CD]TOR", line): + if re.search(r'TRACE_[CD]TOR', line): ctor_dtor = True - line = re.sub('\s+', '', line[:-1]) + line = re.sub(r'\s+', '', line[:-1]) - match = re.search('//(.*)', line) + match = re.search(r'//(.*)', line) if match: comment = match.group(1) - line = re.sub('//.*', '', line) + line = re.sub(r'//.*', '', line) else: comment = None diff --git a/test/CheckOptions.py b/test/CheckOptions.py index cdd9b244..ff288794 100755 --- a/test/CheckOptions.py +++ b/test/CheckOptions.py @@ -60,7 +60,7 @@ class CheckOptions (object): def ledger_options(self): pipe = Popen('%s --debug option.names parse true' % self.ledger, shell=True, stdout=PIPE, stderr=PIPE) - regex = re.compile('\[DEBUG\]\s+Option:\s+(.*?)_?$') + regex = re.compile(r'\[DEBUG\]\s+Option:\s+(.*?)_?$') ledger_options = {match.group(1).replace('_', '-') for match in {regex.search(line.decode()) for line in pipe.stderr.readlines()} if match} return ledger_options diff --git a/test/CheckTexinfo.py b/test/CheckTexinfo.py index 7b13c50e..8a32d2c4 100755 --- a/test/CheckTexinfo.py +++ b/test/CheckTexinfo.py @@ -28,10 +28,10 @@ class CheckTexinfo (CheckOptions): fun_doc = str() fun_example = False item_regex = re.compile(self.function_pattern) - itemx_regex = re.compile('^@defunx') - example_regex = re.compile('^@smallexample\s+@c\s+command:') - fix_regex = re.compile('FIX') - comment_regex = re.compile('^\s*@c') + itemx_regex = re.compile(r'^@defunx') + example_regex = re.compile(r'^@smallexample\s+@c\s+command:') + fix_regex = re.compile(r'FIX') + comment_regex = re.compile(r'^\s*@c') for line in open(filename): line = line.strip() if state == state_normal: @@ -62,9 +62,9 @@ class CheckTexinfo (CheckOptions): option = None opt_doc = str() item_regex = re.compile(self.option_pattern) - itemx_regex = re.compile('^@itemx') - fix_regex = re.compile('FIX') - comment_regex = re.compile('^\s*@c') + itemx_regex = re.compile(r'^@itemx') + fix_regex = re.compile(r'FIX') + comment_regex = re.compile(r'^\s*@c') for line in open(filename): line = line.strip() if state == state_normal: diff --git a/test/ConfirmTests.py b/test/ConfirmTests.py index 54187130..a856f2fc 100755 --- a/test/ConfirmTests.py +++ b/test/ConfirmTests.py @@ -32,8 +32,8 @@ commands = [ ] def clean(num): - num = re.sub("(\s+|\$|,)","", num) - m = re.search("([-0-9.]+)", num) + num = re.sub(r'(\s+|\$|,)',"", num) + m = re.search(r'([-0-9.]+)', num) if m: return float(m.group(1)) else: @@ -45,10 +45,10 @@ def confirm_report(command): failure = False running_total = 0.0 - p = harness.run(re.sub('\$cmd', 'reg', command)) + p = harness.run(re.sub(r'\$cmd', 'reg', command)) for line in harness.readlines(p.stdout): - match = re.match("\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)", line[54:]) + match = re.match(r'\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)', line[54:]) if not match: continue @@ -57,7 +57,7 @@ def confirm_report(command): running_total += value diff = abs(running_total - total) - if re.search(' -[VGB] ', command) and diff < 0.015: + if re.search(r' -[VGB] ', command) and diff < 0.015: diff = 0.0 if diff > 0.001: print("DISCREPANCY: %.3f (%.3f - %.3f) at line %d:" % \ @@ -71,14 +71,14 @@ def confirm_report(command): balance_total = 0.0 - p = harness.run(re.sub('\$cmd', 'bal', command)) + p = harness.run(re.sub(r'\$cmd', 'bal', command)) for line in harness.readlines(p.stdout): if line[0] != '-': balance_total = clean(line[:20]) diff = abs(balance_total - running_total) - if re.search(' -[VGB] ', command) and diff < 0.015: + if re.search(r' -[VGB] ', command) and diff < 0.015: diff = 0.0 if diff > 0.001: print() @@ -90,7 +90,7 @@ def confirm_report(command): return not failure for cmd in commands: - if confirm_report('$ledger --rounding $cmd ' + re.sub('\$tests', str(args.tests), cmd)): + if confirm_report('$ledger --rounding $cmd ' + re.sub(r'\$tests', str(args.tests), cmd)): harness.success() else: harness.failure() diff --git a/test/GenerateTests.py b/test/GenerateTests.py index 1301bcd0..87b65659 100755 --- a/test/GenerateTests.py +++ b/test/GenerateTests.py @@ -35,7 +35,7 @@ if not os.path.isdir(args.tests) and not os.path.isfile(args.tests): sys.exit(1) #def normalize(line): -# match = re.match("((\s*)([A-Za-z]+)?(\s*)([-0-9.]+)(\s*)([A-Za-z]+)?)( (.+))?$", line) +# match = re.match(r'((\s*)([A-Za-z]+)?(\s*)([-0-9.]+)(\s*)([A-Za-z]+)?)( (.+))?$', line) # if match: # if match.group(3): # prefix = match.group(3) + " " + match.group(5) diff --git a/test/RegressTests.py b/test/RegressTests.py index 1804d32e..526c8f7c 100755 --- a/test/RegressTests.py +++ b/test/RegressTests.py @@ -61,7 +61,7 @@ class RegressFile(object): while line: if line.startswith("test "): command = line[5:] - match = re.match('(.*) -> ([0-9]+)', command) + match = re.match(r'(.*) -> ([0-9]+)', command) if match: test.command = self.transform_line(match.group(1)) test.exitcode = int(match.group(2)) @@ -106,13 +106,13 @@ class RegressFile(object): return if test.command.find('-f ') != -1: test.command = '$ledger ' + test.command - if re.search('-f (-|/dev/stdin)(\s|$)', test.command): + if re.search(r'-f (-|/dev/stdin)(\s|$)', test.command): use_stdin = True else: test.command = f'$ledger -f "{str(self.filename.resolve())}" {test.command}' p = harness.run(test.command, - columns=(not re.search('--columns', test.command))) + columns=(not re.search(r'--columns', test.command))) if use_stdin: fd = open(self.filename, encoding='utf-8') diff --git a/test/convert.py b/test/convert.py index a54edaac..bdd7a15b 100755 --- a/test/convert.py +++ b/test/convert.py @@ -67,34 +67,34 @@ not_for_python = 0 class_name = None for line in fd.readlines(): - if re.match('^#ifndef NOT_FOR_PYTHON', line): + if re.match(r'^#ifndef NOT_FOR_PYTHON', line): not_for_python += 1 continue elif not_for_python > 0: - if re.match('^#endif // NOT_FOR_PYTHON', line): + if re.match(r'^#endif // NOT_FOR_PYTHON', line): not_for_python -= 1 continue - if re.match('^(using|CPP|[#{}/])', line): + if re.match(r'^(using|CPP|[#{}/])', line): continue - if re.match('^\s+[{}]\s+$', line): + if re.match(r'^\s+[{}]\s+$', line): continue - if not re.search('assert', line): - match = re.match('^};', line) + if not re.search(r'assert', line): + match = re.match(r'^};', line) if match: continue - match = re.match('BOOST_.*_TEST_SUITE', line) + match = re.match(r'BOOST_.*_TEST_SUITE', line) if match: continue - match = re.match('^struct (.*?) {', line) + match = re.match(r'^struct (.*?) {', line) if match: class_name = match.group(1) continue if class_name: - match = re.search('(~)?%s\(\) {' % class_name, line) + match = re.search(r'(~)?%s\(\) {' % class_name, line) if match: if match.group(1): fo.write(' def tearDown(self):\n') @@ -102,17 +102,17 @@ for line in fd.readlines(): fo.write(' def setUp(self):\n') continue - match = re.match('BOOST_AUTO_TEST_CASE\((.+?)\)', line) + match = re.match(r'BOOST_AUTO_TEST_CASE\((.+?)\)', line) if match: fo.write(' def %s(self):\n' % match.group(1)) continue - match = re.match('void [^:]+::(test[^(]+|setUp|tearDown)\(\)', line) + match = re.match(r'void [^:]+::(test[^(]+|setUp|tearDown)\(\)', line) if match: fo.write(' def %s(self):\n' % match.group(1)) continue - match = re.search(' ([a-z:_<>]+?)&?\s+([a-z0-9_]+)(\((.+?)\))?;', line) + match = re.search(r' ([a-z:_<>]+?)&?\s+([a-z0-9_]+)(\((.+?)\))?;', line) if match: if match.group(1) != "std::string": line = ' %s = %s(%s)\n' % (match.group(2), match.group(1), @@ -120,79 +120,79 @@ for line in fd.readlines(): else: line = '' - match = re.search(' ([a-z:_<>]+?)&?\s+([a-z0-9]+)\s*=\s*([^(]+);', line) + match = re.search(r' ([a-z:_<>]+?)&?\s+([a-z0-9]+)\s*=\s*([^(]+);', line) if match: line = ' %s = %s(%s)\n' % (match.group(2), match.group(1), match.group(3)) - match = re.search(' ([a-z:_<>]+?)\s+([a-z0-9]+)\s*=\s*(.+?)$', line) + match = re.search(r' ([a-z:_<>]+?)\s+([a-z0-9]+)\s*=\s*(.+?)$', line) if match: line = ' %s = %s\n' % (match.group(2), match.group(3)) - line = re.sub('BOOST_CHECK_NE', 'self.assertNotEqual', line) - line = re.sub('BOOST_CHECK_EQUAL', 'self.assertEqual', line) + line = re.sub(r'BOOST_CHECK_NE', 'self.assertNotEqual', line) + line = re.sub(r'BOOST_CHECK_EQUAL', 'self.assertEqual', line) line = re.sub('BOOST_CHECK_THROW\(([^,]+), ([^,)]+?)\)', 'self.assertRaises(\\2, lambda: \\1)', line) - line = re.sub('BOOST_CHECK', 'self.assertTrue', line) + line = re.sub(r'BOOST_CHECK', 'self.assertTrue', line) # jww (2010-06-20): Determine this list automatically by scanning # the class_ lines in src/py_*.cc - line = re.sub('amount_t::precision_t\(([^)]+?)\)', '\\1', line) - line = re.sub('amount_t::', 'Amount.', line) - line = re.sub('Amount\.PARSE_', 'AmountParse.', line) - line = re.sub('commodity_t\(([^)]+?)\)', '\\1', line) - line = re.sub('commodity_t::', 'Commodity.', line) - line = re.sub('balance_t::', 'Balance.', line) - line = re.sub('balance_pair_t::', 'BalancePair.', line) - line = re.sub('value_t::', 'Value.', line) - - line = re.sub('amount_t', 'Amount', line) - line = re.sub('commodity_t', 'Commodity', line) - line = re.sub('balance_t', 'Balance', line) - line = re.sub('balance_pair_t', 'BalancePair', line) - line = re.sub('value_t', 'Value', line) - - line = re.sub("PARSE_DEFAULT", "ParseFlags.Default", line) - line = re.sub("PARSE_PARTIAL", "ParseFlags.Partial", line) - line = re.sub("PARSE_SINGLE", "ParseFlags.Single", line) - line = re.sub("PARSE_NO_MIGRATE", "ParseFlags.NoMigrate", line) - line = re.sub("PARSE_NO_REDUCE", "ParseFlags.NoReduce", line) - line = re.sub("PARSE_NO_ASSIGN", "ParseFlags.NoAssign", line) - line = re.sub("PARSE_NO_DATES", "ParseFlags.NoDates", line) - line = re.sub("PARSE_OP_CONTEXT", "ParseFlags.OpContext", line) - line = re.sub("PARSE_SOFT_FAIL", "ParseFlags.SoftFail", line) - - line = re.sub('ledger::', '', line) - line = re.sub('std::istringstream', 'StringIO', line) - line = re.sub('std::ostringstream', 'StringIO', line) + line = re.sub(r'amount_t::precision_t\(([^)]+?)\)', '\\1', line) + line = re.sub(r'amount_t::', 'Amount.', line) + line = re.sub(r'Amount\.PARSE_', 'AmountParse.', line) + line = re.sub(r'commodity_t\(([^)]+?)\)', '\\1', line) + line = re.sub(r'commodity_t::', 'Commodity.', line) + line = re.sub(r'balance_t::', 'Balance.', line) + line = re.sub(r'balance_pair_t::', 'BalancePair.', line) + line = re.sub(r'value_t::', 'Value.', line) + + line = re.sub(r'amount_t', 'Amount', line) + line = re.sub(r'commodity_t', 'Commodity', line) + line = re.sub(r'balance_t', 'Balance', line) + line = re.sub(r'balance_pair_t', 'BalancePair', line) + line = re.sub(r'value_t', 'Value', line) + + line = re.sub(r'PARSE_DEFAULT', "ParseFlags.Default", line) + line = re.sub(r'PARSE_PARTIAL', "ParseFlags.Partial", line) + line = re.sub(r'PARSE_SINGLE', "ParseFlags.Single", line) + line = re.sub(r'PARSE_NO_MIGRATE', "ParseFlags.NoMigrate", line) + line = re.sub(r'PARSE_NO_REDUCE', "ParseFlags.NoReduce", line) + line = re.sub(r'PARSE_NO_ASSIGN', "ParseFlags.NoAssign", line) + line = re.sub(r'PARSE_NO_DATES', "ParseFlags.NoDates", line) + line = re.sub(r'PARSE_OP_CONTEXT', "ParseFlags.OpContext", line) + line = re.sub(r'PARSE_SOFT_FAIL', "ParseFlags.SoftFail", line) + + line = re.sub(r'ledger::', '', line) + line = re.sub(r'std::istringstream', 'StringIO', line) + line = re.sub(r'std::ostringstream', 'StringIO', line) line = re.sub('set_session_context\(&session\)', 'self.testSession = session()\n set_session_context(self.testSession)', line) line = re.sub('set_session_context\(\)', 'set_session_context()\n self.testSession = None', line) - line = re.sub('([a-z_]+?)_t\b', '\\1', line) - line = re.sub('("[^"]+")', 'u\\1', line) - line = re.sub('std::string\(([^)]+?)\)', '\\1', line) - line = re.sub('string\(([^)]+?)\)', '\\1', line) - line = re.sub('\.print\(([^)]+?)\)', '.print_(\\1)', line) - line = re.sub('true', 'True', line) - line = re.sub('false', 'False', line) - line = re.sub('CURRENT_TIME\(\)', 'datetime.now()', line) - line = re.sub('CURRENT_DATE\(\)', 'date.today()', line) - line = re.sub('commodity\(\)', 'commodity', line) - line = re.sub('precision\(\)', 'precision', line) - line = re.sub('([0-9]+)[FL]', '\\1', line) - line = re.sub('([0-9]+)UL', '\\1L', line) - line = re.sub(';', '', line) - line = re.sub('//', '#', line) - line = re.sub('->', '.', line) + line = re.sub(r'([a-z_]+?)_t\b', '\\1', line) + line = re.sub(r'('[^"]+")', 'u\\1', line) + line = re.sub(r'std::string\(([^)]+?)\)', '\\1', line) + line = re.sub(r'string\(([^)]+?)\)', '\\1', line) + line = re.sub(r'\.print\(([^)]+?)\)', '.print_(\\1)', line) + line = re.sub(r'true', 'True', line) + line = re.sub(r'false', 'False', line) + line = re.sub(r'CURRENT_TIME\(\)', 'datetime.now()', line) + line = re.sub(r'CURRENT_DATE\(\)', 'date.today()', line) + line = re.sub(r'commodity\(\)', 'commodity', line) + line = re.sub(r'precision\(\)', 'precision', line) + line = re.sub(r'([0-9]+)[FL]', '\\1', line) + line = re.sub(r'([0-9]+)UL', '\\1L', line) + line = re.sub(r';', '', line) + line = re.sub(r'//', '#', line) + line = re.sub(r'->', '.', line) line = re.sub('(\s+|\()(\S+?) \? (.+?) : (.+?)\)', '\\1\\3 if \\2 else \\4)', line) - line = re.sub('if \((.+?)\)( {)?$', 'if \\1:', line) - line = re.sub('(} )?else( {)?$', 'else:', line) + line = re.sub(r'if \((.+?)\)( {)?$', 'if \\1:', line) + line = re.sub(r'(} )?else( {)?$', 'else:', line) - line = re.sub('amount_error', 'exceptions.ArithmeticError', line) + line = re.sub(r'amount_error', 'exceptions.ArithmeticError', line) - match = re.match('^ ', line) + match = re.match(r'^ ', line) if match: fo.write(' ' + line) else: diff --git a/tools/genuuid b/tools/genuuid index 0ad5bd92..784da6ac 100755 --- a/tools/genuuid +++ b/tools/genuuid @@ -8,15 +8,15 @@ def scan_path(path): try: with open(path, 'r') as fd: for line in fd: - match = re.match('\*', line) + match = re.match(r'\*', line) if match: bug = uuid = None - match = re.search('\[\[bug:([0-9]+)\]\[#[0-9]+\]\]', line) + match = re.search(r'\[\[bug:([0-9]+)\]\[#[0-9]+\]\]', line) if match: bug = match.group(1) elif bug: - match = re.search(':ID:\s+(.+?)\s*$', line) + match = re.search(r':ID:\s+(.+?)\s*$', line) if match: uuid = match.group(1) print(f"UPDATE bugs SET cf_uuid='{uuid}' WHERE bug_id={bug};") |