#: structureIndexREMask used to identify which files by filename #: are those with tables relating type names to structure types structureIndexREMask = r"structIndex\.(?P<modname>.*?)\.py$" if (True): # was firstrun logic... python interpreter makes sure this module only runs once already # this module operates like a singleton centralStructureIndex = {} # WALK the directory structure # add each directory to the sytem path (from which import can be done) # and exec the structureIndex.***.py files # These indexes are meant to append it to the centralDescriptorIndex for root, dirn, files in config_walk("structures"): sys.path.append(root) for sfilename in files: if (re.match(structureIndexREMask, sfilename)): fullpath = os.path.join(root, sfilename) siFile = open(fullpath) exec siFile siFile.close() # file must declare structureIndex = {...}, keys are types, # values are string names of structure classes that can # be instantiated when needed (should refer to modules # and classes in structures subdirectory, all of which is # in the import path. # note: make sure one index does not stomp another # Means misconfigured structureIndex.
# calculatorIndexREMask used to identify descriptorIndex files # these files need to set descriptorIndex to a dictionary value # relating AstroType names to descriptor calculator names, with the # latter being of proper form to "exec" in python. calculatorIndexREMask = r"calculatorIndex\.(?P<modname>.*?)\.py$" if (True): #note, the firstrun logic runs but is not needed, python only imports once # this module operates like a singleton centralCalculatorIndex = {} calculatorPackageMap = {} loadedCalculatorIndex = {} # WALK the config space as a directory structure for root, dirn, files in config_walk(DESCRIPTORSPACE): if root not in sys.path: sys.path.append(root) if True: for dfile in files: if (re.match(calculatorIndexREMask, dfile)): fullpath = os.path.join(root, dfile) diFile = open(fullpath) exec diFile diFile.close() # file must declare calculatorIndex = {} # note, it might be confusing to find out if # one index entry stomps another... so I'm going to # check that this dict doesn't have keys already # in the central dict