-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
62 lines (47 loc) · 1.92 KB
/
Copy pathsetup.py
File metadata and controls
62 lines (47 loc) · 1.92 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# setup.py
#
# A lancer une seule fois, juste apres avoir clone le projet :
# python setup.py
#
# Ce script cree config_local.py de maniere interactive et verifie
# que la structure de dossiers de donnees existe.
import shutil
from pathlib import Path
ROOT = Path(__file__).resolve().parent
TEMPLATE = ROOT / "config_template.py"
LOCAL = ROOT / "config_local.py"
def main():
print("=== Installation du projet ===\n")
if LOCAL.exists():
print(f"'{LOCAL.name}' existe deja, rien a faire.")
else:
if not TEMPLATE.exists():
print(f"[ERREUR] '{TEMPLATE.name}' introuvable. Verifie que tu es "
f"bien a la racine du projet.")
return
print("Ou se trouve le dossier racine des donnees (PCRI) sur ta machine ?")
print(r"Exemple Windows : C:/Users/toto/OneDrive/PCRI/")
print(r"Exemple Mac/Linux : /Users/toto/OneDrive/PCRI/")
user_path = input("> Chemin : ").strip()
if not user_path:
print("Chemin vide, installation annulee.")
return
if not user_path.endswith("/"):
user_path += "/"
shutil.copy(TEMPLATE, LOCAL)
content = LOCAL.read_text(encoding="utf-8")
content = content.replace('PATH = "CHANGE_ME"', f'PATH = "{user_path}"')
LOCAL.write_text(content, encoding="utf-8")
print(f"\n'{LOCAL.name}' cree avec PATH = {user_path}")
# Import differe pour que config_local existe deja au moment de l'import
import sys
sys.path.insert(0, str(ROOT))
from paths import ensure_folders_exist, check_data_present
print("\nVerification / creation des dossiers...")
ensure_folders_exist()
check_data_present()
print("\n=== Installation terminee ===")
print("Pense a synchroniser/copier les donnees dans le dossier "
"'eCorda_data' si ce n'est pas deja fait (OneDrive, disque partage, etc.)")
if __name__ == "__main__":
main()