tools/metrics/histograms/split_xml.py
def _BuildDocumentDict(nodes, depth):
  """Recursively builds a document dict which will be written later.

  This function recursively builds a document dict which the key of the dict is
  the first word of the node's name at the given |depth| and the value of the
  dict is either a list of nodes that correspond to the key or another dict if
  it doesn't reach to |TARGET_DEPTH|.

  Args:
    nodes: A list of histogram nodes or variants node.
    depth: The current depth, starting from 0.

  Returns:
    The document dict.
  """
  if depth == TARGET_DEPTH:
    return nodes

  temp_dict = document_dict = {}
  for node in nodes:
    name_part = _GetCamelCaseName(node, depth)
    if name_part not in temp_dict:
      temp_dict[name_part] = []
    temp_dict[name_part].append(node)

  # Aggregate keys with less than |AGGREGATE_THRESHOLD| values to 'others'.
  _AggregateMinorNodes(temp_dict)

  for key, nodes in temp_dict.items():
    if key == 'others':
      document_dict[key] = nodes
    else:
      document_dict[key] = _BuildDocumentDict(nodes, depth + 1)

  return document_dict
Recursively builds a document dict which will be written later.

  This function recursively builds a document dict which the key of the dict is
  the first word of the node's name at the given |depth| and the value of the
  dict is either a list of nodes that correspond to the key or another dict if
  it doesn't reach to |TARGET_DEPTH|.

  Args:
    nodes: A list of histogram nodes or variants node.
    depth: The current depth, starting from 0.

  Returns:
    The document dict.
  
Recursively builds a document dict which will be written later.
This function recursively builds a document dict which the key of the dict is
the first word of the node's name at the given |depth| and the value of the
dict is either a list of nodes that correspond to the key or another dict if
it doesn't reach to |TARGET_DEPTH|.
Recursively builds a document dict which will be written later . This function recursively builds a document dict which the key of the dict is the first word of the node ' s name at the given |depth| and the value of the dict is either a list of nodes that correspond to the key or another dict if it doesn ' t reach to |TARGET_DEPTH| .
def _BuildDocumentDict(nodes, depth):
  if depth == TARGET_DEPTH:
    return nodes
  temp_dict = document_dict = {}
  for node in nodes:
    name_part = _GetCamelCaseName(node, depth)
    if name_part not in temp_dict:
      temp_dict[name_part] = []
    temp_dict[name_part].append(node)
  _AggregateMinorNodes(temp_dict)
  for key, nodes in temp_dict.items():
    if key == 'others':
      document_dict[key] = nodes
    else:
      document_dict[key] = _BuildDocumentDict(nodes, depth + 1)
  return document_dict
def _BuildDocumentDict ( nodes , depth ) : if depth == TARGET_DEPTH : return nodes temp_dict = document_dict = { } for node in nodes : name_part = _GetCamelCaseName ( node , depth ) if name_part not in temp_dict : temp_dict [ name_part ] = [ ] temp_dict [ name_part ] . append ( node ) _AggregateMinorNodes ( temp_dict ) for key , nodes in temp_dict . items ( ) : if key == 'others' : document_dict [ key ] = nodes else : document_dict [ key ] = _BuildDocumentDict ( nodes , depth + 1 ) return document_dict
Recursively builds a document dict which will be written later.
Recursively builds a document dict which will be written later .
"""Recursively builds a document dict which will be written later.

  This function recursively builds a document dict which the key of the dict is
  the first word of the node's name at the given |depth| and the value of the
  dict is either a list of nodes that correspond to the key or another dict if
  it doesn't reach to |TARGET_DEPTH|.

  Args:
    nodes: A list of histogram nodes or variants node.
    depth: The current depth, starting from 0.

  Returns:
    The document dict.
  """ # Aggregate keys with less than |AGGREGATE_THRESHOLD| values to 'others'.
The document dict.
The document dict .
nodes
A list of histogram nodes or variants node.
A list of histogram nodes or variants node .
depth
The current depth, starting from 0.
The current depth starting from 0 .