aboutsummaryrefslogtreecommitdiffstats
path: root/merge_production_dotenvs_in_dotenv.py
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-13 17:26:25 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-13 17:26:25 +0100
commitefbbd480ddc62e695123d31c31d233b0df5155bd (patch)
treebc2fb465edd5050d83c97f280b1aac8e023fe3e5 /merge_production_dotenvs_in_dotenv.py
After first pre-commit processing
Diffstat (limited to 'merge_production_dotenvs_in_dotenv.py')
-rw-r--r--merge_production_dotenvs_in_dotenv.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/merge_production_dotenvs_in_dotenv.py b/merge_production_dotenvs_in_dotenv.py
new file mode 100644
index 0000000..c83ed71
--- /dev/null
+++ b/merge_production_dotenvs_in_dotenv.py
@@ -0,0 +1,27 @@
+# ruff: noqa
+import os
+from collections.abc import Sequence
+from pathlib import Path
+
+BASE_DIR = Path(__file__).parent.resolve()
+PRODUCTION_DOTENVS_DIR = BASE_DIR / ".envs" / ".production"
+PRODUCTION_DOTENV_FILES = [
+ PRODUCTION_DOTENVS_DIR / ".django",
+ PRODUCTION_DOTENVS_DIR / ".postgres",
+]
+DOTENV_FILE = BASE_DIR / ".env"
+
+
+def merge(
+ output_file: Path,
+ files_to_merge: Sequence[Path],
+) -> None:
+ merged_content = ""
+ for merge_file in files_to_merge:
+ merged_content += merge_file.read_text()
+ merged_content += os.linesep
+ output_file.write_text(merged_content)
+
+
+if __name__ == "__main__":
+ merge(DOTENV_FILE, PRODUCTION_DOTENV_FILES)