[cig-commits] r6160 - in cs/pythia/trunk: journal/components
pyre/inventory pyre/parsing/locators
leif at geodynamics.org
leif at geodynamics.org
Fri Mar 2 01:35:25 PST 2007
Author: leif
Date: 2007-03-02 01:35:24 -0800 (Fri, 02 Mar 2007)
New Revision: 6160
Modified:
cs/pythia/trunk/journal/components/ChannelFacility.py
cs/pythia/trunk/pyre/inventory/Facility.py
cs/pythia/trunk/pyre/inventory/Inventory.py
cs/pythia/trunk/pyre/parsing/locators/__init__.py
Log:
Allow the "name -> component" mapping to be specified by egg metadata
in setup.py, instead of in little, 2 or 3 line ".odb" files littering
the filesystem. I had been planning this for some time, but issue91
motivated me to actually implement it. (See issue91 for details and
an example.)
Modified: cs/pythia/trunk/journal/components/ChannelFacility.py
===================================================================
--- cs/pythia/trunk/journal/components/ChannelFacility.py 2007-03-02 06:47:56 UTC (rev 6159)
+++ cs/pythia/trunk/journal/components/ChannelFacility.py 2007-03-02 09:35:24 UTC (rev 6160)
@@ -29,7 +29,7 @@
channel = Channel(componentName)
import pyre.parsing.locators
- locator = pyre.parsing.locators.simple('built-in')
+ locator = pyre.parsing.locators.builtIn()
return channel, locator
Modified: cs/pythia/trunk/pyre/inventory/Facility.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/Facility.py 2007-03-02 06:47:56 UTC (rev 6159)
+++ cs/pythia/trunk/pyre/inventory/Facility.py 2007-03-02 09:35:24 UTC (rev 6160)
@@ -103,13 +103,16 @@
locator = component.getLocator()
else:
import pyre.parsing.locators
- component = self._import(instance, componentName)
-
- if component:
- locator = pyre.parsing.locators.simple('imported')
+ component = self._retrieveBuiltInComponent(instance, componentName)
+ if component is not None:
+ locator = pyre.parsing.locators.builtIn()
else:
- locator = pyre.parsing.locators.simple('not found')
- return None, locator
+ component = self._import(instance, componentName)
+ if component:
+ locator = pyre.parsing.locators.simple('imported')
+ else:
+ locator = pyre.parsing.locators.simple('not found')
+ return None, locator
# adjust the names by which this component is known
component.aliases.append(self.name)
@@ -141,6 +144,13 @@
return "could not bind facility '%(facility)s': factory '%(module)s:%(factory)s' is not callable" % self.__dict__
+ def _retrieveBuiltInComponent(self, instance, name):
+ return instance.retrieveBuiltInComponent(
+ name=name,
+ factory=self.family,
+ vault=self.vault)
+
+
def _import(self, instance, name):
# Initialize my value (preventing further lookups), in case we
Modified: cs/pythia/trunk/pyre/inventory/Inventory.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/Inventory.py 2007-03-02 06:47:56 UTC (rev 6159)
+++ cs/pythia/trunk/pyre/inventory/Inventory.py 2007-03-02 09:35:24 UTC (rev 6160)
@@ -204,6 +204,16 @@
vault=vault, extraDepositories=self._priv_depositories)
+ def retrieveBuiltInComponent(self, name, factory, args=(), vault=[]):
+ import merlin
+ group = "pyre.odb." + (".".join([self._priv_name] + vault))
+ for ep in merlin.iter_entry_points(group, name):
+ factory = ep.load()
+ component = factory(*args)
+ return component
+ return None
+
+
def retrieveObject(
self, name, symbol, encodings, vault=[], extraDepositories=[]):
"""retrieve object <name> from the persistent store"""
Modified: cs/pythia/trunk/pyre/parsing/locators/__init__.py
===================================================================
--- cs/pythia/trunk/pyre/parsing/locators/__init__.py 2007-03-02 06:47:56 UTC (rev 6159)
+++ cs/pythia/trunk/pyre/parsing/locators/__init__.py 2007-03-02 09:35:24 UTC (rev 6160)
@@ -29,6 +29,10 @@
return simple('command line')
+def builtIn():
+ return simple('built-in')
+
+
def script(source, line, function):
from ScriptLocator import ScriptLocator
return ScriptLocator(source, line, function)
More information about the cig-commits
mailing list