dotfiles/common/dump.py
2024-08-08 12:28:10 +02:00

18 lines
490 B
Python

from glob import glob
from os.path import expanduser, isdir
from os import mkdir
from shutil import copy2
import shutil
def dump(stuff: list[str]):
for pattern in stuff:
expand = expanduser(pattern)
for path in glob(expand, recursive=True):
normalized_path = path.removeprefix(expanduser("~/"))
if isdir(normalized_path):
mkdir(normalized_path)
else:
shutil.copy2(path, normalized_path)
exit(1)