tools/metrics/histograms/suffixes_to_variants.py
def SuffixesToVariantsMigration(args):
  """Migates all histogram suffixes to patterned histograms."""
  histogram_suffixes_list = minidom.parse(open(HISTOGRAM_SUFFIXES_LIST_PATH))
  histogram_suffixes_nodes = histogram_suffixes_list.getElementsByTagName(
      'histogram_suffixes')

  doc = minidom.Document()
  for histograms_file in ChooseFiles(args):
    histograms = minidom.parse(open(histograms_file))
    single_affected, all_affected_found = _GetSuffixesDict(
        histogram_suffixes_nodes, histograms.getElementsByTagName('histogram'))
    suffixes_to_convert = set()
    for histogram in histograms.getElementsByTagName('histogram'):
      name = histogram.getAttribute('name')
      # Migrate inline patterned histograms.
      if name in single_affected.keys():
        MigrateToInlinePatterenedHistogram(doc, histogram,
                                           single_affected[name])
      elif name in all_affected_found.keys():
        suffixes_to_convert.add(all_affected_found[name])
        MigrateToOutOflinePatterenedHistogram(doc, histogram,
                                              all_affected_found[name])

    _MigrateOutOfLineVariants(doc, histograms, suffixes_to_convert)

    # Update histograms.xml with patterned histograms.
    with open(histograms_file, 'w') as f:
      pretty_xml_string = histogram_configuration_model.PrettifyTree(histograms)
      f.write(pretty_xml_string)

  # Remove histogram_suffixes that have already been migrated.
  with open(HISTOGRAM_SUFFIXES_LIST_PATH, 'w') as f:
    pretty_xml_string = histogram_configuration_model.PrettifyTree(
        histogram_suffixes_list)
    f.write(pretty_xml_string)
Migates all histogram suffixes to patterned histograms.
Migates all histogram suffixes to patterned histograms.
Migates all histogram suffixes to patterned histograms .
def SuffixesToVariantsMigration(args):
  histogram_suffixes_list = minidom.parse(open(HISTOGRAM_SUFFIXES_LIST_PATH))
  histogram_suffixes_nodes = histogram_suffixes_list.getElementsByTagName(
      'histogram_suffixes')
  doc = minidom.Document()
  for histograms_file in ChooseFiles(args):
    histograms = minidom.parse(open(histograms_file))
    single_affected, all_affected_found = _GetSuffixesDict(
        histogram_suffixes_nodes, histograms.getElementsByTagName('histogram'))
    suffixes_to_convert = set()
    for histogram in histograms.getElementsByTagName('histogram'):
      name = histogram.getAttribute('name')
      if name in single_affected.keys():
        MigrateToInlinePatterenedHistogram(doc, histogram,
                                           single_affected[name])
      elif name in all_affected_found.keys():
        suffixes_to_convert.add(all_affected_found[name])
        MigrateToOutOflinePatterenedHistogram(doc, histogram,
                                              all_affected_found[name])
    _MigrateOutOfLineVariants(doc, histograms, suffixes_to_convert)
    with open(histograms_file, 'w') as f:
      pretty_xml_string = histogram_configuration_model.PrettifyTree(histograms)
      f.write(pretty_xml_string)
  with open(HISTOGRAM_SUFFIXES_LIST_PATH, 'w') as f:
    pretty_xml_string = histogram_configuration_model.PrettifyTree(
        histogram_suffixes_list)
    f.write(pretty_xml_string)
def SuffixesToVariantsMigration ( args ) : histogram_suffixes_list = minidom . parse ( open ( HISTOGRAM_SUFFIXES_LIST_PATH ) ) histogram_suffixes_nodes = histogram_suffixes_list . getElementsByTagName ( 'histogram_suffixes' ) doc = minidom . Document ( ) for histograms_file in ChooseFiles ( args ) : histograms = minidom . parse ( open ( histograms_file ) ) single_affected , all_affected_found = _GetSuffixesDict ( histogram_suffixes_nodes , histograms . getElementsByTagName ( 'histogram' ) ) suffixes_to_convert = set ( ) for histogram in histograms . getElementsByTagName ( 'histogram' ) : name = histogram . getAttribute ( 'name' ) if name in single_affected . keys ( ) : MigrateToInlinePatterenedHistogram ( doc , histogram , single_affected [ name ] ) elif name in all_affected_found . keys ( ) : suffixes_to_convert . add ( all_affected_found [ name ] ) MigrateToOutOflinePatterenedHistogram ( doc , histogram , all_affected_found [ name ] ) _MigrateOutOfLineVariants ( doc , histograms , suffixes_to_convert ) with open ( histograms_file , 'w' ) as f : pretty_xml_string = histogram_configuration_model . PrettifyTree ( histograms ) f . write ( pretty_xml_string ) with open ( HISTOGRAM_SUFFIXES_LIST_PATH , 'w' ) as f : pretty_xml_string = histogram_configuration_model . PrettifyTree ( histogram_suffixes_list ) f . write ( pretty_xml_string )
Migates all histogram suffixes to patterned histograms.
Migates all histogram suffixes to patterned histograms .
"""Migates all histogram suffixes to patterned histograms.""" # Migrate inline patterned histograms. # Update histograms.xml with patterned histograms. # Remove histogram_suffixes that have already been migrated.
args