tools/metrics/histograms/update_editor_commands.py
def UpdateHistogramDefinitions(histogram_values, document):
  """Sets the children of <enum name="ExtensionFunctions" ...> node in
  |document| to values generated from policy ids contained in
  |policy_templates|.

  Args:
    histogram_values: A list of pairs (label, value) defining each extension
                      function
    document: A minidom.Document object representing parsed histogram
              definitions XML file.

  """
  # Find ExtensionFunctions enum.
  for enum_node in document.getElementsByTagName('enum'):
    if enum_node.attributes['name'].value == ENUM_NAME:
      extension_functions_enum_node = enum_node
      break
  else:
    raise UserError('No policy enum node found')

  # Remove existing values.
  while extension_functions_enum_node.hasChildNodes():
    extension_functions_enum_node.removeChild(
      extension_functions_enum_node.lastChild)

  # Add a "Generated from (...)" comment
  comment = ' Generated from {0} '.format(EDITOR_COMMAND_CPP)
  extension_functions_enum_node.appendChild(document.createComment(comment))

  # Add values generated from policy templates.
  for (label, value) in histogram_values:
    node = document.createElement('int')
    node.attributes['value'] = str(value)
    node.attributes['label'] = label
    extension_functions_enum_node.appendChild(node)
Sets the children of <enum name="ExtensionFunctions" ...> node in
  |document| to values generated from policy ids contained in
  |policy_templates|.

  Args:
    histogram_values: A list of pairs (label, value) defining each extension
                      function
    document: A minidom.Document object representing parsed histogram
              definitions XML file.

  
Sets the children of  node in
|document| to values generated from policy ids contained in
|policy_templates|.
Sets the children of node in |document| to values generated from policy ids contained in |policy_templates| .
def UpdateHistogramDefinitions(histogram_values, document):
  for enum_node in document.getElementsByTagName('enum'):
    if enum_node.attributes['name'].value == ENUM_NAME:
      extension_functions_enum_node = enum_node
      break
  else:
    raise UserError('No policy enum node found')
  while extension_functions_enum_node.hasChildNodes():
    extension_functions_enum_node.removeChild(
      extension_functions_enum_node.lastChild)
  comment = ' Generated from {0} '.format(EDITOR_COMMAND_CPP)
  extension_functions_enum_node.appendChild(document.createComment(comment))
  for (label, value) in histogram_values:
    node = document.createElement('int')
    node.attributes['value'] = str(value)
    node.attributes['label'] = label
    extension_functions_enum_node.appendChild(node)
def UpdateHistogramDefinitions ( histogram_values , document ) : for enum_node in document . getElementsByTagName ( 'enum' ) : if enum_node . attributes [ 'name' ] . value == ENUM_NAME : extension_functions_enum_node = enum_node break else : raise UserError ( 'No policy enum node found' ) while extension_functions_enum_node . hasChildNodes ( ) : extension_functions_enum_node . removeChild ( extension_functions_enum_node . lastChild ) comment = ' Generated from {0} ' . format ( EDITOR_COMMAND_CPP ) extension_functions_enum_node . appendChild ( document . createComment ( comment ) ) for ( label , value ) in histogram_values : node = document . createElement ( 'int' ) node . attributes [ 'value' ] = str ( value ) node . attributes [ 'label' ] = label extension_functions_enum_node . appendChild ( node )
Sets the children of <enum name="ExtensionFunctions" ...> node in
|document| to values generated from policy ids contained in
|policy_templates|.
Sets the children of <enum name = " ExtensionFunctions " ... > node in |document| to values generated from policy ids contained in |policy_templates| .
"""Sets the children of <enum name="ExtensionFunctions" ...> node in
  |document| to values generated from policy ids contained in
  |policy_templates|.

  Args:
    histogram_values: A list of pairs (label, value) defining each extension
                      function
    document: A minidom.Document object representing parsed histogram
              definitions XML file.

  """ # Find ExtensionFunctions enum. # Remove existing values. # Add a "Generated from (...)" comment # Add values generated from policy templates.
histogram_values
A list of pairs (label, value) defining each extension
function
A list of pairs ( label value ) defining each extension function
document
A minidom.Document object representing parsed histogram
definitions XML file.
A minidom . Document object representing parsed histogram definitions XML file .