summaryrefslogtreecommitdiff
path: root/importpkg.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2016-05-21 17:54:04 +0200
committerHelmut Grohne <helmut@subdivi.de>2016-05-21 17:54:04 +0200
commit4789c77936a634dc717f61309503f99a44b610ed (patch)
tree40e621b92ae1682709ce1f814ceddcbcebb727bb /importpkg.py
parent4cdf80c2ba2535f9a4a66d1bde6f7ac1b380e3d2 (diff)
downloaddebian-dedup-4789c77936a634dc717f61309503f99a44b610ed.tar.gz
move from deprecated optparse to argparse
Diffstat (limited to 'importpkg.py')
-rwxr-xr-ximportpkg.py16
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()