Skip Montanaro | 581c367 | 2003-05-05 14:16:41 +0000 | [diff] [blame] | 1 | """Provide a (g)dbm-compatible interface to bsddb.hashopen.""" |
Guido van Rossum | 6700142 | 1996-01-25 18:33:39 +0000 | [diff] [blame] | 2 | |
Skip Montanaro | 438bb94 | 2001-01-25 13:47:00 +0000 | [diff] [blame] | 3 | import sys |
| 4 | try: |
| 5 | import bsddb |
| 6 | except ImportError: |
| 7 | # prevent a second import of this module from spuriously succeeding |
| 8 | del sys.modules[__name__] |
| 9 | raise |
Guido van Rossum | 6700142 | 1996-01-25 18:33:39 +0000 | [diff] [blame] | 10 | |
Skip Montanaro | e99d5ea | 2001-01-20 19:54:20 +0000 | [diff] [blame] | 11 | __all__ = ["error","open"] |
| 12 | |
Guido van Rossum | 287b399 | 1999-05-03 18:09:26 +0000 | [diff] [blame] | 13 | error = bsddb.error # Exported for anydbm |
Guido van Rossum | 6700142 | 1996-01-25 18:33:39 +0000 | [diff] [blame] | 14 | |
Guido van Rossum | cd16bf6 | 2007-06-13 18:07:49 +0000 | [diff] [blame] | 15 | def open(file, flag = 'r', mode=0o666): |
Guido van Rossum | 6700142 | 1996-01-25 18:33:39 +0000 | [diff] [blame] | 16 | return bsddb.hashopen(file, flag, mode) |