def ProcessBackendNode(self, node):
    """Processes XML nodes labeled 'backend' into a Backends object."""
    tag = xml_parser_utils.GetTag(node)
    if tag != 'backend':
      self.errors.append('Unrecognized node: <%s>' % tag)
      return

    backend = Backend()
    name = xml_parser_utils.GetAttribute(node, 'name')
    if not name:
      self.errors.append('All backends must have names')
      backend.name = '-'
    else:
      backend.name = name
    instance_class = xml_parser_utils.GetChildNodeText(node, 'class')
    if instance_class:
      backend.instance_class = instance_class
    instances = xml_parser_utils.GetChildNodeText(node, 'instances')
    if instances:
      try:
        backend.instances = int(instances)
      except __HOLE__:
        self.errors.append(
            '<instances> must be an integer (bad value %s) in backend %s' %
            (instances, backend.name))
    max_concurrent_requests = xml_parser_utils.GetChildNodeText(
        node, 'max-concurrent-requests')
    if max_concurrent_requests:
      try:
        backend.max_concurrent_requests = int(max_concurrent_requests)
      except ValueError:
        self.errors.append('<max-concurrent-requests> must be an integer '
                           '(bad value %s) in backend %s' %
                           (max_concurrent_requests, backend.name))

    options_node = xml_parser_utils.GetChild(node, 'options')
    if options_node is not None:
      for sub_node in options_node.getchildren():
        tag = xml_parser_utils.GetTag(sub_node)
        if tag not in ('fail-fast', 'dynamic', 'public'):
          self.errors.append('<options> only supports values fail-fast, '
                             'dynamic, and public (bad value %s) in backend %s'
                             % (tag, backend.name))
          continue
        tag = tag.replace('-', '')
        if xml_parser_utils.BooleanValue(sub_node.text):
          backend.options.add(tag)
        else:
          if tag in backend.options:
            backend.options.remove(tag)

    self.backends.append(backend)
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/tools/backends_xml_parser.py/BackendsXmlParser.ProcessBackendNode