tools/checkteamtags/extract_components.py
def display_stat(stats, root, options):
  """"Display coverage statistic.

  The following three values are always displayed:
    - The total number of OWNERS files under directory root and its sub-
      directories.
    - The number of OWNERS files (and its percentage of the total) that have
      component information but no team information.
    - The number of OWNERS files (and its percentage of the total) that have
      both component and team information.

  Optionally, if options.stat_coverage or options.complete_coverage are given,
    the same information will be shown for each depth level.
    (up to the level given by options.stat_coverage, if any).

  Args:
    stats (dict): Tha statistics in dictionary form as produced by the
        owners_file_tags module.
    root (str): The root directory from which the depth level is calculated.
    options (optparse.Values): The command line options as returned by
        optparse.
  """
  file_total = stats['OWNERS-count']
  print("%d OWNERS files in total." % file_total)
  file_with_component = stats['OWNERS-with-component-only-count']
  file_pct_with_component = "N/A"
  if file_total > 0:
    file_pct_with_component = "{0:.2f}".format(
        100.0 * file_with_component / file_total)
  print('%(file_with_component)d (%(file_pct_with_component)s%%) OWNERS '\
        'files have COMPONENT' % {
            'file_with_component': file_with_component,
            'file_pct_with_component': file_pct_with_component})
  file_with_team_component = stats['OWNERS-with-team-and-component-count']
  file_pct_with_team_component = "N/A"
  if file_total > 0:
    file_pct_with_team_component = "{0:.2f}".format(
        100.0 * file_with_team_component / file_total)
  print('%(file_with_team_component)d (%(file_pct_with_team_component)s%%) '\
        'OWNERS files have TEAM and COMPONENT' % {
            'file_with_team_component': file_with_team_component,
            'file_pct_with_team_component': file_pct_with_team_component})

  print("\nUnder directory %s " % root)
  # number of depth to display, default is max depth under root
  num_output_depth = len(stats['OWNERS-count-by-depth'])
  if (options.stat_coverage > 0
      and options.stat_coverage < num_output_depth):
    num_output_depth = options.stat_coverage

  for depth in range(0, num_output_depth):
    file_total_by_depth = stats['OWNERS-count-by-depth'][depth]
    file_with_component_by_depth =\
    stats['OWNERS-with-component-only-count-by-depth'][depth]
    file_pct_with_component_by_depth = "N/A"
    if file_total_by_depth > 0:
      file_pct_with_component_by_depth = "{0:.2f}".format(
          100.0 * file_with_component_by_depth / file_total_by_depth)
    file_with_team_component_by_depth =\
    stats['OWNERS-with-team-and-component-count-by-depth'][depth]
    file_pct_with_team_component_by_depth = "N/A"
    if file_total_by_depth > 0:
      file_pct_with_team_component_by_depth = "{0:.2f}".format(
          100.0 * file_with_team_component_by_depth / file_total_by_depth)
    print('%(file_total_by_depth)d OWNERS files at depth %(depth)d' % {
        'file_total_by_depth': file_total_by_depth,
        'depth': depth
    })
    print('have COMPONENT: %(file_with_component_by_depth)d, '\
          'percentage: %(file_pct_with_component_by_depth)s%%' % {
              'file_with_component_by_depth':
              file_with_component_by_depth,
              'file_pct_with_component_by_depth':
              file_pct_with_component_by_depth})
    print('have COMPONENT and TEAM: %(file_with_team_component_by_depth)d,'\
          'percentage: %(file_pct_with_team_component_by_depth)s%%' % {
              'file_with_team_component_by_depth':
              file_with_team_component_by_depth,
              'file_pct_with_team_component_by_depth':
              file_pct_with_team_component_by_depth})
Display coverage statistic.

  The following three values are always displayed:
    - The total number of OWNERS files under directory root and its sub-
      directories.
    - The number of OWNERS files (and its percentage of the total) that have
      component information but no team information.
    - The number of OWNERS files (and its percentage of the total) that have
      both component and team information.

  Optionally, if options.stat_coverage or options.complete_coverage are given,
    the same information will be shown for each depth level.
    (up to the level given by options.stat_coverage, if any).

  Args:
    stats (dict): Tha statistics in dictionary form as produced by the
        owners_file_tags module.
    root (str): The root directory from which the depth level is calculated.
    options (optparse.Values): The command line options as returned by
        optparse.
  
