MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / main

Function main

tools/python-3.11.9-amd64/Tools/scripts/db2pickle.py:50–132  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

48 sys.stderr.write(__doc__ % globals())
49
50def main(args):
51 try:
52 opts, args = getopt.getopt(args, "hbrdag",
53 ["hash", "btree", "recno", "dbm",
54 "gdbm", "anydbm"])
55 except getopt.error:
56 usage()
57 return 1
58
59 if len(args) == 0 or len(args) > 2:
60 usage()
61 return 1
62 elif len(args) == 1:
63 dbfile = args[0]
64 pfile = sys.stdout
65 else:
66 dbfile = args[0]
67 try:
68 pfile = open(args[1], 'wb')
69 except IOError:
70 sys.stderr.write("Unable to open %s\n" % args[1])
71 return 1
72
73 dbopen = None
74 for opt, arg in opts:
75 if opt in ("-h", "--hash"):
76 try:
77 dbopen = bsddb.hashopen
78 except AttributeError:
79 sys.stderr.write("bsddb module unavailable.\n")
80 return 1
81 elif opt in ("-b", "--btree"):
82 try:
83 dbopen = bsddb.btopen
84 except AttributeError:
85 sys.stderr.write("bsddb module unavailable.\n")
86 return 1
87 elif opt in ("-r", "--recno"):
88 try:
89 dbopen = bsddb.rnopen
90 except AttributeError:
91 sys.stderr.write("bsddb module unavailable.\n")
92 return 1
93 elif opt in ("-a", "--anydbm"):
94 try:
95 dbopen = anydbm.open
96 except AttributeError:
97 sys.stderr.write("dbm module unavailable.\n")
98 return 1
99 elif opt in ("-g", "--gdbm"):
100 try:
101 dbopen = gdbm.open
102 except AttributeError:
103 sys.stderr.write("dbm.gnu module unavailable.\n")
104 return 1
105 elif opt in ("-d", "--dbm"):
106 try:
107 dbopen = dbm.open

Callers 1

db2pickle.pyFile · 0.70

Calls 7

usageFunction · 0.70
openFunction · 0.50
getoptMethod · 0.45
writeMethod · 0.45
keysMethod · 0.45
dumpMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected