diff options
author | Matthew Peveler <matt.peveler@gmail.com> | 2020-12-12 10:46:22 -0500 |
---|---|---|
committer | Matthew Peveler <matt.peveler@gmail.com> | 2020-12-12 10:46:22 -0500 |
commit | 006adc1d18d75157d3d5231558d8ed25c0f45a2f (patch) | |
tree | 4eb299781fe1af779848a430c1cee41071dadee5 | |
parent | 8313e45cc78af30bb8df5d33311a7f2fdc50595c (diff) | |
download | asciidoc-py3-006adc1d18d75157d3d5231558d8ed25c0f45a2f.tar.gz |
improve indentation
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
-rwxr-xr-x | asciidoc.py | 35 | ||||
-rwxr-xr-x | tests/testasciidoc.py | 43 |
2 files changed, 49 insertions, 29 deletions
diff --git a/asciidoc.py b/asciidoc.py index c33708c..c665398 100755 --- a/asciidoc.py +++ b/asciidoc.py @@ -903,8 +903,9 @@ def system(name, args, is_macro=False, attrs=None): value = document.attributes.get(attr) if value: if not re.match(r'^\d+$', value) and len(value) > 1: - message.warning('%s: illegal counter value: %s' - % (syntax, value)) + message.warning( + '%s: illegal counter value: %s' % (syntax, value) + ) return None if re.match(r'^\d+$', value): expr = value + '+1' @@ -1056,13 +1057,17 @@ def subs_attrs(lines, dictionary=None): pos = mo.start() + len(s) # Expand conditional attributes. # Single name -- higher precedence. - reo1 = re.compile(r'(?s)\{(?P<name>[^\\\W][-\w]*?)' - r'(?P<op>\=|\?|!|#|%|@|\$)' - r'(?P<value>.*?)\}(?!\\)') + reo1 = re.compile( + r'(?s)\{(?P<name>[^\\\W][-\w]*?)' + r'(?P<op>\=|\?|!|#|%|@|\$)' + r'(?P<value>.*?)\}(?!\\)' + ) # Multiple names (n1,n2,... or n1+n2+...) -- lower precedence. - reo2 = re.compile(r'(?s)\{(?P<name>[^\\\W][-\w' + OR + AND + r']*?)' - r'(?P<op>\=|\?|!|#|%|@|\$)' - r'(?P<value>.*?)\}(?!\\)') + reo2 = re.compile( + r'(?s)\{(?P<name>[^\\\W][-\w' + OR + AND + r']*?)' + r'(?P<op>\=|\?|!|#|%|@|\$)' + r'(?P<value>.*?)\}(?!\\)' + ) for reo in [reo1, reo2]: pos = 0 while True: @@ -1213,12 +1218,14 @@ def subs_attrs(lines, dictionary=None): return tuple(result) -east_asian_widths = {'W': 2, # Wide - 'F': 2, # Full-width (wide) - 'Na': 1, # Narrow - 'H': 1, # Half-width (narrow) - 'N': 1, # Neutral (not East Asian, treated as narrow) - 'A': 1} # Ambiguous (s/b wide in East Asian context, narrow otherwise, but that doesn't work) +east_asian_widths = { + 'W': 2, # Wide + 'F': 2, # Full-width (wide) + 'Na': 1, # Narrow + 'H': 1, # Half-width (narrow) + 'N': 1, # Neutral (not East Asian, treated as narrow) + 'A': 1, # Ambiguous (s/b wide in East Asian context, narrow otherwise, but that doesn't work) +} """Mapping of result codes from `unicodedata.east_asian_width()` to character column widths.""" diff --git a/tests/testasciidoc.py b/tests/testasciidoc.py index fef160b..a6c5c1c 100755 --- a/tests/testasciidoc.py +++ b/tests/testasciidoc.py @@ -90,9 +90,9 @@ class AsciiDocTest(object): the test name and output file type. """ return '%s-%s%s' % ( - os.path.normpath(os.path.join(self.datadir, self.name)), - backend, - BACKEND_EXT[backend] + os.path.normpath(os.path.join(self.datadir, self.name)), + backend, + BACKEND_EXT[backend] ) def parse(self, lines, confdir, datadir): @@ -122,7 +122,8 @@ class AsciiDocTest(object): if directive == 'source': if data: self.source = os.path.normpath(os.path.join( - self.confdir, os.path.normpath(data[0]))) + self.confdir, os.path.normpath(data[0]) + )) elif directive == 'options': self.options = eval(' '.join(data)) for i, v in enumerate(self.options): @@ -156,8 +157,9 @@ class AsciiDocTest(object): Returns True if the output test data file is missing or out of date. """ return self.is_missing(backend) or ( - os.path.getmtime(self.source) - > os.path.getmtime(self.backend_filename(backend))) + os.path.getmtime(self.source) + > os.path.getmtime(self.backend_filename(backend)) + ) def clean_artifacts(self): for artifact in self.artifacts: @@ -297,7 +299,7 @@ class AsciiDocTests(object): first = True while not lines.eol(): s = lines.read_until(r'^%+$') - s = [line for line in s if len(line) > 0] # Drop blank lines. + s = [line for line in s if len(line) > 0] # Drop blank lines. # Must be at least one non-blank line in addition to delimiter. if len(s) > 1: # Optional globals precede all tests. @@ -322,8 +324,11 @@ class AsciiDocTests(object): """ self.passed = self.failed = self.skipped = 0 for test in self.tests: - if (not test.disabled or number) and (not number or number == test.number) \ - and (not backend or backend in test.backends): + if ( + (not test.disabled or number) + and (not number or number == test.number) + and (not backend or backend in test.backends) + ): test.run(backend) self.passed += test.passed self.failed += test.failed @@ -388,8 +393,10 @@ if __name__ == '__main__': os.environ['SOURCE_DATE_EPOCH'] = '1038184662' # Process command line options. from argparse import ArgumentParser - parser = ArgumentParser(description='Run AsciiDoc conformance tests specified in ' - 'configuration FILE.') + parser = ArgumentParser( + description='Run AsciiDoc conformance tests specified in configuration' + 'FILE.' + ) msg = 'Use configuration file CONF_FILE (default configuration file is '\ 'testasciidoc.conf in testasciidoc.py directory)' parser.add_argument( @@ -411,10 +418,16 @@ if __name__ == '__main__': subparsers.add_parser('run', help='Execute tests', parents=[options]) - subparser = subparsers.add_parser('update', help='Regenerate and update test data', - parents=[options]) - subparser.add_argument('--force', action='store_true', - help='Update all test data overwriting existing data') + subparser = subparsers.add_parser( + 'update', + help='Regenerate and update test data', + parents=[options] + ) + subparser.add_argument( + '--force', + action='store_true', + help='Update all test data overwriting existing data' + ) args = parser.parse_args() |