Пример #1
0
def evar2(var, domain):
  def mixVarWithLoc(loc):
    newVar = copy.deepcopy(var)
    newVar["label"] = newVar["label"].replace("%loc",loc)
    newVar["algexp"] = substituteDataArrayElementInString("%loc", newVar["algexp"], locations[loc])
    newVar["algexp"] = newVar["algexp"].replace("%loc",loc)
    return newVar
  
  def mixVarWithOrgDst(matrixCell):
    (org, dst, r) = matrixCell
    if (options.fullMatrix == False and r == 0):
      return nullInstruction
    if (org != dst):
      newVar = copy.deepcopy(var)
      newVar["label"] = newVar["label"].replace("%org",org)
      newVar["label"] = newVar["label"].replace("%dst",dst)
      newVar["algexp"] = substituteDataArrayElementInString("%org", newVar["algexp"], locations[org])
      newVar["algexp"] = substituteDataArrayElementInString("%dst", newVar["algexp"], locations[dst])
      newVar["algexp"] = newVar["algexp"].replace("%cell", str(r))
      newVar["algexp"] = newVar["algexp"].replace("%org",org)
      newVar["algexp"] = newVar["algexp"].replace("%dst",dst)
      return newVar
    else:
      return nullInstruction

  varBuilder = None
  if (domain[0].__class__ == "".__class__): #if it is string, it is just loc
    varBuilder = mixVarWithLoc
  else: #the type is tuple, it is a matrix
    varBuilder = mixVarWithOrgDst
  for r in map(varBuilder, domain):
    printing.printVar2(r)