summaryrefslogtreecommitdiff
path: root/importpkg.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2016-05-23 21:03:52 +0200
committerHelmut Grohne <helmut@subdivi.de>2016-05-23 21:03:52 +0200
commitad65a01073bce55948ce4b45381ee6941b5046b2 (patch)
treef85e8dadc83913823db1ec303265b4d4c8ef3631 /importpkg.py
parent2f12a6e2f42673cc2b9cceec33821ce589204fd1 (diff)
downloaddebian-dedup-ad65a01073bce55948ce4b45381ee6941b5046b2.tar.gz
remove curl dependency
Teach importpkg how to download urls using urlopen and thus remove the need for invoking curl.
Diffstat (limited to 'importpkg.py')
-rwxr-xr-ximportpkg.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/importpkg.py b/importpkg.py
index fedad73..badef15 100755
--- a/importpkg.py
+++ b/importpkg.py
@@ -9,6 +9,10 @@ import argparse
import hashlib
import sys
import zlib
+try:
+ from urllib.request import urlopen
+except ImportError:
+ from urllib import urlopen
import yaml
@@ -72,20 +76,22 @@ class ImportpkgExtractor(DebExtractor):
raise ProcessingFinished()
def main():
- 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
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-H", "--hash", action="store",
+ help="verify that stdin hash given sha256 hash")
+ parser.add_argument("input", nargs='?', default=stdin, type=urlopen,
+ help="read from this location instead of stdin")
+ args = parser.parse_args()
dumper = yaml.SafeDumper(sys.stdout)
dumper.open()
if args.hash:
stdin = HashedStream(stdin, hashlib.sha256())
try:
- ImportpkgExtractor(dumper.represent).process(stdin)
+ ImportpkgExtractor(dumper.represent).process(args.input)
except ProcessingFinished:
pass
else: