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

Function main

tools/python-3.11.9-amd64/Tools/scripts/pickle2db.py:55–144  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

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

Callers 1

pickle2db.pyFile · 0.70

Calls 8

listFunction · 0.85
usageFunction · 0.70
openFunction · 0.50
getoptMethod · 0.45
writeMethod · 0.45
keysMethod · 0.45
loadMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected