def expandTopLevelKeys(self): if Key.LET_KEY in self._data: letObj = Let(self._data[Key.LET_KEY]) # create a Let object from let map letObj.expandMacrosInLet() # do self-expansion of macros for key in self._data: if key == Key.JOBS_KEY: # skip 'jobs'; they expand later continue elif key == Key.LET_KEY: # macro definitions have to remain re-evaluable continue else: dat = letObj.expandMacros(self._data[key]) self._data[key] = dat return
def expandTopLevelKeys(self): if Key.LET_KEY in self._data: letObj = Let( self._data[Key.LET_KEY]) # create a Let object from let map letObj.expandMacrosInLet() # do self-expansion of macros for key in self._data: if key == Key.JOBS_KEY: # skip 'jobs'; they expand later continue elif key == Key.LET_KEY: # macro definitions have to remain re-evaluable continue else: dat = letObj.expandMacros(self._data[key]) self._data[key] = dat return
def resolveRun(self, cfg=None): config = cfg or self._config subJobs = [] job = self if not job.hasFeature("run"): return [job] else: # prepare a Let object for potential macro expansion letObj = Let(self.get(Key.LET_KEY, {})) letObj.expandMacrosInLet() # do self-expansion of macros for subjob in job.getFeature("run"): # make best effort on macro expansion if isinstance(subjob, types.StringTypes): if Key.hasMacro(subjob): subjob = letObj.expandMacros(subjob) # get job object subjobObj = self._getJob(subjob, config) if not subjobObj: raise RuntimeError, "No such job: \"%s\"" % subjob # make new job map job::subjob as copy of job, but extend[subjob] newjobname = self.name + self._config.COMPOSED_NAME_SEP + \ subjobObj.name.replace(self._config.NS_SEP, self._config.COMPOSED_NAME_SEP) newjob = job.clone() newjob.name = newjobname newjob.removeFeature('run') # remove 'run' key # we assume the initial 'run' job has already been resolved, so # we reset it here and set the 'extend' to the subjob if newjob.hasFeature(Key.RESOLVED_KEY): newjob.removeFeature(Key.RESOLVED_KEY) else: raise RuntimeError, "Cannot resolve 'run' key before 'extend' key" newjob.setFeature('extend', [subjobObj]) # extend subjob # add to config self._config.addJob( newjobname, newjob) # TODO: why not config.addJob(...) ?! # add to job list subJobs.append(newjob) job.setFeature( 'run', subJobs) # overwrite with list of Jobs (instead of Strings) return subJobs
def resolveRun(self, cfg=None): config = cfg or self._config subJobs = [] job = self if not job.hasFeature("run"): return [job] else: # prepare a Let object for potential macro expansion letObj = Let(self.get(Key.LET_KEY, {})) letObj.expandMacrosInLet() # do self-expansion of macros for subjob in job.getFeature("run"): # make best effort on macro expansion if isinstance(subjob, types.StringTypes): if Key.hasMacro(subjob): subjob = letObj.expandMacros(subjob) # get job object subjobObj = self._getJob(subjob, config) if not subjobObj: raise RuntimeError, 'No such job: "%s"' % subjob # make new job map job::subjob as copy of job, but extend[subjob] newjobname = ( self.name + self._config.COMPOSED_NAME_SEP + subjobObj.name.replace(self._config.NS_SEP, self._config.COMPOSED_NAME_SEP) ) newjob = job.clone() newjob.name = newjobname newjob.removeFeature("run") # remove 'run' key # we assume the initial 'run' job has already been resolved, so # we reset it here and set the 'extend' to the subjob if newjob.hasFeature(Key.RESOLVED_KEY): newjob.removeFeature(Key.RESOLVED_KEY) else: raise RuntimeError, "Cannot resolve 'run' key before 'extend' key" newjob.setFeature("extend", [subjobObj]) # extend subjob # add to config self._config.addJob(newjobname, newjob) # TODO: why not config.addJob(...) ?! # add to job list subJobs.append(newjob) job.setFeature("run", subJobs) # overwrite with list of Jobs (instead of Strings) return subJobs
def resolveExtend(self, entryTrace=[], cfg=None): # resolve the 'extend' entry of a job config = cfg or self._config if self.hasFeature(Key.RESOLVED_KEY): return #self.includeGlobalLet() # make sure potential global let is included first self.includeGlobalDefaults( ) # make sure potential global let is included first if self.hasFeature("extend"): # prepare a Let object for potential macro expansion letObj = Let(self.get(Key.LET_KEY, {})) letObj.expandMacrosInLet() # do self-expansion of macros # loop through 'extend' entries extends = self.getFeature("extend") self._console.indent() for entry in extends: # make best effort on macro expansion if isinstance(entry, types.StringTypes): if Key.hasMacro(entry): entry = letObj.expandMacros(entry) entryJob = self._getJob(entry, config) if not entryJob: raise RuntimeError, "No such job: \"%s\" (trace: %s)" % ( entry, entryTrace + [self.name]) if entryJob.name in entryTrace: # cycle check raise RuntimeError, "Extend entry already seen: %s" % str( entryTrace + [self.name, entryJob.name]) self._console.debug('Including "%s" into "%s"' % (entryJob.name, self.name)) # make sure this entry job is fully resolved in its context entryJob.resolveExtend(entryTrace + [self.name], config) # now merge the fully expanded job into the current job self.mergeJob(entryJob) self._console.outdent() self.setFeature(Key.RESOLVED_KEY, True)
def expandTopLevelKeys(self): if Key.LET_KEY in self._data: letDict = self._data[Key.LET_KEY] else: letDict = self._data[Key.LET_KEY] = {} #letDict.update(os.environ) # include OS env - this is permanent! if "QOOXDOO_PATH" in os.environ: letDict["QOOXDOO_PATH"] = os.environ["QOOXDOO_PATH"] letObj = Let(letDict) # create a Let object from let map letObj.expandMacrosInLet() # do self-expansion of macros for key in self._data: if key == Key.JOBS_KEY: # skip 'jobs'; they expand later continue elif key == Key.LET_KEY: # macro definitions have to remain re-evaluable continue else: dat = letObj.expandMacros(self._data[key]) self._data[key] = dat return
def resolveExtend(self, entryTrace=[], cfg=None): # resolve the 'extend' entry of a job config = cfg or self._config if self.hasFeature(Key.RESOLVED_KEY): return #self.includeGlobalLet() # make sure potential global let is included first self.includeGlobalDefaults() # make sure potential global let is included first if self.hasFeature("extend"): # prepare a Let object for potential macro expansion letObj = Let(self.get(Key.LET_KEY, {})) letObj.expandMacrosInLet() # do self-expansion of macros # loop through 'extend' entries extends = self.getFeature("extend") self._console.indent() for entry in extends: # make best effort on macro expansion if isinstance(entry, types.StringTypes): if Key.hasMacro(entry): entry = letObj.expandMacros(entry) entryJob = self._getJob(entry, config) if not entryJob: raise RuntimeError, "No such job: \"%s\" (trace: %s)" % (entry, entryTrace+[self.name]) if entryJob.name in entryTrace: # cycle check raise RuntimeError, "Extend entry already seen: %s" % str(entryTrace+[self.name, entryJob.name]) self._console.debug('Including "%s" into "%s"' % (entryJob.name, self.name)) # make sure this entry job is fully resolved in its context entryJob.resolveExtend(entryTrace + [self.name], config) # now merge the fully expanded job into the current job self.mergeJob(entryJob) self._console.outdent() self.setFeature(Key.RESOLVED_KEY, True)