How to use the astor.code_to_ast.find_py_files function in astor

To help you get started, we’ve selected a few astor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jacktasia / fstringify / fstringify / api.py View on Github external
def fstringify(file_or_path, verbose=False, quiet=False):
    to_use = os.path.abspath(file_or_path)
    if not os.path.exists(to_use):
        print(f"`{file_or_path}` not found")
        sys.exit(1)

    if os.path.isdir(to_use):
        files = astor.code_to_ast.find_py_files(to_use)
    else:
        files = ((os.path.dirname(to_use), os.path.basename(to_use)),)

    fstringify_files(files, verbose=verbose, quiet=quiet)
github ikamensh / flynt / src / flynt / api.py View on Github external
def _resolve_files(files_or_paths) -> List[str]:
    """Resolve relative paths and directory names into a list of absolute paths to python files."""

    files = []
    for file_or_path in files_or_paths:

        abs_path = os.path.abspath(file_or_path)

        if not os.path.exists(abs_path):
            print(f"`{file_or_path}` not found")
            sys.exit(1)

        if os.path.isdir(abs_path):
            for folder, filename in astor.code_to_ast.find_py_files(abs_path):
                files.append(os.path.join(folder, filename))
        else:
            files.append(abs_path)

        files = [f for f in files if all(b not in file_or_path for b in blacklist)]
    return files
github jacktasia / fstringify / fstringify / api.py View on Github external
def fstringify_dir(in_dir):
    files = astor.code_to_ast.find_py_files(in_dir)
    return fstringify_files(files)