tools/metrics/histograms/suffixes_to_variants.py
def _GetSuffixesDict(nodes, all_histograms):
  """Gets a dict of simple histogram-suffixes to be used in the migration.

  Returns two dicts of histogram-suffixes to be migrated to the new patterned
  histograms syntax.

  The first dict: the keys are the histogram-suffixes' affected histogram name
  and the values are the histogram_suffixes nodes that have only one
  affected-histogram. These histograms-suffixes can be converted to inline
  patterned histograms.

  The second dict: the keys are the histogram_suffixes name and the values
  are the histogram_suffixes nodes whose affected-histograms are all present in
  the |all_histograms|. These histogram suffixes can be converted to out-of-line
  variants.

  Args:
    nodes: A Nodelist of histograms_suffixes nodes.
    all_histograms: A Nodelist of all chosen histograms.

  Returns:
    A dict of histograms-suffixes nodes keyed by their names.
  """

  single_affected = {}
  all_affected_found = {}
  for histogram_suffixes in nodes:
    affected_histograms = histogram_suffixes.getElementsByTagName(
        'affected-histogram')
    if len(affected_histograms) == 1:
      affected_histogram = affected_histograms[0].getAttribute('name')
      single_affected[affected_histogram] = histogram_suffixes
    elif _AreAllAffectedHistogramsFound(affected_histograms, all_histograms):
      for affected_histogram in affected_histograms:
        affected_histogram = affected_histogram.getAttribute('name')
        if affected_histogram in all_affected_found:
          logging.warning(
              'Histogram %s is already associated with other suffixes. '
              'Please manually migrate it.', affected_histogram)
          continue
        all_affected_found[affected_histogram] = histogram_suffixes
  return single_affected, all_affected_found
Gets a dict of simple histogram-suffixes to be used in the migration.

  Returns two dicts of histogram-suffixes to be migrated to the new patterned
  histograms syntax.

  The first dict: the keys are the histogram-suffixes' affected histogram name
  and the values are the histogram_suffixes nodes that have only one
  affected-histogram. These histograms-suffixes can be converted to inline
  patterned histograms.

  The second dict: the keys are the histogram_suffixes name and the values
  are the histogram_suffixes nodes whose affected-histograms are all present in
  the |all_histograms|. These histogram suffixes can be converted to out-of-line
  variants.

  Args:
    nodes: A Nodelist of histograms_suffixes nodes.
    all_histograms: A Nodelist of all chosen histograms.

  Returns:
    A dict of histograms-suffixes nodes keyed by their names.
  
Gets a dict of simple histogram-suffixes to be used in the migration.
Returns two dicts of histogram-suffixes to be migrated to the new patterned
histograms syntax.

The first dict: the keys are the histogram-suffixes' affected histogram name
and the values are the histogram_suffixes nodes that have only one
affected-histogram. These histograms-suffixes can be converted to inline
patterned histograms.

The second dict: the keys are the histogram_suffixes name and the values
are the histogram_suffixes nodes whose affected-histograms are all present in
the |all_histograms|. These histogram suffixes can be converted to out-of-line
variants.
Gets a dict of simple histogram - suffixes to be used in the migration . Returns two dicts of histogram - suffixes to be migrated to the new patterned histograms syntax . The first dict : the keys are the histogram - suffixes ' affected histogram name and the values are the histogram_suffixes nodes that have only one affected - histogram . These histograms - suffixes can be converted to inline patterned histograms . The second dict : the keys are the histogram_suffixes name and the values are the histogram_suffixes nodes whose affected - histograms are all present in the |all_histograms| . These histogram suffixes can be converted to out - of - line variants .
def _GetSuffixesDict(nodes, all_histograms):
  single_affected = {}
  all_affected_found = {}
  for histogram_suffixes in nodes:
    affected_histograms = histogram_suffixes.getElementsByTagName(
        'affected-histogram')
    if len(affected_histograms) == 1:
      affected_histogram = affected_histograms[0].getAttribute('name')
      single_affected[affected_histogram] = histogram_suffixes
    elif _AreAllAffectedHistogramsFound(affected_histograms, all_histograms):
      for affected_histogram in affected_histograms:
        affected_histogram = affected_histogram.getAttribute('name')
        if affected_histogram in all_affected_found:
          logging.warning(
              'Histogram %s is already associated with other suffixes. '
              'Please manually migrate it.', affected_histogram)
          continue
        all_affected_found[affected_histogram] = histogram_suffixes
  return single_affected, all_affected_found
def _GetSuffixesDict ( nodes , all_histograms ) : single_affected = { } all_affected_found = { } for histogram_suffixes in nodes : affected_histograms = histogram_suffixes . getElementsByTagName ( 'affected-histogram' ) if len ( affected_histograms ) == 1 : affected_histogram = affected_histograms [ 0 ] . getAttribute ( 'name' ) single_affected [ affected_histogram ] = histogram_suffixes elif _AreAllAffectedHistogramsFound ( affected_histograms , all_histograms ) : for affected_histogram in affected_histograms : affected_histogram = affected_histogram . getAttribute ( 'name' ) if affected_histogram in all_affected_found : logging . warning ( 'Histogram %s is already associated with other suffixes. ' 'Please manually migrate it.' , affected_histogram ) continue all_affected_found [ affected_histogram ] = histogram_suffixes return single_affected , all_affected_found
Gets a dict of simple histogram-suffixes to be used in the migration.
Gets a dict of simple histogram - suffixes to be used in the migration .
"""Gets a dict of simple histogram-suffixes to be used in the migration.

  Returns two dicts of histogram-suffixes to be migrated to the new patterned
  histograms syntax.

  The first dict: the keys are the histogram-suffixes' affected histogram name
  and the values are the histogram_suffixes nodes that have only one
  affected-histogram. These histograms-suffixes can be converted to inline
  patterned histograms.

  The second dict: the keys are the histogram_suffixes name and the values
  are the histogram_suffixes nodes whose affected-histograms are all present in
  the |all_histograms|. These histogram suffixes can be converted to out-of-line
  variants.

  Args:
    nodes: A Nodelist of histograms_suffixes nodes.
    all_histograms: A Nodelist of all chosen histograms.

  Returns:
    A dict of histograms-suffixes nodes keyed by their names.
  """
A dict of histograms-suffixes nodes keyed by their names.
A dict of histograms - suffixes nodes keyed by their names .
nodes
A Nodelist of histograms_suffixes nodes.
A Nodelist of histograms_suffixes nodes .
all_histograms
A Nodelist of all chosen histograms.
A Nodelist of all chosen histograms .