From 8d2493c09465f933bf72922b118078813cae8d37 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 11 Jun 2011 19:54:15 +0100 Subject: Add --checksum option to allow choosing checksums to compute. Only SHA1 is computed by default. --- summain | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'summain') diff --git a/summain b/summain index 2ff1b21..ac9d7c9 100755 --- a/summain +++ b/summain @@ -32,6 +32,8 @@ class Summain(cliapp.Application): self.settings.string_list(['exclude'], 'do not output or compute FIELD', metavar='FIELD') + self.settings.string_list(['checksum', 'c'], + 'which checksums to compute') def files(self, root): if os.path.isdir(root): @@ -50,9 +52,12 @@ class Summain(cliapp.Application): pn = summainlib.PathNormalizer() else: pn = summainlib.SamePath() + checksums = [x.upper() + for x in self.settings['checksum'] or ['SHA1']] for root in args: for filename in self.files(root): - o = summainlib.FilesystemObject(filename, nn, pn, exclude) + o = summainlib.FilesystemObject(filename, nn, pn, exclude, + checksums) self.output.write(o.format(root if relative else None)) self.output.write('\n') -- cgit v1.2.1 From f2174ad7e7fb02fa3ba1093109f7f0c875934ed4 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 11 Jun 2011 20:01:27 +0100 Subject: Check that all checksums are OK. --- summain | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'summain') diff --git a/summain b/summain index ac9d7c9..ff9e225 100755 --- a/summain +++ b/summain @@ -54,6 +54,12 @@ class Summain(cliapp.Application): pn = summainlib.SamePath() checksums = [x.upper() for x in self.settings['checksum'] or ['SHA1']] + o = summainlib.FilesystemObject('.', nn, pn, exclude, checksums) + for checksum in checksums: + try: + o[checksum] + except KeyError: + raise cliapp.AppException('Unknown checksum %s' % checksum) for root in args: for filename in self.files(root): o = summainlib.FilesystemObject(filename, nn, pn, exclude, -- cgit v1.2.1 From e2a190cf766cd9cacd9dbeb94c0361f3445c2845 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 11 Jun 2011 20:14:47 +0100 Subject: Tweak --checksum help text to list all checksum types. --- summain | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'summain') diff --git a/summain b/summain index ff9e225..92ad5f3 100755 --- a/summain +++ b/summain @@ -33,7 +33,10 @@ class Summain(cliapp.Application): 'do not output or compute FIELD', metavar='FIELD') self.settings.string_list(['checksum', 'c'], - 'which checksums to compute') + 'which checksums to compute: ' + 'MD5, SHA1, SHA224, SHA256, SHA384, SHA512; ' + 'use once per checksum type ' + '(default is SHA1)') def files(self, root): if os.path.isdir(root): -- cgit v1.2.1