Skip to content

Write function to replace given text in all files in a given directory #5

@fhightower

Description

@fhightower

What?

(See issue title)

Why?

This is a common use-case that would be helpful to have.

How?

I recommend writing a function with the following signature:

def directory_replace_text_in_files(directory_path: str, old: str, new: str, *, recursive: bool = False) -> Iterator[str]:
    ...

For the directory path, it would be nice to accept a Pathlib.Path or str. The function should yield file_paths that were updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttime est: 1 hourWe estimate this issue will take 1 hour to complete

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions