[hdf-compass] 05/295: finished the primary implementation of the Directory (Container class)
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:19 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 dad53406432cde3cedd67e0af3ac431db0fcc433
Author: Matt Comerford <matthew.comerford at colorado.edu>
Date: Wed Jun 18 14:43:43 2014 -0600
finished the primary implementation of the Directory (Container class)
---
asc_model/__init__.py | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/asc_model/__init__.py b/asc_model/__init__.py
index fda3ab6..5dc7d20 100644
--- a/asc_model/__init__.py
+++ b/asc_model/__init__.py
@@ -43,6 +43,7 @@ Give it a shot and let me know if you run into problems.
'''
class Filesystem(compass_model.Store):
+
"""
A "data store" represented by the file system.
@@ -86,4 +87,44 @@ class Filesystem(compass_model.Store):
def getparent(self, key):
if key == '/':
return None
- return self[op.dirname(key)]
\ No newline at end of file
+ return self[op.dirname(key)]
+
+class Directory(compass_model.Container):
+
+ """
+ Represents a directory in the file system.
+ """
+
+ classkind = "Directory"
+
+ @staticmethod
+ def canhandle(store, key):
+ return op.isdir(key)
+
+ def __init__(self, store, key):
+ self._store = store
+ self._key = key
+ try:
+ self._names = os.listdir(key)
+ except OSError:
+ self._names = []
+
+ @property
+ def key(self):
+ return self._key
+
+ @property
+ def store(self):
+ return self._store
+
+ @property
+ def description(self):
+ return 'folder "%s" (%d members)' % (self.displayname, len(self))
+
+ def __len__(self):
+ return len(self._names)
+
+ def __iter__(self):
+ for name in self._names:
+ key = op.join(self.key, name)
+ yield self._store[key]
\ No newline at end of file
--
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