tools/metrics/histograms/merge_xml.py
def MergeTrees(trees, should_expand_owners):
  """Merges a list of histograms.xml DOM trees.

  Args:
    trees: A list of histograms.xml DOM trees.
    should_expand_owners: Whether we want to expand owners for histograms.

  Returns:
    A merged DOM tree.
  """
  doc = xml.dom.minidom.Document()
  doc.appendChild(
      MakeNodeWithChildren(
          doc,
          'histogram-configuration',
          # This can result in the merged document having multiple <enums> and
          # similar sections, but scripts ignore these anyway.
          GetEnumsNodes(doc, trees) +
          # Sort the <histogram> and <histogram_suffixes> nodes by name and
          # return the combined nodes.
          CombineHistogramsSorted(doc, trees)))
  # After using the unsafe version of appendChild, we see a regression when
  # pretty-printing the merged |doc|. This might because the unsafe appendChild
  # doesn't build indexes for later lookup. And thus, we need to convert the
  # merged |doc| to a xml string and convert it back to force it to build
  # indexes for the merged |doc|.
  doc = xml.dom.minidom.parseString(doc.toxml().encode('utf-8'))
  # Only perform fancy operations after |doc| becomes stable. This helps improve
  # the runtime performance.
  if should_expand_owners:
    for histograms in doc.getElementsByTagName('histograms'):
      expand_owners.ExpandHistogramsOWNERS(histograms)
  return doc
Merges a list of histograms.xml DOM trees.

  Args:
    trees: A list of histograms.xml DOM trees.
    should_expand_owners: Whether we want to expand owners for histograms.

  Returns:
    A merged DOM tree.
  
Merges a list of histograms.xml DOM trees.
Merges a list of histograms . xml DOM trees .
def MergeTrees(trees, should_expand_owners):
  doc = xml.dom.minidom.Document()
  doc.appendChild(
      MakeNodeWithChildren(
          doc,
          'histogram-configuration',
          GetEnumsNodes(doc, trees) +
          CombineHistogramsSorted(doc, trees)))
  doc = xml.dom.minidom.parseString(doc.toxml().encode('utf-8'))
  if should_expand_owners:
    for histograms in doc.getElementsByTagName('histograms'):
      expand_owners.ExpandHistogramsOWNERS(histograms)
  return doc
def MergeTrees ( trees , should_expand_owners ) : doc = xml . dom . minidom . Document ( ) doc . appendChild ( MakeNodeWithChildren ( doc , 'histogram-configuration' , GetEnumsNodes ( doc , trees ) + CombineHistogramsSorted ( doc , trees ) ) ) doc = xml . dom . minidom . parseString ( doc . toxml ( ) . encode ( 'utf-8' ) ) if should_expand_owners : for histograms in doc . getElementsByTagName ( 'histograms' ) : expand_owners . ExpandHistogramsOWNERS ( histograms ) return doc
Merges a list of histograms.xml DOM trees.
Merges a list of histograms . xml DOM trees .
"""Merges a list of histograms.xml DOM trees.

  Args:
    trees: A list of histograms.xml DOM trees.
    should_expand_owners: Whether we want to expand owners for histograms.

  Returns:
    A merged DOM tree.
  """ # This can result in the merged document having multiple <enums> and # similar sections, but scripts ignore these anyway. # Sort the <histogram> and <histogram_suffixes> nodes by name and # return the combined nodes. # After using the unsafe version of appendChild, we see a regression when # pretty-printing the merged |doc|. This might because the unsafe appendChild # doesn't build indexes for later lookup. And thus, we need to convert the # merged |doc| to a xml string and convert it back to force it to build # indexes for the merged |doc|. # Only perform fancy operations after |doc| becomes stable. This helps improve # the runtime performance.
A merged DOM tree.
A merged DOM tree .
trees
A list of histograms.xml DOM trees.
A list of histograms . xml DOM trees .
should_expand_owners
Whether we want to expand owners for histograms.
Whether we want to expand owners for histograms .