From ad0b4f6096a37611a536243f13ff671fd6969a09 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 18 Apr 2015 19:05:47 +0300 Subject: Run pep8 in check; fix problems found --- summain | 57 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'summain') 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() -- cgit v1.2.1