mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
updated string printing to be consistent between python 2 & 3. Previously, python 3 would print the db key & values as byte code, while python 2 inherently ignores this when printing. Now the stdout is the same in both versions.
This commit is contained in:
parent
44ea56d65c
commit
48a2db509f
@ -45,11 +45,17 @@ if __name__ == "__main__":
|
||||
|
||||
elif which == '':
|
||||
sys.stderr.write("{} is an unrecognized database type\n".format(sys.argv[1]))
|
||||
sys.stderr.write("Try the file again by removing the extension\n")
|
||||
exit(1)
|
||||
|
||||
print('{} is a {} db'.format(filename, which))
|
||||
try:
|
||||
out = sys.stdout.buffer
|
||||
|
||||
except AttributeError:
|
||||
out = sys.stdout
|
||||
|
||||
out.write(filename.encode('UTF-8') + b' is a ' + which.encode('UTF-8') + b' db\n')
|
||||
|
||||
db = dbm.open(filename, 'r')
|
||||
|
||||
for key in db.keys():
|
||||
print("{}:{}".format(key, db[key]))
|
||||
out.write(key + b":" + db[key] + b"\n")
|
||||
|
Loading…
x
Reference in New Issue
Block a user