third_party/blink/tools/blinkpy/style/main.py
def change_directory(filesystem, checkout_root, paths):
    """Change the working directory to the checkout root, if possible.

    If every path in the paths parameter is below the checkout root (or if
    the paths parameter is empty or None), this method changes the current
    working directory to the checkout root and converts the paths parameter
    as described below.

    This allows the paths being checked to be displayed relative to the
    checkout root, and for path-specific style checks to work as expected.
    Path-specific checks include whether files should be skipped, whether
    custom style rules should apply to certain files, etc.

    Args:
        paths: A list of paths to the files that should be checked for style.
            This argument can be None or the empty list if a git commit
            or all changes under the checkout root should be checked.
        checkout_root: The path to the root of the repository.

    Returns:
        A copy of the paths parameter -- possibly converted, as follows.
        If this method changed the current working directory to the
        checkout root, then the list is the paths parameter converted to
        normalized paths relative to the checkout root.
    """
    if paths is not None:
        paths = list(paths)

    if paths:
        # Then try converting all of the paths to paths relative to
        # the checkout root.
        rel_paths = []
        for path in paths:
            rel_path = filesystem.relpath(path, checkout_root)
            if rel_path.startswith(filesystem.pardir):
                # Then the path is not below the checkout root.  Since all
                # paths should be interpreted relative to the same root,
                # do not interpret any of the paths as relative to the
                # checkout root.  Interpret all of them relative to the
                # current working directory, and do not change the current
                # working directory.
                _log.warning(
                    """Path-dependent style checks may not work correctly:

  One of the given paths is outside the repository of the current
  working directory:

    Path: %s
    Checkout root: %s

  Pass only files below the checkout root to ensure correct results.
  See the help documentation for more info.
""", path, checkout_root)

                return paths
            rel_paths.append(rel_path)
        # If we got here, the conversion was successful.
        paths = rel_paths

    _log.debug('Changing to checkout root: ' + checkout_root)
    filesystem.chdir(checkout_root)

    return paths
Change the working directory to the checkout root, if possible.

    If every path in the paths parameter is below the checkout root (or if
    the paths parameter is empty or None), this method changes the current
    working directory to the checkout root and converts the paths parameter
    as described below.

    This allows the paths being checked to be displayed relative to the
    checkout root, and for path-specific style checks to work as expected.
    Path-specific checks include whether files should be skipped, whether
    custom style rules should apply to certain files, etc.

    Args:
        paths: A list of paths to the files that should be checked for style.
            This argument can be None or the empty list if a git commit
            or all changes under the checkout root should be checked.
        checkout_root: The path to the root of the repository.

    Returns:
        A copy of the paths parameter -- possibly converted, as follows.
        If this method changed the current working directory to the
        checkout root, then the list is the paths parameter converted to
        normalized paths relative to the checkout root.
    
Change the working directory to the checkout root, if possible.
If every path in the paths parameter is below the checkout root (or if
the paths parameter is empty or None), this method changes the current
working directory to the checkout root and converts the paths parameter
as described below.

This allows the paths being checked to be displayed relative to the
checkout root, and for path-specific style checks to work as expected.
Path-specific checks include whether files should be skipped, whether
custom style rules should apply to certain files, etc.
Change the working directory to the checkout root if possible . If every path in the paths parameter is below the checkout root ( or if the paths parameter is empty or None ) this method changes the current working directory to the checkout root and converts the paths parameter as described below . This allows the paths being checked to be displayed relative to the checkout root and for path - specific style checks to work as expected . Path - specific checks include whether files should be skipped whether custom style rules should apply to certain files etc .
def change_directory(filesystem, checkout_root, paths):
    if paths is not None:
        paths = list(paths)
    if paths:
        rel_paths = []
        for path in paths:
            rel_path = filesystem.relpath(path, checkout_root)
            if rel_path.startswith(filesystem.pardir):
                _log.warning(
                    """Path-dependent style checks may not work correctly:
  One of the given paths is outside the repository of the current
  working directory:
    Path: %s
    Checkout root: %s
  Pass only files below the checkout root to ensure correct results.
  See the help documentation for more info.
""", path, checkout_root)
                return paths
            rel_paths.append(rel_path)
        paths = rel_paths
    _log.debug('Changing to checkout root: ' + checkout_root)
    filesystem.chdir(checkout_root)
    return paths
def change_directory ( filesystem , checkout_root , paths ) : if paths is not None : paths = list ( paths ) if paths : rel_paths = [ ] for path in paths : rel_path = filesystem . relpath ( path , checkout_root ) if rel_path . startswith ( filesystem . pardir ) : _log . warning ( """Path-dependent style checks may not work correctly:

  One of the given paths is outside the repository of the current
  working directory:

    Path: %s
    Checkout root: %s

  Pass only files below the checkout root to ensure correct results.
  See the help documentation for more info.
""" , path , checkout_root ) return paths rel_paths . append ( rel_path ) paths = rel_paths _log . debug ( 'Changing to checkout root: ' + checkout_root ) filesystem . chdir ( checkout_root ) return paths
Change the working directory to the checkout root, if possible.
Change the working directory to the checkout root if possible .
"""Change the working directory to the checkout root, if possible.

    If every path in the paths parameter is below the checkout root (or if
    the paths parameter is empty or None), this method changes the current
    working directory to the checkout root and converts the paths parameter
    as described below.

    This allows the paths being checked to be displayed relative to the
    checkout root, and for path-specific style checks to work as expected.
    Path-specific checks include whether files should be skipped, whether
    custom style rules should apply to certain files, etc.

    Args:
        paths: A list of paths to the files that should be checked for style.
            This argument can be None or the empty list if a git commit
            or all changes under the checkout root should be checked.
        checkout_root: The path to the root of the repository.

    Returns:
        A copy of the paths parameter -- possibly converted, as follows.
        If this method changed the current working directory to the
        checkout root, then the list is the paths parameter converted to
        normalized paths relative to the checkout root.
    """ # Then try converting all of the paths to paths relative to # the checkout root. # Then the path is not below the checkout root.  Since all # paths should be interpreted relative to the same root, # do not interpret any of the paths as relative to the # checkout root.  Interpret all of them relative to the # current working directory, and do not change the current # working directory. # If we got here, the conversion was successful.
A copy of the paths parameter -- possibly converted, as follows.
If this method changed the current working directory to the
checkout root, then the list is the paths parameter converted to
normalized paths relative to the checkout root.
A copy of the paths parameter -- possibly converted as follows . If this method changed the current working directory to the checkout root then the list is the paths parameter converted to normalized paths relative to the checkout root .
filesystem
checkout_root
The path to the root of the repository.
The path to the root of the repository .
paths
A list of paths to the files that should be checked for style.
This argument can be None or the empty list if a git commit
or all changes under the checkout root should be checked.
A list of paths to the files that should be checked for style . This argument can be None or the empty list if a git commit or all changes under the checkout root should be checked .