-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.py
More file actions
36 lines (28 loc) · 1 KB
/
Copy pathinstall.py
File metadata and controls
36 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import subprocess
import sys
from pathlib import Path
def get_xdg_config_home():
config_home = os.getenv("XDG_CONFIG_HOME", None)
if config_home is not None:
return Path(config_home)
config_home = os.getenv("HOME", None)
if config_home is not None:
return Path(config_home) / Path(".config")
print("$XDG_CONFIG_HOME and $HOME is empty.\nInstallation failed.")
exit(1)
def copy_dir(src: Path, dest: Path):
"""
subprocess is used because dirs_exist_ok option for shutil.copytree()
doesn't available on Python 3.7 or earlier.
"""
print(f"Copying {src} to {dest}")
subprocess.run(["cp", "-r", str(src), str(dest)])
config_home = get_xdg_config_home() if len(sys.argv) != 2 else Path(sys.argv[1])
config_home /= Path("UhhyouPlugins/")
config_home.mkdir(parents=True, exist_ok=True)
style_dir = Path("style")
if not style_dir.exists():
print("style directory doesn't exists.\nInstallation failed.")
exit(1)
copy_dir(style_dir, config_home)