summaryrefslogtreecommitdiffstats
path: root/pym/portage/env
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-09-07 10:17:26 +0000
committerAlec Warner <antarus@gentoo.org>2007-09-07 10:17:26 +0000
commit97929938006be5405be632ee1181b2e1a30f9620 (patch)
treee5f4c8e29e25df2051bbc683d863b7eab7f47b9d /pym/portage/env
parentf77868a5f27b87d053e000667992ecb4cb78d335 (diff)
downloadportage-97929938006be5405be632ee1181b2e1a30f9620.tar.gz
portage-97929938006be5405be632ee1181b2e1a30f9620.tar.bz2
portage-97929938006be5405be632ee1181b2e1a30f9620.zip
Fix minor issues with loaders in the static file loader, fix quoting and import style in news.py. Add TextFileLoader and EnvLoader loaders
svn path=/main/trunk/; revision=7753
Diffstat (limited to 'pym/portage/env')
-rw-r--r--pym/portage/env/loaders.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/pym/portage/env/loaders.py b/pym/portage/env/loaders.py
index ae9579a86..e7f5289a7 100644
--- a/pym/portage/env/loaders.py
+++ b/pym/portage/env/loaders.py
@@ -67,6 +67,40 @@ class DataLoader(object):
"""
raise NotImplementedError("Please override in a subclass")
+class EnvLoader(DataLoader):
+ """ Class to access data in the environment """
+ def __init__(self, validator):
+ DataLoader.__init__(self, validator)
+
+ def load(self):
+ return os.environ
+
+class TestTextLoader(DataLoader):
+ """ You give it some data, it 'loads' it for you, no filesystem access
+ """
+ def __init__(self, validator):
+ DataLoader.__init__(self, validator)
+ self.data = {}
+ self.errors = {}
+
+ def setData(self, text):
+ """Explicitly set the data field
+ Args:
+ text - a dict of data typical of Loaders
+ Returns:
+ None
+ """
+ if isinstance(text, dict):
+ self.data = text
+ else:
+ raise ValueError("setData requires a dict argument")
+
+ def setErrors(self, errors):
+ self.errors = errors
+
+ def load(self):
+ return (self.data, self.errors)
+
class FileLoader(DataLoader):
""" Class to access data in files """
@@ -234,4 +268,3 @@ class KeyValuePairFileLoader(FileLoader):
data[key].append(value)
else:
data[key] = value
-