Skip to content

Commit

Permalink
Changed cache system to DataBase
Browse files Browse the repository at this point in the history
added py2 compatibility
  • Loading branch information
abelcarreras committed May 12, 2021
1 parent caf3d57 commit a65e4c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
11 changes: 9 additions & 2 deletions pyqchem/cache.py
Expand Up @@ -24,11 +24,14 @@ def __new__(cls, *args, **kwargs):
cls.__instance__ = super(SimpleCache, cls, ).__new__(cls)
return cls.__instance__

def __init__(self):
def __init__(self, filename=None):
"""
Constructor
"""

if filename is not None:
self._calculation_data_filename = filename

# python 2 compatibility
if not '_calculation_data_filename' in dir(self):
self._calculation_data_filename = 'calculation_data.db'
Expand Down Expand Up @@ -112,13 +115,17 @@ def __new__(cls, *args, **kwargs):
cls.__instance__ = super(SqlCache, cls, ).__new__(cls)
return cls.__instance__

def __init__(self):
def __init__(self, filename=None):
"""
Constructor
"""

if filename is not None:
self._calculation_data_filename = filename

# python 2 compatibility
if not '_calculation_data_filename' in dir(self):
print('python 2')
self._calculation_data_filename = 'calculation_data.db'

self._conn = sqlite3.connect(self._calculation_data_filename)
Expand Down
3 changes: 1 addition & 2 deletions pyqchem/qchem_core.py
Expand Up @@ -11,8 +11,7 @@

# Backwards Compatibility
def redefine_calculation_data_filename(filename):
cache = CacheSystem()
cache.redefine_calculation_data_filename(filename)
cache = CacheSystem(filename=filename)


# Check if calculation finished ok
Expand Down
2 changes: 1 addition & 1 deletion tests/rasci_test.py
Expand Up @@ -13,7 +13,7 @@
if 'USER' in os.environ and os.environ['USER'] == 'travis':
recalculate = False
else:
recalculate = True
recalculate = False


class HydrogenTest(unittest.TestCase):
Expand Down
Binary file modified tests/test_data.db
Binary file not shown.

0 comments on commit a65e4c3

Please sign in to comment.