tools/metrics/histograms/validate_prefix.py
def ValidatePrefixInFile(xml_path):
  """Validates that all <histogram> and <variants> are put in the correct file.

  Args:
    xml_path: The path to the histograms.xml file.

  Returns:
    A boolean that is True if at least a histogram has incorrect prefix, False
        otherwise.
  """
  prefix = os.path.basename(os.path.dirname(xml_path))
  has_prefix_error = False
  tree = xml.dom.minidom.parse(xml_path)

  for node in extract_histograms.IterElementsWithTag(tree, 'variants', 3):
    correct_dir = split_xml.GetDirForNode(node)
    if correct_dir != prefix:
      variants_name = node.getAttribute('name')
      logging.error(
          'Variants of name %s is not placed in the correct directory, '
          'please remove it from the metadata/%s directory '
          'and place it in the metadata/%s directory.', variants_name, prefix,
          correct_dir)
      has_prefix_error = True

  for node in extract_histograms.IterElementsWithTag(tree, 'histogram', 3):
    correct_dir = split_xml.GetDirForNode(node)
    if correct_dir != prefix:
      histogram_name = node.getAttribute('name')
      logging.error(
          'Histogram of name %s is not placed in the correct directory, '
          'please remove it from the metadata/%s directory '
          'and place it in the metadata/%s directory.', histogram_name, prefix,
          correct_dir)
      has_prefix_error = True

  return has_prefix_error
Validates that all <histogram> and <variants> are put in the correct file.

  Args:
    xml_path: The path to the histograms.xml file.

  Returns:
    A boolean that is True if at least a histogram has incorrect prefix, False
        otherwise.
  
Validates that all  and  are put in the correct file.
Validates that all and are put in the correct file .
def ValidatePrefixInFile(xml_path):
  prefix = os.path.basename(os.path.dirname(xml_path))
  has_prefix_error = False
  tree = xml.dom.minidom.parse(xml_path)
  for node in extract_histograms.IterElementsWithTag(tree, 'variants', 3):
    correct_dir = split_xml.GetDirForNode(node)
    if correct_dir != prefix:
      variants_name = node.getAttribute('name')
      logging.error(
          'Variants of name %s is not placed in the correct directory, '
          'please remove it from the metadata/%s directory '
          'and place it in the metadata/%s directory.', variants_name, prefix,
          correct_dir)
      has_prefix_error = True
  for node in extract_histograms.IterElementsWithTag(tree, 'histogram', 3):
    correct_dir = split_xml.GetDirForNode(node)
    if correct_dir != prefix:
      histogram_name = node.getAttribute('name')
      logging.error(
          'Histogram of name %s is not placed in the correct directory, '
          'please remove it from the metadata/%s directory '
          'and place it in the metadata/%s directory.', histogram_name, prefix,
          correct_dir)
      has_prefix_error = True
  return has_prefix_error
def ValidatePrefixInFile ( xml_path ) : prefix = os . path . basename ( os . path . dirname ( xml_path ) ) has_prefix_error = False tree = xml . dom . minidom . parse ( xml_path ) for node in extract_histograms . IterElementsWithTag ( tree , 'variants' , 3 ) : correct_dir = split_xml . GetDirForNode ( node ) if correct_dir != prefix : variants_name = node . getAttribute ( 'name' ) logging . error ( 'Variants of name %s is not placed in the correct directory, ' 'please remove it from the metadata/%s directory ' 'and place it in the metadata/%s directory.' , variants_name , prefix , correct_dir ) has_prefix_error = True for node in extract_histograms . IterElementsWithTag ( tree , 'histogram' , 3 ) : correct_dir = split_xml . GetDirForNode ( node ) if correct_dir != prefix : histogram_name = node . getAttribute ( 'name' ) logging . error ( 'Histogram of name %s is not placed in the correct directory, ' 'please remove it from the metadata/%s directory ' 'and place it in the metadata/%s directory.' , histogram_name , prefix , correct_dir ) has_prefix_error = True return has_prefix_error
Validates that all <histogram> and <variants> are put in the correct file.
Validates that all <histogram > and <variants > are put in the correct file .
"""Validates that all <histogram> and <variants> are put in the correct file.

  Args:
    xml_path: The path to the histograms.xml file.

  Returns:
    A boolean that is True if at least a histogram has incorrect prefix, False
        otherwise.
  """
A boolean that is True if at least a histogram has incorrect prefix, False
otherwise.
A boolean that is True if at least a histogram has incorrect prefix False otherwise .
xml_path
The path to the histograms.xml file.
The path to the histograms . xml file .