diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-06-11 20:15:04 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-06-11 20:15:04 +0100 |
commit | 7fd201a6fe71e40a273f5b638b0c592fcea2b0db (patch) | |
tree | e70a602097e27c7cd605ed0711d69f95654a8520 /summain | |
parent | dbd009da9ed28c3f20d64eaa78031ed3e1126211 (diff) | |
parent | e2a190cf766cd9cacd9dbeb94c0361f3445c2845 (diff) | |
download | summain-7fd201a6fe71e40a273f5b638b0c592fcea2b0db.tar.gz |
Support multiple checksum types.
Diffstat (limited to 'summain')
-rwxr-xr-x | summain | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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') |