[Yt-svn] yt-commit r1061 - in branches/yt-object-serialization: . yt/fido
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Mon Dec 29 20:39:38 PST 2008
Author: mturk
Date: Mon Dec 29 20:39:37 2008
New Revision: 1061
URL: http://yt.spacepope.org/changeset/1061
Log:
Updates to the parameter file db for some only_on_root calls,
auto-initialization of the shelf, etc.
I'm trying to figure out how to handle syncing; this will do for now, but it
kind of stinks.
Also, I think the HOP halos will have to be un-pickleable. This kind of bums
me out.
Added:
branches/yt-object-serialization/.bzrignore
Modified:
branches/yt-object-serialization/ (props changed)
branches/yt-object-serialization/yt/fido/ParameterFileStorage.py
Added: branches/yt-object-serialization/.bzrignore
==============================================================================
--- (empty file)
+++ branches/yt-object-serialization/.bzrignore Mon Dec 29 20:39:37 2008
@@ -0,0 +1,4 @@
+__config__.py
+build
+hdf5.cfg
+setuptools-0.6c9-py2.5.egg
Modified: branches/yt-object-serialization/yt/fido/ParameterFileStorage.py
==============================================================================
--- branches/yt-object-serialization/yt/fido/ParameterFileStorage.py (original)
+++ branches/yt-object-serialization/yt/fido/ParameterFileStorage.py Mon Dec 29 20:39:37 2008
@@ -23,29 +23,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-## This is going to be the means of interacting with an SQLite (no, I repeat,
-## ORM will be used here!) db in the ~/.yt/ directory where parameter files
-## will be stored. It will be queried for a hash, which then gets instantiated
-## and returned to the user.
-
-## Non-functional right now.
-
-## Our table layout:
-## ParameterFiles
-## Filename fn text
-## Last known path path text
-## Sim time time real
-## CurrentTimeID ctid real
-## Hash hash text
-
from yt.fido import *
from yt.funcs import *
import shelve
import os.path
-#sqlite3.register_adapter(yt.lagos.OutputTypes.EnzoStaticOutput, _adapt_pf)
-#sqlite3.register_converter("pfile", _convert_pf)
-
class ParameterFileStore(object):
_shared_state = {}
@@ -57,7 +39,7 @@
return self
def __init__(self, in_memory = False):
- pass
+ only_on_root(self.__init_shelf)
def _get_db_name(self):
return os.path.expanduser("~/.yt/parameter_files.db")
@@ -109,14 +91,23 @@
my_shelf = shelve.open(self._get_db_name(), flag='r')
return my_shelf[key]
- def __setitem__(self, key, val):
+ def __store_item(self, key, val):
my_shelf = shelve.open(self._get_db_name(), 'c')
my_shelf[key] = val
- def __delitem__(self, key):
+ def __delete_item(self, key):
my_shelf = shelve.open(self._get_db_name(), 'c')
del my_shelf[key]
+ def __init_shelf(self):
+ shelve.open(self._get_db_name(), 'c')
+
+ def __setitem__(self, key, val):
+ only_on_root(self.__store_item, key, val)
+
+ def __delitem__(self, key):
+ only_on_root(self.__delete_item, key)
+
def keys(self):
my_shelf = shelve.open(self._get_db_name(), flag='r')
return my_shelf.keys()
More information about the yt-svn
mailing list