Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bsddb3 instead of dbhash #44

Open
Arfrever opened this issue Jul 5, 2017 · 1 comment
Open

Use bsddb3 instead of dbhash #44

Arfrever opened this issue Jul 5, 2017 · 1 comment

Comments

@Arfrever
Copy link

Arfrever commented Jul 5, 2017

dbhash module is deprecated:
https://docs.python.org/2.7/library/dbhash.html

This functionality still exists in bsddb3 (outside of standard library).
bsddb3 also supports Python 3.

--- planet/idindex.py
+++ planet/idindex.py
@@ -13,8 +13,8 @@
         cache = config.cache_directory()
         index=os.path.join(cache,'index')
         if not os.path.exists(index): return None
-        import dbhash
-        return dbhash.open(filename(index, 'id'),'w')
+        import bsddb3
+        return bsddb3.hashopen(filename(index, 'id'),'w')
     except Exception, e:
         if e.__class__.__name__ == 'DBError': e = e.args[-1]
         from planet import logger as log
@@ -35,8 +35,8 @@
     cache = config.cache_directory()
     index=os.path.join(cache,'index')
     if not os.path.exists(index): os.makedirs(index)
-    import dbhash
-    index = dbhash.open(filename(index, 'id'),'c')
+    import bsddb3
+    index = bsddb3.hashopen(filename(index, 'id'),'c')
 
     try:
         import libxml2
--- tests/test_idindex.py
+++ tests/test_idindex.py
@@ -67,8 +67,8 @@
         self.assertEqual(12,len(doc.getElementsByTagName('planet:name')))
 
 try:
-    module = 'dbhash'
+    import bsddb3
 except ImportError:
-    planet.logger.warn("dbhash is not available => can't test id index")
+    planet.logger.warn("bsddb3 is not available => can't test id index")
     for method in dir(idIndexTest):
         if method.startswith('test_'):  delattr(idIndexTest,method)
@kgaughan
Copy link

A better idea might be to use anydbm instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants