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 |
Benjamin Peterson | 73541af | 2010-04-03 15:38:38 +0000 | [diff] [blame] | 4 | import warnings |
Benjamin Peterson | 4dbda85 | 2010-04-03 15:45:59 +0000 | [diff] [blame] | 5 | warnings.warnpy3k("in 3.x, the dbhash module has been removed", stacklevel=2) |
Skip Montanaro | 438bb94 | 2001-01-25 13:47:00 +0000 | [diff] [blame] | 6 | try: |
| 7 | import bsddb |
| 8 | except ImportError: |
| 9 | # prevent a second import of this module from spuriously succeeding |
| 10 | del sys.modules[__name__] |
| 11 | raise |
Guido van Rossum | 6700142 | 1996-01-25 18:33:39 +0000 | [diff] [blame] | 12 | |
Skip Montanaro | e99d5ea | 2001-01-20 19:54:20 +0000 | [diff] [blame] | 13 | __all__ = ["error","open"] |
| 14 | |
Guido van Rossum | 287b399 | 1999-05-03 18:09:26 +0000 | [diff] [blame] | 15 | error = bsddb.error # Exported for anydbm |
Guido van Rossum | 6700142 | 1996-01-25 18:33:39 +0000 | [diff] [blame] | 16 | |
Martin v. Löwis | e24fef0 | 2001-06-05 05:33:19 +0000 | [diff] [blame] | 17 | def open(file, flag = 'r', mode=0666): |
Guido van Rossum | 6700142 | 1996-01-25 18:33:39 +0000 | [diff] [blame] | 18 | return bsddb.hashopen(file, flag, mode) |