Display coverage statistic.
The following three values are always displayed:
The total number of OWNERS files under directory root and its sub
directories.
The number of OWNERS files (and its percentage of the total) that have
component information but no team information.
The number of OWNERS files (and its percentage of the total) that have
both component and team information.

Optionally, if options.stat_coverage or options.complete_coverage are given,
the same information will be shown for each depth level.
(up to the level given by options.stat_coverage, if any).
Display coverage statistic . The following three values are always displayed : The total number of OWNERS files under directory root and its sub directories . The number of OWNERS files ( and its percentage of the total ) that have component information but no team information . The number of OWNERS files ( and its percentage of the total ) that have both component and team information . Optionally if options . stat_coverage or options . complete_coverage are given the same information will be shown for each depth level . ( up to the level given by options . stat_coverage if any ) .
def display_stat(stats, root, options):
  file_total = stats['OWNERS-count']
  print("%d OWNERS files in total." % file_total)
  file_with_component = stats['OWNERS-with-component-only-count']
  file_pct_with_component = "N/A"
  if file_total > 0:
    file_pct_with_component = "{0:.2f}".format(
        100.0 * file_with_component / file_total)
  print('%(file_with_component)d (%(file_pct_with_component)s%%) OWNERS '\
        'files have COMPONENT' % {
            'file_with_component': file_with_component,
            'file_pct_with_component': file_pct_with_component})
  file_with_team_component = stats['OWNERS-with-team-and-component-count']
  file_pct_with_team_component = "N/A"
  if file_total > 0:
    file_pct_with_team_component = "{0:.2f}".format(
        100.0 * file_with_team_component / file_total)
  print('%(file_with_team_component)d (%(file_pct_with_team_component)s%%) '\
        'OWNERS files have TEAM and COMPONENT' % {
            'file_with_team_component': file_with_team_component,
            'file_pct_with_team_component': file_pct_with_team_component})
  print("\nUnder directory %s " % root)
  num_output_depth = len(stats['OWNERS-count-by-depth'])
  if (options.stat_coverage > 0
      and options.stat_coverage < num_output_depth):
    num_output_depth = options.stat_coverage
  for depth in range(0, num_output_depth):
    file_total_by_depth = stats['OWNERS-count-by-depth'][depth]
    file_with_component_by_depth =\
    stats['OWNERS-with-component-only-count-by-depth'][depth]
    file_pct_with_component_by_depth = "N/A"
    if file_total_by_depth > 0:
      file_pct_with_component_by_depth = "{0:.2f}".format(
          100.0 * file_with_component_by_depth / file_total_by_depth)
    file_with_team_component_by_depth =\
    stats['OWNERS-with-team-and-component-count-by-depth'][depth]
    file_pct_with_team_component_by_depth = "N/A"
    if file_total_by_depth > 0:
      file_pct_with_team_component_by_depth = "{0:.2f}".format(
          100.0 * file_with_team_component_by_depth / file_total_by_depth)
    print('%(file_total_by_depth)d OWNERS files at depth %(depth)d' % {
        'file_total_by_depth': file_total_by_depth,
        'depth': depth
    })
    print('have COMPONENT: %(file_with_component_by_depth)d, '\
          'percentage: %(file_pct_with_component_by_depth)s%%' % {
              'file_with_component_by_depth':
              file_with_component_by_depth,
              'file_pct_with_component_by_depth':
              file_pct_with_component_by_depth})
    print('have COMPONENT and TEAM: %(file_with_team_component_by_depth)d,'\
          'percentage: %(file_pct_with_team_component_by_depth)s%%' % {
              'file_with_team_component_by_depth':
              file_with_team_component_by_depth,
              'file_pct_with_team_component_by_depth':
              file_pct_with_team_component_by_depth})
