Przeglądaj źródła

Read data sources from file instead of hard coding it

jherve 1 miesiąc temu
rodzic
commit
717e22eded
1 zmienionych plików z 6 dodań i 4 usunięć
  1. 6 4
      start.py

+ 6 - 4
start.py

@@ -5,10 +5,11 @@ from pathlib import Path, PurePosixPath
 
 
 is_windows = os.name == "nt"
 is_windows = os.name == "nt"
 
 
-data_sources = [
-    Path.home() / "Documents" / "cv",
-    Path.home() / "Documents" / "formations" / "5_jours"
-]
+
+def read_data_sources(file: Path) -> list[Path]:
+    with open(file) as f:
+        paths = f.readlines()
+        return [Path(p_str.strip()).expanduser() for p_str in paths]
 
 
 
 
 def to_source_path(path: Path):
 def to_source_path(path: Path):
@@ -19,6 +20,7 @@ def to_source_path(path: Path):
 
 
 
 
 def main():
 def main():
+    data_sources = read_data_sources(Path("./data_sources"))
     hostname = socket.gethostname()
     hostname = socket.gethostname()
     container_name = "borgmatic"
     container_name = "borgmatic"
     ssh_auth_sock = os.getenv("SSH_AUTH_SOCK")
     ssh_auth_sock = os.getenv("SSH_AUTH_SOCK")