parameters: (histogram_values, document)
docstring: 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.
docstring_summary: Sets the children of <enum name="ExtensionFunctions" ...> node in
    |document| to values generated from policy ids contained in
    |policy_templates|.
docstring_tokens: Sets the children of <enum name = ExtensionFunctions ... > node in |document| to values generated from policy ids contained in |policy_templates| .
function: 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(
      EXTENSION_FUNCTIONS_HISTOGRAM_VALUE_PATH)
    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)
function_tokens: def UpdateHistogramDefinitions ( histogram_values , document ) : # 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 ( EXTENSION_FUNCTIONS_HISTOGRAM_VALUE_PATH ) 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 )