dotfiles/common/dump.py

17 lines
515 B
Python
Raw Normal View History

2024-08-08 12:28:10 +02:00
from glob import glob
import shutil
2024-08-08 12:31:06 +02:00
import os
2024-08-08 12:28:10 +02:00
def dump(stuff: list[str]):
for pattern in stuff:
2024-08-08 12:31:06 +02:00
expand = os.path.expanduser(pattern)
2024-08-08 12:28:10 +02:00
for path in glob(expand, recursive=True):
2024-08-08 12:31:06 +02:00
normalized_path = path.removeprefix(os.path.expanduser("~/"))
if os.path.isdir(normalized_path) and not os.path.exists(normalized_path):
os.mkdir(normalized_path)
elif os.path.isfile(normalized_path):
2024-08-08 12:28:10 +02:00
shutil.copy2(path, normalized_path)
2024-08-07 22:46:13 +02:00
exit(1)