def __init__(self, abspath, log): info = {} setup_roots = findSetupRoots(abspath) if setup_roots in all_setups_cache: all_setups = all_setups_cache[setup_roots] else: all_setups_cache[setup_roots] = all_setups = \ dict(iterSetups(setup_roots)) modname = path.splitext(path.basename(abspath))[0] readSetup(info, modname, abspath, all_setups, log) self.abspath = abspath if not info: raise RuntimeError('Could not load setup ' + abspath) self.name = info.keys()[0] self.edited = False self.extended = copy(info[self.name]['extended']) self.description = copy(info[self.name]['description']) self.includes = copy(info[self.name]['includes']) self.sysconfig = copy(info[self.name]['sysconfig']) self.alias_config = copy(info[self.name]['alias_config']) self.excludes = copy(info[self.name]['excludes']) self.group = copy(info[self.name]['group']) self.modules = copy(info[self.name]['modules']) self.startupcode = copy(info[self.name]['startupcode']) self.devices = {} devs = info[self.name]['devices'] for deviceName in devs: self.devices[deviceName] = (Device(deviceName, devs[deviceName][0], copy(devs[deviceName][1])))
def readSetups(paths, logger): """Read all setups on the given paths.""" infodict = {} all_setups = dict(iterSetups(paths)) for (setupname, filename) in all_setups.items(): readSetup(infodict, setupname, filename, all_setups, logger) # check if all includes exist for name, info in iteritems(infodict): if info is None: continue # erroneous setup for include in info['includes']: if not infodict.get(include): logger.error('Setup "%s" includes setup "%s" which does not ' 'exist or has errors', name, include) infodict[name] = None return infodict
def __init__(self, filename, devs_seen, setup_info): self.filename = filename self.devs_seen = devs_seen self.setup_info = setup_info self.setupname = path.basename(filename)[:-3] self.log = logging.getLogger(filename) self.is_guiconfig = self.setupname.startswith('guiconfig') setup_roots = findSetupRoots(filename) if setup_roots in SetupChecker.all_setups_cache: all_setups = SetupChecker.all_setups_cache[setup_roots] else: SetupChecker.all_setups_cache[setup_roots] = all_setups = \ dict(iterSetups(setup_roots)) if self.is_guiconfig: self.ns = prepareGuiNamespace() else: self.ns = prepareNamespace(self.setupname, filename, all_setups) self.good = True # filled by check() self.code = None self.ast = None
def _readSetup(self): uniqueId = self._getUniqueSetupId(self._shortSetupPath) setups = {} setup_roots = findSetupRoots(self._absSetupPath) if setup_roots in all_setups_cache: all_setups = all_setups_cache[setup_roots] else: all_setups_cache[setup_roots] = all_setups = \ dict(iterSetups(setup_roots)) modname = path.splitext(path.basename(self._absSetupPath))[0] readSetup(setups, modname, self._absSetupPath, all_setups, self) if not setups: # logging will be done by readSetup return None info = listvalues(setups)[0] info['uniqueid'] = uniqueId info['setupname'] = self._setupName info['shortsetuppath'] = self._shortSetupPath return info