docstamp/file_utils.py
def replace_file_content(filepath, old, new, max=1):
    """ Modify the content of `filepath`, replacing `old` for `new`.

    Parameters
    ----------
    filepath: str
        Path to the file to be modified. It will be overwritten.

    old: str
        This is old substring to be replaced.

    new: str
        This is new substring, which would replace old substring.

    max: int
        If larger than 0, Only the first `max` occurrences are replaced.
    """
    with open(filepath, 'r') as f:
        content = f.read()

    content = content.replace(old, new, max)
    with open(filepath, 'w') as f:
        f.write(content)
def replace_file_content(filepath, old, new, max=1):
    with open(filepath, 'r') as f:
        content = f.read()

    content = content.replace(old, new, max)
    with open(filepath, 'w') as f:
        f.write(content)
def replace_file_content ( filepath , old , new , max = 1 ) : with open ( filepath , 'r' ) as f : content = f . read ( ) content = content . replace ( old , new , max ) with open ( filepath , 'w' ) as f : f . write ( content )
Modify the content of `filepath`, replacing `old` for `new`.

    Parameters
    ----------
    filepath: str
        Path to the file to be modified. It will be overwritten.

    old: str
        This is old substring to be replaced.

    new: str
        This is new substring, which would replace old substring.

    max: int
        If larger than 0, Only the first `max` occurrences are replaced.
Modify the content of filepath replacing old for new .