2024-02-13 13:57:53 +03:00
|
|
|
# ruff: noqa
|
2018-03-08 15:56:15 +03:00
|
|
|
import os
|
2022-07-27 01:37:02 +03:00
|
|
|
from collections.abc import Sequence
|
2019-07-08 01:35:09 +03:00
|
|
|
from pathlib import Path
|
2018-03-08 15:56:15 +03:00
|
|
|
|
2023-01-26 11:50:33 +03:00
|
|
|
BASE_DIR = Path(__file__).parent.resolve()
|
2023-01-28 18:10:45 +03:00
|
|
|
PRODUCTION_DOTENVS_DIR = BASE_DIR / ".envs" / ".production"
|
|
|
|
PRODUCTION_DOTENV_FILES = [
|
|
|
|
PRODUCTION_DOTENVS_DIR / ".django",
|
|
|
|
PRODUCTION_DOTENVS_DIR / ".postgres",
|
2018-03-08 15:56:15 +03:00
|
|
|
]
|
2023-01-28 18:10:45 +03:00
|
|
|
DOTENV_FILE = BASE_DIR / ".env"
|
2018-03-08 15:56:15 +03:00
|
|
|
|
|
|
|
|
2018-04-09 01:03:29 +03:00
|
|
|
def merge(
|
2023-01-28 18:10:45 +03:00
|
|
|
output_file: Path,
|
|
|
|
files_to_merge: Sequence[Path],
|
2018-04-09 01:03:29 +03:00
|
|
|
) -> None:
|
2023-01-28 18:10:45 +03:00
|
|
|
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)
|
2018-03-08 15:56:15 +03:00
|
|
|
|
|
|
|
|
2018-04-09 01:03:29 +03:00
|
|
|
if __name__ == "__main__":
|
2023-01-28 18:10:45 +03:00
|
|
|
merge(DOTENV_FILE, PRODUCTION_DOTENV_FILES)
|