-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathhashdb-dump.py
More file actions
executable file
·36 lines (31 loc) · 889 Bytes
/
hashdb-dump.py
File metadata and controls
executable file
·36 lines (31 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python
#
# Read the Tokyo Cabinet hash database in infile.
# For each item, print the key and value (pretty-print as YAML).
# Each value is assumed to be JSON.
#
import sys
import common.myyaml
import common.file
import common.json
from common.stats import stats
import os.path
#from optparse import OptionParser
#parser = OptionParser()
#parser.add_option("-i", "--infile", dest="infile", help="TokyoCabinet infile")
#(options, args) = parser.parse_args()
#assert options.infile is not None
assert len(sys.argv) == 2
infile = sys.argv[1]
from common.hashdb import read
sys.stderr.write(stats() + "\n")
# traverse records
for (key, value) in common.hashdb.read(infile):
sys.stderr.write(stats() + "\n")
print key
print common.myyaml.dump(value)
# if key in value:
# print value
# else:
# print key, value
sys.stderr.write(stats() + "\n")