MCPcopy Create free account
hub / github.com/LaunchPlatform/beanhub-cli / create_backup

Function create_backup

beanhub_cli/format.py:25–41  ·  view source on GitHub ↗

Create a backup file :param src: path of source file to create backup :param suffix: suffix of backup file :return: the path of backup file

(src: pathlib.Path, suffix: str)

Source from the content-addressed store, hash-verified

23
24
25def create_backup(src: pathlib.Path, suffix: str) -> pathlib.Path:
26 """Create a backup file
27
28 :param src: path of source file to create backup
29 :param suffix: suffix of backup file
30 :return: the path of backup file
31 """
32 conflicts = 0
33 while True:
34 backup_path: pathlib.Path = src.with_name(src.name + suffix)
35 if conflicts > 0:
36 backup_path = backup_path.with_name(f"{backup_path.name}.{conflicts}")
37 if backup_path.exists():
38 conflicts += 1
39 continue
40 shutil.copy2(src, backup_path)
41 return backup_path
42
43
44def file_tree_iterator(

Callers 1

format_beancountFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected