forked from turian/common-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashdb-append.py
More file actions
executable file
·31 lines (26 loc) · 928 Bytes
/
hashdb-append.py
File metadata and controls
executable file
·31 lines (26 loc) · 928 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
#!/usr/bin/python
#
# Read the Tokyo Cabinet hash database in addfile, and
# add (perhaps overwrite) the entries to outfile.
#
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("-o", "--outfile", dest="outfile", help="TokyoCabinet outfile")
parser.add_option("-a", "--addfile", dest="addfile", help="TokyoCabinet addfile")
(options, args) = parser.parse_args()
assert options.addfile is not None
assert options.outfile is not None
from common.hashdb import read
print >> sys.stderr, "Adding key,value pairs from %s to %s..." % (options.addfile, options.outfile)
outdb = common.hashdb.write_open(options.outfile)
sys.stderr.write(stats() + "\n")
# traverse records
for (key, value) in common.hashdb.read(options.addfile):
outdb.put(key,value)
sys.stderr.write(stats() + "\n")