def rootAuthority(xri):
 if xri.startswith('xri://'):
  xri = xri[6:]
 authority = xri.split('/', 1)[0]
 if (authority[0] == '('):
  root = authority[:(authority.index(')') + 1)]
 elif (authority[0] in XRI_AUTHORITIES):
  root = authority[0]
 else:
  segments = authority.split('!')
  segments = reduce(list.__add__, map((lambda s: s.split('*')), segments))
  root = segments[0]
 return XRI(root)

def rootAuthority ( xri ) : if xri . startswith ( 'xri://' ) : xri = xri [ 6 : ] authority = xri . split ( '/' , 1 ) [ 0 ] if ( authority [ 0 ] == '(' ) : root = authority [ : ( authority . index ( ')' ) + 1 ) ] elif ( authority [ 0 ] in XRI_AUTHORITIES ) : root = authority [ 0 ] else : segments = authority . split ( '!' ) segments = reduce ( list . __add__ , map ( ( lambda s : s . split ( '*' ) ) , segments ) ) root = segments [ 0 ] return XRI ( root )
return the root authority for an xri .