def display_stat ( stats , root , options ) : file_total = stats [ 'OWNERS-count' ] print ( "%d OWNERS files in total." % file_total ) file_with_component = stats [ 'OWNERS-with-component-only-count' ] file_pct_with_component = "N/A" if file_total > 0 : file_pct_with_component = "{0:.2f}" . format ( 100.0 * file_with_component / file_total ) print ( '%(file_with_component)d (%(file_pct_with_component)s%%) OWNERS ' 'files have COMPONENT' % { 'file_with_component' : file_with_component , 'file_pct_with_component' : file_pct_with_component } ) file_with_team_component = stats [ 'OWNERS-with-team-and-component-count' ] file_pct_with_team_component = "N/A" if file_total > 0 : file_pct_with_team_component = "{0:.2f}" . format ( 100.0 * file_with_team_component / file_total ) print ( '%(file_with_team_component)d (%(file_pct_with_team_component)s%%) ' 'OWNERS files have TEAM and COMPONENT' % { 'file_with_team_component' : file_with_team_component , 'file_pct_with_team_component' : file_pct_with_team_component } ) print ( "\nUnder directory %s " % root ) num_output_depth = len ( stats [ 'OWNERS-count-by-depth' ] ) if ( options . stat_coverage > 0 and options . stat_coverage < num_output_depth ) : num_output_depth = options . stat_coverage for depth in range ( 0 , num_output_depth ) : file_total_by_depth = stats [ 'OWNERS-count-by-depth' ] [ depth ] file_with_component_by_depth = stats [ 'OWNERS-with-component-only-count-by-depth' ] [ depth ] file_pct_with_component_by_depth = "N/A" if file_total_by_depth > 0 : file_pct_with_component_by_depth = "{0:.2f}" . format ( 100.0 * file_with_component_by_depth / file_total_by_depth ) file_with_team_component_by_depth = stats [ 'OWNERS-with-team-and-component-count-by-depth' ] [ depth ] file_pct_with_team_component_by_depth = "N/A" if file_total_by_depth > 0 : file_pct_with_team_component_by_depth = "{0:.2f}" . format ( 100.0 * file_with_team_component_by_depth / file_total_by_depth ) print ( '%(file_total_by_depth)d OWNERS files at depth %(depth)d' % { 'file_total_by_depth' : file_total_by_depth , 'depth' : depth } ) print ( 'have COMPONENT: %(file_with_component_by_depth)d, ' 'percentage: %(file_pct_with_component_by_depth)s%%' % { 'file_with_component_by_depth' : file_with_component_by_depth , 'file_pct_with_component_by_depth' : file_pct_with_component_by_depth } ) print ( 'have COMPONENT and TEAM: %(file_with_team_component_by_depth)d,' 'percentage: %(file_pct_with_team_component_by_depth)s%%' % { 'file_with_team_component_by_depth' : file_with_team_component_by_depth , 'file_pct_with_team_component_by_depth' : file_pct_with_team_component_by_depth } )
Display coverage statistic.
Display coverage statistic .
""""Display coverage statistic.

  The following three values are always displayed:
    - The total number of OWNERS files under directory root and its sub-
      directories.
    - The number of OWNERS files (and its percentage of the total) that have
      component information but no team information.
    - The number of OWNERS files (and its percentage of the total) that have
      both component and team information.

  Optionally, if options.stat_coverage or options.complete_coverage are given,
    the same information will be shown for each depth level.
    (up to the level given by options.stat_coverage, if any).

  Args:
    stats (dict): Tha statistics in dictionary form as produced by the
        owners_file_tags module.
    root (str): The root directory from which the depth level is calculated.
    options (optparse.Values): The command line options as returned by
        optparse.
  """ # number of depth to display, default is max depth under root
stats
Tha statistics in dictionary form as produced by the
owners_file_tags module.
Tha statistics in dictionary form as produced by the owners_file_tags module .
root
The root directory from which the depth level is calculated.
The root directory from which the depth level is calculated .
options
The command line options as returned by
optparse.
The command line options as returned by optparse .