diff options
Diffstat (limited to 'importpkg.py')
-rwxr-xr-x | importpkg.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/importpkg.py b/importpkg.py index 933ec80..fedad73 100755 --- a/importpkg.py +++ b/importpkg.py @@ -5,8 +5,8 @@ on multiple machines. The generated yaml contains multiple documents. The first document contains package metadata. Then a document is emitted for each file. And finally a document consisting of the string "commit" is emitted.""" +import argparse import hashlib -import optparse import sys import zlib @@ -72,17 +72,17 @@ class ImportpkgExtractor(DebExtractor): raise ProcessingFinished() def main(): - parser = optparse.OptionParser() - parser.add_option("-H", "--hash", action="store", - help="verify that stdin hash given sha256 hash") - options, args = parser.parse_args() + parser = argparse.ArgumentParser() + parser.add_argument("-H", "--hash", action="store", + help="verify that stdin hash given sha256 hash") + args = parser.parse_args() try: stdin = sys.stdin.buffer except AttributeError: # python2 stdin = sys.stdin dumper = yaml.SafeDumper(sys.stdout) dumper.open() - if options.hash: + if args.hash: stdin = HashedStream(stdin, hashlib.sha256()) try: ImportpkgExtractor(dumper.represent).process(stdin) @@ -90,8 +90,8 @@ def main(): pass else: raise RuntimeError("unexpected termination of extractor") - if options.hash: - stdin.validate(options.hash) + if args.hash: + stdin.validate(args.hash) dumper.represent("commit") dumper.close() |