コード例 #1
0
  def __searchAndSubstitute(self,L):
    for i in range(0,len(L)):
      if type(L[i])==type(list()):
	self.__searchAndSubstitute(L[i])
      else:
#	print "searchAndSubstitute(): L[i]:",L[i]
	if re.search('\$',L[i])!=None: #there is a variable
	  items=re.split('(\$\S+)',L[i])
	  if(len(items)==1): #same as L[i]
	    print "ERROR: entry \"", L[i], "\" not correctly specified"
	    continue
	  newLi=[]
#	  print "searchAndSubstitute(), split:",items
	  for it in items:
	    if it!='':
	      if re.search('\$',it)!=None: #is a var
		k=it.split('$')[1]
		if k in self.Dict.keys():
		  newLi+=[self.Dict[k]]
		else: #not found, pheraps become from a command
		  print "WARN: key", it, " not found, may be is a command variable!"
		  newLi+=[[it]]
	      else: #not a var
		newLi+=[[it]]
	  if(newLi!=[] and len(L)!=1):
	    newLi=listUtils.reduceListConcat(newLi)
	    del L[i]
	    for b in newLi:
	      L.append(b) #substitute
	  else:
	    L[i]=newLi #substitute
#	  print "searchAndSubstitute(), L[i] finally: ",L[i]
    return L
コード例 #2
0
ファイル: parsing.py プロジェクト: fmes/complex-sim
def configReduce(confDict):
  for k in confDict.keys():
    confDict[k]=listUtils.reduceListConcat(confDict[k])
コード例 #3
0
 def minimize(self):
   for k in self.Dict.keys():
     self.Dict[k]=listUtils.reduceListConcat(self.Dict[k])