def getCanonicalID(iname, xrd_tree):
 xrd_list = xrd_tree.findall(xrd_tag)
 xrd_list.reverse()
 try:
  canonicalID = xri.XRI(xrd_list[0].findall(canonicalID_tag)[0].text)
 except IndexError:
  return None
 childID = canonicalID.lower()
 for xrd in xrd_list[1:]:
  parent_sought = childID[:childID.rindex('!')]
  parent = xri.XRI(xrd.findtext(canonicalID_tag))
  if (parent_sought != parent.lower()):
   raise XRDSFraud(('%r can not come from %s' % (childID, parent)))
  childID = parent_sought
 root = xri.rootAuthority(iname)
 if (not xri.providerIsAuthoritative(root, childID)):
  raise XRDSFraud(('%r can not come from root %r' % (childID, root)))
 return canonicalID

def getCanonicalID ( iname , xrd_tree ) : xrd_list = xrd_tree . findall ( xrd_tag ) xrd_list . reverse ( ) try : canonicalID = xri . XRI ( xrd_list [ 0 ] . findall ( canonicalID_tag ) [ 0 ] . text ) except IndexError : return None childID = canonicalID . lower ( ) for xrd in xrd_list [ 1 : ] : parent_sought = childID [ : childID . rindex ( '!' ) ] parent = xri . XRI ( xrd . findtext ( canonicalID_tag ) ) if ( parent_sought != parent . lower ( ) ) : raise XRDSFraud ( ( '%r can not come from %s' % ( childID , parent ) ) ) childID = parent_sought root = xri . rootAuthority ( iname ) if ( not xri . providerIsAuthoritative ( root , childID ) ) : raise XRDSFraud ( ( '%r can not come from root %r' % ( childID , root ) ) ) return canonicalID
return the canonicalid from this xrds document .