Beispiel #1
0
	def _createVarSource(self, var_list, lookup_list): # create variable source
		psource_list = []
		for (doElevate, PSourceClass, args) in createLookupHelper(self._paramConfig, var_list, lookup_list):
			if doElevate: # switch needs elevation beyond local scope
				self._nestedSources.append((PSourceClass, args))
			else:
				psource_list.append(PSourceClass(*args))
		# Optimize away unnecessary cross operations
		return ParameterSource.createInstance('CrossParameterSource', *psource_list)
	def _createVarSource(self, var_list, lookup_list): # create variable source
		psource_list = []
		for (doElevate, PSourceClass, args) in createLookupHelper(self._paramConfig, var_list, lookup_list):
			if doElevate: # switch needs elevation beyond local scope
				self.elevatedSwitch.append((PSourceClass, args))
			else:
				psource_list.append(PSourceClass(*args))
		# Optimize away unnecessary cross operations
		if len(lfilter(lambda p: p.getMaxParameters() is not None, psource_list)) > 1:
			return [CrossParameterSource(*psource_list)]
		return psource_list # simply forward list of psources
Beispiel #3
0
	def _registerPSource(self, pconfig, varName):
		def replace_nonalnum(value):
			if str.isalnum(value):
				return value
			return ' '
		lookup_str = pconfig.get(varName, 'lookup', '')
		lookup_list = lfilter(identity, str.join('', imap(replace_nonalnum, lookup_str)).split())
		for (doElevate, PSourceClass, args) in createLookupHelper(pconfig, [varName], lookup_list):
			if doElevate: # switch needs elevation beyond local scope
				self._nestedSources.append((PSourceClass, args))
			else:
				ps = PSourceClass(*args)
				if ps.depends():
					self._lookupSources.append(ps)
				else:
					self._constSources.append(ps)