tools/metrics/histograms/expand_owners.py
def _ExtractComponentViaDirmd(path):
  """Returns the component for monorail issues at the given path.

  Examples are 'Blink>Storage>FileAPI' and 'UI'.

  Uses dirmd in third_party/depot_tools to parse metadata and walk parent
  directories up to the top level of the repo.

  Returns an empty string if no component can be extracted.

  Args:
    path: The path to a directory to query, e.g. 'src/storage'.
  """
  # Verify that the paths are absolute and the root is a parent of the
  # passed in path.
  root_path = os.path.abspath(os.path.join(*DIR_ABOVE_TOOLS))
  path = os.path.abspath(path)
  if not path.startswith(root_path):
    raise Error('Path {} is not a subpath of the root path {}.'.format(
        path, root_path))
  subpath = path[len(root_path) + 1:] or '.'  # E.g. content/public.
  dirmd_exe = 'dirmd'
  if sys.platform == 'win32':
    dirmd_exe = 'dirmd.bat'
  dirmd_path = os.path.join(*(DIR_ABOVE_TOOLS +
                              ['third_party', 'depot_tools', dirmd_exe]))
  dirmd_command = [dirmd_path, 'read', '-form', 'sparse', root_path, path]
  dirmd = subprocess.Popen(
      dirmd_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  if dirmd.wait() != 0:
    raise Error('dirmd failed: ' + dirmd.stderr.read())
  json_out = json.load(dirmd.stdout)
  # On Windows, dirmd output still uses Unix path separators.
  if sys.platform == 'win32':
    subpath = subpath.replace('\\', '/')
  return _ComponentFromDirmd(json_out, subpath)
Returns the component for monorail issues at the given path.

  Examples are 'Blink>Storage>FileAPI' and 'UI'.

  Uses dirmd in third_party/depot_tools to parse metadata and walk parent
  directories up to the top level of the repo.

  Returns an empty string if no component can be extracted.

  Args:
    path: The path to a directory to query, e.g. 'src/storage'.
  
Returns the component for monorail issues at the given path.
Examples are 'Blink>Storage>FileAPI' and 'UI'.

Uses dirmd in third_party/depot_tools to parse metadata and walk parent
directories up to the top level of the repo.

Returns an empty string if no component can be extracted.
Returns the component for monorail issues at the given path . Examples are ' Blink > Storage > FileAPI ' and ' UI ' . Uses dirmd in third_party / depot_tools to parse metadata and walk parent directories up to the top level of the repo . Returns an empty string if no component can be extracted .
def _ExtractComponentViaDirmd(path):
  root_path = os.path.abspath(os.path.join(*DIR_ABOVE_TOOLS))
  path = os.path.abspath(path)
  if not path.startswith(root_path):
    raise Error('Path {} is not a subpath of the root path {}.'.format(
        path, root_path))
  subpath = path[len(root_path) + 1:] or '.'  
  dirmd_exe = 'dirmd'
  if sys.platform == 'win32':
    dirmd_exe = 'dirmd.bat'
  dirmd_path = os.path.join(*(DIR_ABOVE_TOOLS +
                              ['third_party', 'depot_tools', dirmd_exe]))
  dirmd_command = [dirmd_path, 'read', '-form', 'sparse', root_path, path]
  dirmd = subprocess.Popen(
      dirmd_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  if dirmd.wait() != 0:
    raise Error('dirmd failed: ' + dirmd.stderr.read())
  json_out = json.load(dirmd.stdout)
  if sys.platform == 'win32':
    subpath = subpath.replace('\\', '/')
  return _ComponentFromDirmd(json_out, subpath)
def _ExtractComponentViaDirmd ( path ) : root_path = os . path . abspath ( os . path . join ( * DIR_ABOVE_TOOLS ) ) path = os . path . abspath ( path ) if not path . startswith ( root_path ) : raise Error ( 'Path {} is not a subpath of the root path {}.' . format ( path , root_path ) ) subpath = path [ len ( root_path ) + 1 : ] or '.' dirmd_exe = 'dirmd' if sys . platform == 'win32' : dirmd_exe = 'dirmd.bat' dirmd_path = os . path . join ( * ( DIR_ABOVE_TOOLS + [ 'third_party' , 'depot_tools' , dirmd_exe ] ) ) dirmd_command = [ dirmd_path , 'read' , '-form' , 'sparse' , root_path , path ] dirmd = subprocess . Popen ( dirmd_command , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) if dirmd . wait ( ) != 0 : raise Error ( 'dirmd failed: ' + dirmd . stderr . read ( ) ) json_out = json . load ( dirmd . stdout ) if sys . platform == 'win32' : subpath = subpath . replace ( '\\' , '/' ) return _ComponentFromDirmd ( json_out , subpath )
Returns the component for monorail issues at the given path.
Returns the component for monorail issues at the given path .
"""Returns the component for monorail issues at the given path.

  Examples are 'Blink>Storage>FileAPI' and 'UI'.

  Uses dirmd in third_party/depot_tools to parse metadata and walk parent
  directories up to the top level of the repo.

  Returns an empty string if no component can be extracted.

  Args:
    path: The path to a directory to query, e.g. 'src/storage'.
  """ # Verify that the paths are absolute and the root is a parent of the # passed in path. # E.g. content/public. # On Windows, dirmd output still uses Unix path separators.
path
The path to a directory to query, e.g. 'src/storage'.
The path to a directory to query e . g . ' src / storage ' .