tools/metrics/histograms/update_histogram_enum.py
def ReadHistogramValuesFromXML(filename, element_name,
                               value_attribute, label_attribute):
  """Creates a dictionary of enum values, read from an XML file.

  Args:
      filename: The unix-style path (relative to src/) of the file to open.
      element_name: Name of elements in the given XML that would be used to
          extract enums.
      value_attribute: The attribute name in source XML that would be mapped to
          |value| attributes in enums.xml.
      label_attribute: The attribute name in source XML that would be mapped to
          |label| attributes in enums.xml.

  Returns:
      A boolean indicating wheather the histograms.xml file would be changed.

  Raises:
      DuplicatedValue: An error when two enum labels share the same value.
  """
  source_xml = minidom.parse(path_util.GetInputFile(filename))
  result = {}
  for row in source_xml.getElementsByTagName(element_name):
    enum_value = int(row.getAttribute(value_attribute))
    label = row.getAttribute(label_attribute)
    # If two enum labels have the same value
    if enum_value in result:
      raise DuplicatedValue(result[enum_value], label)
    result[enum_value] = label
  return result
Creates a dictionary of enum values, read from an XML file.

  Args:
      filename: The unix-style path (relative to src/) of the file to open.
      element_name: Name of elements in the given XML that would be used to
          extract enums.
      value_attribute: The attribute name in source XML that would be mapped to
          |value| attributes in enums.xml.
      label_attribute: The attribute name in source XML that would be mapped to
          |label| attributes in enums.xml.

  Returns:
      A boolean indicating wheather the histograms.xml file would be changed.

  Raises:
      DuplicatedValue: An error when two enum labels share the same value.
  
Creates a dictionary of enum values, read from an XML file.
Creates a dictionary of enum values read from an XML file .
def ReadHistogramValuesFromXML(filename, element_name,
                               value_attribute, label_attribute):
  source_xml = minidom.parse(path_util.GetInputFile(filename))
  result = {}
  for row in source_xml.getElementsByTagName(element_name):
    enum_value = int(row.getAttribute(value_attribute))
    label = row.getAttribute(label_attribute)
    if enum_value in result:
      raise DuplicatedValue(result[enum_value], label)
    result[enum_value] = label
  return result
def ReadHistogramValuesFromXML ( filename , element_name , value_attribute , label_attribute ) : source_xml = minidom . parse ( path_util . GetInputFile ( filename ) ) result = { } for row in source_xml . getElementsByTagName ( element_name ) : enum_value = int ( row . getAttribute ( value_attribute ) ) label = row . getAttribute ( label_attribute ) if enum_value in result : raise DuplicatedValue ( result [ enum_value ] , label ) result [ enum_value ] = label return result
Creates a dictionary of enum values, read from an XML file.
Creates a dictionary of enum values read from an XML file .
"""Creates a dictionary of enum values, read from an XML file.

  Args:
      filename: The unix-style path (relative to src/) of the file to open.
      element_name: Name of elements in the given XML that would be used to
          extract enums.
      value_attribute: The attribute name in source XML that would be mapped to
          |value| attributes in enums.xml.
      label_attribute: The attribute name in source XML that would be mapped to
          |label| attributes in enums.xml.

  Returns:
      A boolean indicating wheather the histograms.xml file would be changed.

  Raises:
      DuplicatedValue: An error when two enum labels share the same value.
  """ # If two enum labels have the same value
A boolean indicating wheather the histograms.xml file would be changed.
A boolean indicating wheather the histograms . xml file would be changed .
An error when two enum labels share the same value.
An error when two enum labels share the same value .
DuplicatedValue
filename
The unix-style path (relative to src/) of the file to open.
The unix - style path ( relative to src / ) of the file to open .
element_name
Name of elements in the given XML that would be used to
extract enums.
Name of elements in the given XML that would be used to extract enums .
value_attribute
The attribute name in source XML that would be mapped to
|value| attributes in enums.xml.
The attribute name in source XML that would be mapped to |value| attributes in enums . xml .
label_attribute
The attribute name in source XML that would be mapped to
|label| attributes in enums.xml.
The attribute name in source XML that would be mapped to |label| attributes in enums . xml .