def __getitem__(self, key): if self.recur.has_key(key): return "" self.recur[key] = True try: value = expandMacros(self.macros[key], self) finally: del self.recur[key] return value
def macroString(self, trait): from pyre.util import expandMacros class InventoryAdapter(object): def __init__(self, inventory): self.inventory = inventory def __getitem__(self, key): return expandMacros(str(self.inventory.getTraitValue(key)), self) descriptor = self.inventory.getTraitDescriptor(trait.name) return expandMacros(descriptor.value, InventoryAdapter(self.inventory))
def __setitem__(self, trait, value): locator = locators.file(self.fp.name, self.fp.lineno) path = trait.split('.') key = path[-1] path = path[:-1] node = _getNode(self.node, path) value = expandMacros(value, self.macros) node.setProperty(key, value, locator) dict.__setitem__(self, key, value)
def _expandNodeListArgs(self, args): from pyre.util import expandMacros machinefile = self.machinefile nodegen = self.nodegen file = open(machinefile, "w") for node in self.nodelist: file.write((nodegen + '\n') % node) file.close() substitutions = { 'launcher.machinefile': machinefile, } for i, arg in enumerate(args): args[i] = expandMacros(arg, substitutions) return
def _expandNodeListArgs(self, args): from pyre.util import expandMacros machinefile = self.machinefile nodegen = self.nodegen file = open(machinefile, "w") for node in self.nodelist: file.write((nodegen + '\n') % node) file.close() substitutions = { 'launcher.machinefile': machinefile, } for i,arg in enumerate(args): args[i] = expandMacros(arg, substitutions) return
def __getitem__(self, key): return expandMacros(str(self.inventory.getTraitValue(key)), self)
def expandMacros(self, value): return expandMacros(value, self.rp)