1 """Guess which db package to use to open a db file."""
6 """Guess which db package to use to open a db file.
10 - None if the database file can't be read;
11 - empty string if the file can be read but can't be recognized
12 - the module name (e.g. "dbm" or "gdbm") if recognized.
14 Importing the given module may still fail, and opening the
15 database using that module may still fail.
22 f =
open(filename + os.extsep +
"pag",
"rb")
24 f =
open(filename + os.extsep +
"dir",
"rb")
32 f =
open(filename + os.extsep +
"dat",
"rb")
34 f =
open(filename + os.extsep +
"dir",
"rb")
36 if f.read(1)
in [
"'",
'"']:
45 f =
open(filename,
"rb")
60 (magic,) = struct.unpack(
"=l", s)
65 if magic == 0x13579ace:
69 if magic
in (0x00061561, 0x61150600):
74 (magic,) = struct.unpack(
"=l", s16[-4:])
79 if magic
in (0x00061561, 0x61150600):