Mercurial > p > roundup > code
annotate roundup/anypy/dbm_.py @ 4740:fe9568a6cbd6
Untangle template selection logic from template loading functionality.
| author | anatoly techtonik <techtonik@gmail.com> |
|---|---|
| date | Tue, 15 Jan 2013 00:10:01 +0300 |
| parents | 0d9369d35483 |
| children | d5da643b3d25 |
| rev | line source |
|---|---|
| 4360 | 1 # In Python 3 the "anydbm" module was renamed to be "dbm" which is now a |
| 2 # package containing the various implementations. The "wichdb" module's | |
| 3 # whichdb() function was moved to the new "dbm" module. | |
| 4 | |
|
4383
0d9369d35483
fix up some pre-Python2.6 compatibility issues in the *dbm interface
Richard Jones <richard@users.sourceforge.net>
parents:
4360
diff
changeset
|
5 import sys |
|
0d9369d35483
fix up some pre-Python2.6 compatibility issues in the *dbm interface
Richard Jones <richard@users.sourceforge.net>
parents:
4360
diff
changeset
|
6 if sys.version_info[:2] < (2, 6): |
|
0d9369d35483
fix up some pre-Python2.6 compatibility issues in the *dbm interface
Richard Jones <richard@users.sourceforge.net>
parents:
4360
diff
changeset
|
7 def key_in(db, key): |
|
0d9369d35483
fix up some pre-Python2.6 compatibility issues in the *dbm interface
Richard Jones <richard@users.sourceforge.net>
parents:
4360
diff
changeset
|
8 return db.has_key(key) |
|
0d9369d35483
fix up some pre-Python2.6 compatibility issues in the *dbm interface
Richard Jones <richard@users.sourceforge.net>
parents:
4360
diff
changeset
|
9 else: |
|
0d9369d35483
fix up some pre-Python2.6 compatibility issues in the *dbm interface
Richard Jones <richard@users.sourceforge.net>
parents:
4360
diff
changeset
|
10 def key_in(db, key): |
|
0d9369d35483
fix up some pre-Python2.6 compatibility issues in the *dbm interface
Richard Jones <richard@users.sourceforge.net>
parents:
4360
diff
changeset
|
11 return key in db |
|
0d9369d35483
fix up some pre-Python2.6 compatibility issues in the *dbm interface
Richard Jones <richard@users.sourceforge.net>
parents:
4360
diff
changeset
|
12 |
| 4360 | 13 try: |
| 14 # old school first because <3 had a "dbm" module too... | |
| 15 import anydbm | |
| 16 from whichdb import whichdb | |
| 17 except ImportError: | |
| 18 # python 3+ | |
| 19 import dbm as anydbm | |
| 20 whichdb = anydbm.whichdb |
