Beispiel #1
0
def esignature(sign, domain):
  if (domain[0].__class__ == "".__class__): #if the first element is a string, domain is a list of locs
    locsignature = {}
    locsignature["name"] = "loc"
    locsignature["istatelist"] = []
    for loc in domain:
      locsignature["istatelist"].append("~" + loc)
    sign["signature"].append(locsignature)
  else: #otherwise the first element is a tuple, so the domain is a matrix of locs
    orgsignature = {}
    orgsignature["name"] = "org"
    orgsignature["istatelist"] = []
    dstsignature = {}
    dstsignature["name"] = "dst"
    dstsignature["istatelist"] = []
    for (org,dst,n) in domain:
      if ("~" + org not in orgsignature["istatelist"]):#This ensures that the input order is maintained
        orgsignature["istatelist"].append("~" + org)
      if ("~" + dst not in dstsignature["istatelist"]):
        dstsignature["istatelist"].append("~" + dst)
    sign["signature"].append(orgsignature)
    sign["signature"].append(dstsignature)
  printing.printSignature(sign)