[hdf-compass] 45/295: cleaning up Structure class, adding Attributes class.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/master
in repository hdf-compass.
commit 629bf9f8cd556bbe0901ec10013c2f8d10eca177
Author: Matt Comerford <matthew.comerford at colorado.edu>
Date: Thu Sep 4 07:51:48 2014 -0600
cleaning up Structure class, adding Attributes class.
---
opendap_model/__init__.py | 58 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 5 deletions(-)
diff --git a/opendap_model/__init__.py b/opendap_model/__init__.py
index d93cdc5..ae4eab1 100644
--- a/opendap_model/__init__.py
+++ b/opendap_model/__init__.py
@@ -126,13 +126,13 @@ class Dataset(compass_model.Container):
return self._dset
-class Grid(compass_model.Container):
+class Structure(compass_model.Container):
"""
Represents Structure/StructureType Object in OpENDAP/Pydap.
"""
- classkind = "Grid"
+ classkind = "Structure/Grid/Sequence"
def __len__(self):
return len(self._dset.data)
@@ -147,7 +147,10 @@ class Grid(compass_model.Container):
@staticmethod
def canhandle(store, key):
new_key, new_dset = check_key(key, store.dataset)
- return new_key in new_dset and isinstance(new_dset[new_key], dap.model.GridType)
+ try:
+ return new_key in new_dset and isinstance(new_dset[new_key], dap.model.StructureType)
+ except isinstance(new_dset[new_key], dap.model.DatasetType):
+ return False
def __init__(self, store, key):
new_key, new_dset = check_key(key, store.dataset)
@@ -171,7 +174,7 @@ class Grid(compass_model.Container):
@property
def description(self):
- return "A Pydap GridType Object."
+ return "A Pydap StructureType Object."
class Base(compass_model.Array):
@@ -230,9 +233,54 @@ class Base(compass_model.Array):
def description(self):
return "A Pydap BaseType Object."
+
+class Attributes(compass_model.KeyValue):
+ """
+ Represents the Attributes member of Pydap Objects.
+ """
+
+ classkind = "Attributes"
+
+ @property
+ def keys(self):
+ return self._keys.keys()
+
+ def __getitem__(self, name):
+ return self._keys[name]
+
+ @staticmethod
+ def canhandle(store, key):
+ new_key = check_key(key, store.dataset)
+ return new_key != ''
+
+ def __init__(self, store, key):
+ new_key, new_dset = check_key(key, store.dataset)
+
+ self._store = store
+ self._key = new_key
+ self._keys = new_dset[self._key].attributes
+
+ @property
+ def key(self):
+ return self._key
+
+ @property
+ def store(self):
+ return self._store
+
+ @property
+ def displayname(self):
+ return "%s Attributes" % self._key
+
+ @property
+ def description(self):
+ return "Attributes of %s" % self._key
+
+
# Register Handlers
+Server.push(Attributes)
Server.push(Dataset)
-Server.push(Grid)
+Server.push(Structure)
Server.push(Base)
compass_model.push(Server)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/hdf-compass.git
More information about the debian-science-commits
mailing list