aboutsummaryrefslogtreecommitdiff
path: root/src_doit/common.py
diff options
context:
space:
mode:
authorbozo.kopic <bozo@kopic.xyz>2021-07-28 01:43:55 +0200
committerbozo.kopic <bozo@kopic.xyz>2021-07-29 00:01:57 +0200
commit1e874e790c12839695761a654b44fb427149a353 (patch)
tree6942441ac511ec1417b2434b111101fa8d7f7e68 /src_doit/common.py
init
Diffstat (limited to 'src_doit/common.py')
-rw-r--r--src_doit/common.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src_doit/common.py b/src_doit/common.py
new file mode 100644
index 0000000..6697b6e
--- /dev/null
+++ b/src_doit/common.py
@@ -0,0 +1,19 @@
+from pathlib import Path
+import shutil
+
+
+def rm_rf(*paths: Path):
+ for path in paths:
+ if not path.exists():
+ continue
+ if path.is_dir():
+ shutil.rmtree(str(path), ignore_errors=True)
+ else:
+ path.unlink()
+
+
+def cp_r(src: Path, dest: Path):
+ if src.is_dir():
+ shutil.copytree(str(src), str(dest), dirs_exist_ok=True)
+ else:
+ shutil.copy2(str(src), str(dest))