[cig-commits] r20523 - cs/pythia/trunk/pyre/inventory
brad at geodynamics.org
brad at geodynamics.org
Sat Jul 14 17:50:50 PDT 2012
Author: brad
Date: 2012-07-14 17:50:49 -0700 (Sat, 14 Jul 2012)
New Revision: 20523
Modified:
cs/pythia/trunk/pyre/inventory/FacilityArrayFacility.py
cs/pythia/trunk/pyre/inventory/Inventory.py
Log:
Extend Inventory to allow ordering of facilities (used in FacilityArray).
Modified: cs/pythia/trunk/pyre/inventory/FacilityArrayFacility.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/FacilityArrayFacility.py 2012-07-13 08:58:41 UTC (rev 20522)
+++ cs/pythia/trunk/pyre/inventory/FacilityArrayFacility.py 2012-07-15 00:50:49 UTC (rev 20523)
@@ -25,13 +25,15 @@
def _retrieveComponent(self, instance, componentName):
facilityNames = self._cast(componentName)
-
+
+ facilityOrder = []
dict = {}
for index, facilityName in enumerate(facilityNames):
# Strip leading and trailing whitespace from facility name
facility = self.itemFactory(facilityName.strip())
- attr = "item%d" % index
+ attr = "item%05d" % index
dict[attr] = facility
+ facilityOrder.append(facilityName.strip())
from Inventory import Inventory
from pyre.components.Component import Component
@@ -41,6 +43,7 @@
dict = {'Inventory': Inventory}
FacilityArray = Component.__metaclass__("FacilityArray", (Component,), dict)
fa = FacilityArray(self.name)
+ fa.Inventory._facilityOrder = facilityOrder
import pyre.parsing.locators
locator = pyre.parsing.locators.builtIn()
Modified: cs/pythia/trunk/pyre/inventory/Inventory.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/Inventory.py 2012-07-13 08:58:41 UTC (rev 20522)
+++ cs/pythia/trunk/pyre/inventory/Inventory.py 2012-07-15 00:50:49 UTC (rev 20523)
@@ -401,7 +401,13 @@
candidates = []
- for name, facility in self._facilityRegistry.iteritems():
+ if self._facilityOrder is None:
+ keys = self._facilityRegistry.iterkeys()
+ else:
+ keys = self._facilityOrder
+ #for name, facility in self._facilityRegistry.iteritems():
+ for name in keys:
+ facility = self._facilityRegistry[name]
try:
component = facility.__get__(self)
if component and component is not Error:
@@ -492,6 +498,7 @@
# trait registries
_traitRegistry = {}
_facilityRegistry = {}
+ _facilityOrder = None
_myTraitRegistry = {}
More information about the CIG-COMMITS
mailing list