summaryrefslogtreecommitdiff
path: root/summain
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-06-11 20:15:04 +0100
committerLars Wirzenius <liw@liw.fi>2011-06-11 20:15:04 +0100
commit7fd201a6fe71e40a273f5b638b0c592fcea2b0db (patch)
treee70a602097e27c7cd605ed0711d69f95654a8520 /summain
parentdbd009da9ed28c3f20d64eaa78031ed3e1126211 (diff)
parente2a190cf766cd9cacd9dbeb94c0361f3445c2845 (diff)
downloadsummain-7fd201a6fe71e40a273f5b638b0c592fcea2b0db.tar.gz
Support multiple checksum types.
Diffstat (limited to 'summain')
-rwxr-xr-xsummain16
1 files changed, 15 insertions, 1 deletions
diff --git a/summain b/summain
index 2ff1b21..92ad5f3 100755
--- a/summain
+++ b/summain
@@ -32,6 +32,11 @@ 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: '
+ 'MD5, SHA1, SHA224, SHA256, SHA384, SHA512; '
+ 'use once per checksum type '
+ '(default is SHA1)')
def files(self, root):
if os.path.isdir(root):
@@ -50,9 +55,18 @@ class Summain(cliapp.Application):
pn = summainlib.PathNormalizer()
else:
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)
+ o = summainlib.FilesystemObject(filename, nn, pn, exclude,
+ checksums)
self.output.write(o.format(root if relative else None))
self.output.write('\n')