summaryrefslogtreecommitdiff
path: root/summain
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-04-18 19:05:47 +0300
committerLars Wirzenius <liw@liw.fi>2015-04-18 19:05:47 +0300
commitad0b4f6096a37611a536243f13ff671fd6969a09 (patch)
tree03f9521543d99c95d3a0f786d89fdfcc3469c81a /summain
parent692a0885b8f36233f88f1dfc5185b2bf9791cbf0 (diff)
downloadsummain-ad0b4f6096a37611a536243f13ff671fd6969a09.tar.gz
Run pep8 in check; fix problems found
Diffstat (limited to 'summain')
-rwxr-xr-xsummain57
1 files changed, 31 insertions, 26 deletions
diff --git a/summain b/summain
index fd0e077..aa8ae79 100755
--- a/summain
+++ b/summain
@@ -37,7 +37,7 @@ class OutputFormat(object):
def write(self):
for name, o in self.objects:
self.write_object(name, o)
-
+
def write_object(self, name, o):
raise NotImplemented()
@@ -74,7 +74,7 @@ class GeneratorList(list):
def __init__(self, gen):
self.gen = gen
-
+
def __len__(self):
return 1
@@ -92,7 +92,7 @@ class Json(OutputFormat):
def dictify(self, name, o):
keys = self.keys + self.checksums
- values = { 'Name': name }
+ values = {'Name': name}
for k in keys:
if o[k] != '':
values[k] = o[k]
@@ -103,23 +103,28 @@ class Json(OutputFormat):
class Summain(cliapp.Application):
def add_settings(self):
- self.settings.boolean(['relative-paths', 'r'],
- 'print paths relative to arguments')
- self.settings.boolean(['mangle-paths', 'm'],
- 'mangle (obfuscate) paths')
- self.settings.string(['secret'],
- 'use SECRET to make mangled paths unguessable')
- self.settings.string_list(['exclude'],
- 'do not output or compute FIELD',
- metavar='FIELD')
- self.settings.string_list(['checksum', 'c'],
- 'which checksums to compute: '
- 'MD5, SHA1, SHA224, SHA256, SHA384, SHA512; '
- 'use once per checksum type '
- '(default is SHA1)')
- self.settings.choice(['output-format', 'f'],
- ['rfc822', 'csv', 'json'],
- 'choose output format (rfc822, csv, json)')
+ self.settings.boolean(
+ ['relative-paths', 'r'],
+ 'print paths relative to arguments')
+ self.settings.boolean(
+ ['mangle-paths', 'm'],
+ 'mangle (obfuscate) paths')
+ self.settings.string(
+ ['secret'],
+ 'use SECRET to make mangled paths unguessable')
+ self.settings.string_list(
+ ['exclude'],
+ 'do not output or compute FIELD',
+ metavar='FIELD')
+ self.settings.string_list(
+ ['checksum', 'c'],
+ 'which checksums to compute: '
+ 'MD5, SHA1, SHA224, SHA256, SHA384, SHA512; '
+ 'use once per checksum type (default is SHA1)')
+ self.settings.choice(
+ ['output-format', 'f'],
+ ['rfc822', 'csv', 'json'],
+ 'choose output format (rfc822, csv, json)')
def files(self, root):
if os.path.isdir(root) and not os.path.islink(root):
@@ -136,7 +141,7 @@ class Summain(cliapp.Application):
yield root
def process_args(self, args):
- checksums = [x.upper()
+ checksums = [x.upper()
for x in self.settings['checksum'] or ['SHA1']]
fmt = self.new_formatter(checksums, self.find_roots(args))
fmt.write()
@@ -159,12 +164,12 @@ class Summain(cliapp.Application):
def relative_path(self, root, o):
'''Return a path that is relative to root, if possible.
-
+
If pathname does not start with root, then return it
unmodified.
-
+
'''
-
+
if root.endswith(os.sep):
root2 = root
else:
@@ -182,8 +187,8 @@ class Summain(cliapp.Application):
'csv': CSV,
'json': Json,
}
- return table[self.settings['output-format']](self.output, checksums,
- objects)
+ formatter = table[self.settings['output-format']]
+ return formatter(self.output, checksums, objects)
Summain(version=summainlib.__version__).run()