Commit cf59e3dc authored by admuc's avatar admuc

typos, reasonable modifications presented by pylint3

parent 9981a40b
......@@ -3,12 +3,11 @@
a2x3 - A toolchain manager for AsciiDoc3 - converts AsciiDoc3 text files to other
file formats. See asciidoc3.org for more information.
Copyright: (c) 2009 Stuart Rackham <srackham@gmail.com> MIT
Copyright: (c) 2009 Stuart Rackham <srackham@gmail.com> MIT
Copyright: (c) 2018 Berthold Gehrke <berthold.gehrke@gmail.com> for Python3 version
License: GNU GPL v2 or higher
'''
import fnmatch
import html.parser
import mimetypes
......@@ -104,19 +103,23 @@ class AttrDict(dict):
except KeyError as k:
if '_default' in self:
return self['_default']
else:
raise AttributeError(k)
raise AttributeError(k)
def __setattr__(self, key, value):
self[key] = value
def __delattr__(self, key):
try:
del self[key]
except KeyError as k:
raise AttributeError(k)
def __repr__(self):
return '<AttrDict ' + dict.__repr__(self) + '>'
def __getstate__(self):
return dict(self)
def __setstate__(self, value):
for k, v in list(value.items()):
self[k] = v
......@@ -311,7 +314,7 @@ def find_files(path, pattern):
Return list of file names matching pattern in directory path.
'''
result = []
for (p, dirs, files) in os.walk(path):
for (p, __, files) in os.walk(path):
for f in files:
if fnmatch.fnmatch(f, pattern):
result.append(os.path.normpath(os.path.join(p, f)))
......@@ -367,7 +370,6 @@ def get_source_options(asciidoc3_file):
parse_options()
return result
#####################################################################
# Application class
#####################################################################
......@@ -431,7 +433,7 @@ class A2X3(AttrDict):
stdout = shell(self.asciidoc3 + ' --backend list')[0]
backends = [(i, os.path.split(i)[1]) for i in stdout.splitlines()]
backend_dir = [i[0] for i in backends if i[1] == self.backend]
if len(backend_dir) == 0:
if not backend_dir:
die('missing %s backend' % self.backend)
if len(backend_dir) > 1:
die('more than one %s backend' % self.backend)
......@@ -669,7 +671,7 @@ class A2X3(AttrDict):
elif self.backend == 'chunked':
to_chunked(self)
elif self.backend == 'epub':
to_epub(self)
to_epub(self)
elif self.backend == 'text':
to_text(self)
else:
......@@ -834,7 +836,7 @@ class A2X3(AttrDict):
write_file('mimetype', 'application/epub+zip')
zip.write('mimetype', compress_type=zipfile.ZIP_STORED)
# Compress all remaining files.
for (p, dirs, files) in os.walk('.'):
for (p, __, files) in os.walk('.'):
for f in files:
f = os.path.normpath(os.path.join(p, f))
if f != 'mimetype':
......@@ -879,7 +881,6 @@ class A2X3(AttrDict):
# Script main line.
#####################################################################
#if __name__ == '__main__':
def main():
global OPTIONS
description = '''A toolchain manager for AsciiDoc3
......@@ -1007,7 +1008,7 @@ def main():
a2x3.load_conf()
a2x3.execute()
except KeyboardInterrupt:
exit(1)
sys.exit(1)
if __name__ == '__main__':
main()
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment