def AnyFeedFromString(xml_string):
  """Creates an instance of the appropriate feed class from the
    xml string contents.

  Args:
    xml_string: str A string which contains valid XML. The root element
        of the XML string should match the tag and namespace of the desired
        class.

  Returns:
    An instance of the target class with members assigned according to the
    contents of the XML - or a basic gdata.GDataFeed instance if it is
    impossible to determine the appropriate class (look for extra elements
    in GDataFeed's .FindExtensions() and extension_elements[] ).
  """
  tree = ElementTree.fromstring(xml_string)
  category = tree.find('{%s}category' % atom.ATOM_NAMESPACE)
  if category is None:
    # TODO: is this the best way to handle this?
    return atom._CreateClassFromElementTree(GPhotosBaseFeed, tree)
  namespace, kind = category.get('term').split('#')
  if namespace != PHOTOS_NAMESPACE:
    # TODO: is this the best way to handle this?
    return atom._CreateClassFromElementTree(GPhotosBaseFeed, tree)
  ## TODO: is getattr safe this way?
  feed_class = getattr(gdata.photos, kind.title() % '%sFeed')
  return atom._CreateClassFromElementTree(feed_class, tree)
dataset/ETHPy150Open CollabQ/CollabQ/vendor/gdata/photos/__init__.py/AnyFeedFromString/swapped operands of `%`