Compare commits
	
		
			14 Commits
		
	
	
		
			3213e8a21f
			...
			main
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 9040b26279 | ||
|  | 98d656b2fe | ||
|  | abadff31d8 | ||
|  | ba36851336 | ||
|  | d9e6bac410 | ||
|  | 69f6a11874 | ||
|  | 8e8409afc4 | ||
| fd51a0625f | |||
| 2162cf78cd | |||
| 8036dc33b3 | |||
|  | d968795628 | ||
|  | 05f7003ea8 | ||
| 3a7b46219e | |||
|  | ad1aff0438 | 
							
								
								
									
										4
									
								
								generate
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								generate
									
									
									
									
									
								
							| @@ -1,10 +1,10 @@ | |||||||
| #!/home/fname/Projects/OpenSource/python-mommy-venv/.venv/bin/python3 | #!.venv/bin/python3 | ||||||
| import requests | import requests | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| import json | import json | ||||||
|  |  | ||||||
|  |  | ||||||
| CARGO_MOMMY_DATA = "https://raw.githubusercontent.com/diamondburned/go-mommy/refs/heads/main/responses.json" | CARGO_MOMMY_DATA = "https://raw.githubusercontent.com/Gankra/cargo-mommy/refs/heads/main/responses.json" | ||||||
| MODULE_PATH = Path("python_mommy_venv") | MODULE_PATH = Path("python_mommy_venv") | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ version = "0.0.0" | |||||||
| license-files = ["LICENSE"] | license-files = ["LICENSE"] | ||||||
|  |  | ||||||
| [project.scripts] | [project.scripts] | ||||||
| python-mommy-dev = "python_mommy_venv.__main__:development" | mommify-venv-compile = "python_mommy_venv.__main__:cli_compile_config" | ||||||
| mommify-venv = "python_mommy_venv.__main__:mommify_venv" | mommify-venv = "python_mommy_venv.__main__:mommify_venv" | ||||||
|  |  | ||||||
| [build-system] | [build-system] | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import argparse | |||||||
|  |  | ||||||
| from .responses import compile_config | from .responses import compile_config | ||||||
| from .static import IS_VENV, VENV_DIRECTORY, CONFIG_DIRECTORY, COMPILED_CONFIG_FILE_NAME | from .static import IS_VENV, VENV_DIRECTORY, CONFIG_DIRECTORY, COMPILED_CONFIG_FILE_NAME | ||||||
|  | from ntpath import devnull | ||||||
|  |  | ||||||
| logging.basicConfig( | logging.basicConfig( | ||||||
|     format='%(message)s', |     format='%(message)s', | ||||||
| @@ -19,7 +20,7 @@ log_level = logging.INFO | |||||||
| mommy_logger = logging.getLogger("mommy") | mommy_logger = logging.getLogger("mommy") | ||||||
| mommy_logger.setLevel(logging.INFO) | mommy_logger.setLevel(logging.INFO) | ||||||
| serious_logger = logging.getLogger("serious") | serious_logger = logging.getLogger("serious") | ||||||
| serious_logger.setLevel(logging.WARNING) | serious_logger.setLevel(50) | ||||||
|  |  | ||||||
|  |  | ||||||
| def config_logging(verbose: bool): | def config_logging(verbose: bool): | ||||||
| @@ -29,18 +30,10 @@ def config_logging(verbose: bool): | |||||||
|             force=True, |             force=True, | ||||||
|         ) |         ) | ||||||
|         logging.getLogger().setLevel(logging.DEBUG) |         logging.getLogger().setLevel(logging.DEBUG) | ||||||
|         mommy_logger.setLevel(logging.ERROR) |         mommy_logger.setLevel(50) | ||||||
|         serious_logger.setLevel(logging.DEBUG) |         serious_logger.setLevel(logging.DEBUG) | ||||||
|  |  | ||||||
|  |  | ||||||
| def development(): |  | ||||||
|     s = "positive" |  | ||||||
|     if len(sys.argv) > 1: |  | ||||||
|         s = sys.argv[1] |  | ||||||
|  |  | ||||||
|     compile_config() |  | ||||||
|      |  | ||||||
|  |  | ||||||
| WRAPPER_TEMPLATE = """#!{inner_bin} | WRAPPER_TEMPLATE = """#!{inner_bin} | ||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
|  |  | ||||||
| @@ -93,19 +86,34 @@ PIP_HOOK = """# GENERATED BY MOMMY | |||||||
|     sys.exit(code)""" |     sys.exit(code)""" | ||||||
|  |  | ||||||
|  |  | ||||||
| def assert_venv(): | def assert_venv(only_warn: bool = False): | ||||||
|     if not IS_VENV: |     if not IS_VENV: | ||||||
|         mommy_logger.error("mommy doesn't run in a virtual environment~") |         mommy_logger.error("mommy doesn't run in a virtual environment~") | ||||||
|         serious_logger.error("this has to run in a virtual environment") |         serious_logger.error("this should run in a virtual environment") | ||||||
|  |         if not only_warn: | ||||||
|             exit(1) |             exit(1) | ||||||
|  |  | ||||||
|  |  | ||||||
| def wrap_interpreter(path: Path): | def write_compile_config(local: bool, disable_requests: bool = False): | ||||||
|  |     assert_venv(only_warn=not local) | ||||||
|  |  | ||||||
|  |     compiled_base_dir = VENV_DIRECTORY if local else CONFIG_DIRECTORY | ||||||
|  |     compiled_config_file = compiled_base_dir / COMPILED_CONFIG_FILE_NAME | ||||||
|  |     compiled = compile_config(disable_requests=disable_requests) | ||||||
|  |     mommy_logger.info("mommy writes its moods in %s", compiled_config_file) | ||||||
|  |     serious_logger.info("writing compiled config file to %s", compiled_config_file) | ||||||
|  |     compiled_base_dir.mkdir(parents=True, exist_ok=True) | ||||||
|  |     with compiled_config_file.open("w") as f: | ||||||
|  |         json.dump(compiled, f, indent=4) | ||||||
|  |     if not local: | ||||||
|  |         (VENV_DIRECTORY / COMPILED_CONFIG_FILE_NAME).unlink(missing_ok=True) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def wrap_interpreter(path: Path, symlink_target: Path): | ||||||
|     mommy_logger.info("mommy found a symlink to an interpreter~ %s", str(path)) |     mommy_logger.info("mommy found a symlink to an interpreter~ %s", str(path)) | ||||||
|     serious_logger.info("interpreter symlink found at %s", str(path)) |     serious_logger.info("interpreter symlink found at %s", str(path)) | ||||||
|  |  | ||||||
|     inner_symlink = path.parent / ("inner_" + path.name) |     inner_symlink = path.parent / ("inner_" + path.name) | ||||||
|     symlink_target = path.resolve() |  | ||||||
|  |  | ||||||
|     if inner_symlink.exists(): |     if inner_symlink.exists(): | ||||||
|         raise Exception("inner symlink somehow already exists. This shouldn't happen because of prior checks") |         raise Exception("inner symlink somehow already exists. This shouldn't happen because of prior checks") | ||||||
| @@ -146,6 +154,33 @@ def install_pip_hook(path: Path): | |||||||
|         f.write(text) |         f.write(text) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def cli_compile_config(): | ||||||
|  |     parser = argparse.ArgumentParser(description="only recompile the config") | ||||||
|  |  | ||||||
|  |     parser.add_argument( | ||||||
|  |         "-v", "--verbose", | ||||||
|  |         action="store_true", | ||||||
|  |         help="enable verbose and serious output" | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  |     parser.add_argument( | ||||||
|  |         "-l", "--local", | ||||||
|  |         action="store_true", | ||||||
|  |         help="compile the config only for the current virtual environment" | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  |     parser.add_argument( | ||||||
|  |         "-r", "--no-requests", | ||||||
|  |         action="store_true", | ||||||
|  |         help="by default if makes one request to GitHub to fetch the newest responses, this disables that" | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  |     args = parser.parse_args() | ||||||
|  |  | ||||||
|  |     config_logging(args.verbose) | ||||||
|  |     write_compile_config(args.local, disable_requests=args.no_requests) | ||||||
|  |  | ||||||
|  |  | ||||||
| def mommify_venv(): | def mommify_venv(): | ||||||
|     parser = argparse.ArgumentParser(description="patch the virtual environment to use mommy") |     parser = argparse.ArgumentParser(description="patch the virtual environment to use mommy") | ||||||
|  |  | ||||||
| @@ -161,21 +196,18 @@ def mommify_venv(): | |||||||
|         help="compile the config only for the current virtual environment" |         help="compile the config only for the current virtual environment" | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|  |     parser.add_argument( | ||||||
|  |         "-r", "--no-requests", | ||||||
|  |         action="store_true", | ||||||
|  |         help="by default if makes one request to GitHub to fetch the newest responses, this disables that" | ||||||
|  |     ) | ||||||
|  |  | ||||||
|     args = parser.parse_args() |     args = parser.parse_args() | ||||||
|  |  | ||||||
|     config_logging(args.verbose) |     config_logging(args.verbose) | ||||||
|     assert_venv() |     assert_venv() | ||||||
|  |  | ||||||
|     compiled_base_dir = VENV_DIRECTORY if args.local else CONFIG_DIRECTORY |     write_compile_config(args.local) | ||||||
|     compiled_config_file = compiled_base_dir / COMPILED_CONFIG_FILE_NAME |  | ||||||
|     compiled = compile_config() |  | ||||||
|     mommy_logger.info("mommy writes its moods in %s", compiled_config_file) |  | ||||||
|     serious_logger.info("writing compiled config file to %s", compiled_config_file) |  | ||||||
|     compiled_base_dir.mkdir(parents=True, exist_ok=True) |  | ||||||
|     with compiled_config_file.open("w") as f: |  | ||||||
|         json.dump(compiled, f, indent=4) |  | ||||||
|     if not args.local: |  | ||||||
|         (VENV_DIRECTORY / COMPILED_CONFIG_FILE_NAME).unlink(missing_ok=True) |  | ||||||
|  |  | ||||||
|     mommy_logger.info("") |     mommy_logger.info("") | ||||||
|  |  | ||||||
| @@ -185,6 +217,18 @@ def mommify_venv(): | |||||||
|     mommy_logger.info("mommy looks in %s to mess your system up~ <33", str(bin_path)) |     mommy_logger.info("mommy looks in %s to mess your system up~ <33", str(bin_path)) | ||||||
|     serious_logger.info("scanning binary directory of venv at %s", str(bin_path)) |     serious_logger.info("scanning binary directory of venv at %s", str(bin_path)) | ||||||
|  |  | ||||||
|  |     # resolving the symlinks before making edits to anything because else it will mess up the resolving | ||||||
|  |     # and link to the wrapper instead of the original script | ||||||
|  |     resolved_symlinks = { | ||||||
|  |         path.name: path.resolve() | ||||||
|  |         for path in bin_path.iterdir() | ||||||
|  |         if path.is_symlink() | ||||||
|  |     } | ||||||
|  |     serious_logger.debug("resolved symlinks:\n%s", "\n".join( | ||||||
|  |         f"\t{name} => {str(target)}" | ||||||
|  |         for name, target in resolved_symlinks.items() | ||||||
|  |     )) | ||||||
|  |  | ||||||
|     for path in list(bin_path.iterdir()): |     for path in list(bin_path.iterdir()): | ||||||
|         name = path.name |         name = path.name | ||||||
|  |  | ||||||
| @@ -194,10 +238,11 @@ def mommify_venv(): | |||||||
|             if name.startswith("inner_"): |             if name.startswith("inner_"): | ||||||
|                 continue |                 continue | ||||||
|              |              | ||||||
|             if subprocess.run([str(path), '-c', '"exit(0)"']).returncode != 0: |             RANDOM_RETURNCODE = 161 | ||||||
|  |             if subprocess.run([str(path), '-c', f'exit({RANDOM_RETURNCODE})']).returncode != RANDOM_RETURNCODE: | ||||||
|                 continue |                 continue | ||||||
|  |  | ||||||
|             wrap_interpreter(path) |             wrap_interpreter(path, resolved_symlinks[path.name]) | ||||||
|  |  | ||||||
|         else: |         else: | ||||||
|             # could be pip |             # could be pip | ||||||
|   | |||||||
| @@ -17,6 +17,8 @@ | |||||||
|                 "well done~!\n{role} is so happy for you~", |                 "well done~!\n{role} is so happy for you~", | ||||||
|                 "what a good {affectionate_term} you are~", |                 "what a good {affectionate_term} you are~", | ||||||
|                 "that's {role}'s clever little {affectionate_term}~", |                 "that's {role}'s clever little {affectionate_term}~", | ||||||
|  |                 "you're doing so well~!", | ||||||
|  |                 "you're making {role} so happy~", | ||||||
|                 "{role} loves {pronoun} cute little {affectionate_term}~" |                 "{role} loves {pronoun} cute little {affectionate_term}~" | ||||||
|             ], |             ], | ||||||
|             "negative": [ |             "negative": [ | ||||||
| @@ -24,6 +26,7 @@ | |||||||
|                 "don't forget to hydrate~", |                 "don't forget to hydrate~", | ||||||
|                 "aww, you'll get it next time~", |                 "aww, you'll get it next time~", | ||||||
|                 "do you need {role}'s help~?", |                 "do you need {role}'s help~?", | ||||||
|  |                 "everything's gonna be ok~", | ||||||
|                 "{role} still loves you no matter what~", |                 "{role} still loves you no matter what~", | ||||||
|                 "oh no did {role}'s little {affectionate_term} make a big mess~?", |                 "oh no did {role}'s little {affectionate_term} make a big mess~?", | ||||||
|                 "{role} knows {pronoun} little {affectionate_term} can do better~", |                 "{role} knows {pronoun} little {affectionate_term} can do better~", | ||||||
| @@ -33,7 +36,26 @@ | |||||||
|                 "oh, darling, you're almost there~", |                 "oh, darling, you're almost there~", | ||||||
|                 "does {role}'s little {affectionate_term} need a bit of a break~?", |                 "does {role}'s little {affectionate_term} need a bit of a break~?", | ||||||
|                 "oops~! {role} loves you anyways~", |                 "oops~! {role} loves you anyways~", | ||||||
|  |                 "try again for {role}, {affectionate_term}~", | ||||||
|                 "don't worry, {role} knows you can do it~" |                 "don't worry, {role} knows you can do it~" | ||||||
|  |             ], | ||||||
|  |             "overflow": [ | ||||||
|  |                 "{role} has executed too many times and needs to take a nap~" | ||||||
|  |             ] | ||||||
|  |         }, | ||||||
|  |         "ominous": { | ||||||
|  |             "positive": [ | ||||||
|  |                 "What you have set in motion today will be remembered for aeons to come!", | ||||||
|  |                 "{role} will see to it that {pronoun} little {affectionate_term}'s name is feared~", | ||||||
|  |                 "{role} is proud of the evil seed {pronoun} {affectionate_term} has planted into this accursed world" | ||||||
|  |             ], | ||||||
|  |             "negative": [ | ||||||
|  |                 "Ah, failure? {role} will make sure the stars are right next time", | ||||||
|  |                 "Does {role}'s little {affectionate_term} need more time for worship~?", | ||||||
|  |                 "May the mark of the beast stain your flesh forever, {role} will haunt your soul forevermore" | ||||||
|  |             ], | ||||||
|  |             "overflow": [ | ||||||
|  |                 "THOU HAST DRUNK TOO DEEPLY OF THE FONT" | ||||||
|             ] |             ] | ||||||
|         }, |         }, | ||||||
|         "thirsty": { |         "thirsty": { | ||||||
| @@ -46,10 +68,11 @@ | |||||||
|                 "*pats your butt*\nthat's a good {affectionate_term}~", |                 "*pats your butt*\nthat's a good {affectionate_term}~", | ||||||
|                 "*drags {pronoun} nail along your cheek*\nsuch a good {affectionate_term}~", |                 "*drags {pronoun} nail along your cheek*\nsuch a good {affectionate_term}~", | ||||||
|                 "*bites {pronoun} lip*\nmhmm~", |                 "*bites {pronoun} lip*\nmhmm~", | ||||||
|                 "give {pronoun} a kiss~", |                 "give {role} a kiss~", | ||||||
|                 "*heavy breathing against your neck*" |                 "*heavy breathing against your neck*" | ||||||
|             ], |             ], | ||||||
|             "negative": [ |             "negative": [ | ||||||
|  |                 "you're so cute when you're flustered~", | ||||||
|                 "do you think you're going to get a reward from {role} like that~?", |                 "do you think you're going to get a reward from {role} like that~?", | ||||||
|                 "*grabs your hair and pulls your head back*\nyou can do better than that for {role} can't you~?", |                 "*grabs your hair and pulls your head back*\nyou can do better than that for {role} can't you~?", | ||||||
|                 "if you don't learn how to code better, {role} is going to put you in time-out~", |                 "if you don't learn how to code better, {role} is going to put you in time-out~", | ||||||
| @@ -58,6 +81,9 @@ | |||||||
|                 "gosh you must be flustered~", |                 "gosh you must be flustered~", | ||||||
|                 "are you just keysmashing now~?\ncute~", |                 "are you just keysmashing now~?\ncute~", | ||||||
|                 "is {role}'s little {affectionate_term} having trouble reaching the keyboard~?" |                 "is {role}'s little {affectionate_term} having trouble reaching the keyboard~?" | ||||||
|  |             ], | ||||||
|  |             "overflow": [ | ||||||
|  |                 "you've been a bad little {affectionate_term} and worn out {role}~" | ||||||
|             ] |             ] | ||||||
|         }, |         }, | ||||||
|         "yikes": { |         "yikes": { | ||||||
| @@ -71,7 +97,10 @@ | |||||||
|                 "{role} is getting hot~", |                 "{role} is getting hot~", | ||||||
|                 "that's a good {denigrating_term}~", |                 "that's a good {denigrating_term}~", | ||||||
|                 "yes~\nyes~~\nyes~~~", |                 "yes~\nyes~~\nyes~~~", | ||||||
|                 "{role}'s going to keep {pronoun} good little {denigrating_term}~" |                 "{role}'s going to keep {pronoun} good little {denigrating_term}~", | ||||||
|  |                 "open wide {denigrating_term}.\nyou've earned {role}'s {part}~", | ||||||
|  |                 "do you want {role}'s {part}?\nkeep this up and you'll earn it~", | ||||||
|  |                 "oooh~ what a good {denigrating_term} you are~" | ||||||
|             ], |             ], | ||||||
|             "negative": [ |             "negative": [ | ||||||
|                 "you filthy {denigrating_term}~\nyou made a mess, now clean it up~\nwith your tongue~", |                 "you filthy {denigrating_term}~\nyou made a mess, now clean it up~\nwith your tongue~", | ||||||
| @@ -83,7 +112,14 @@ | |||||||
|                 "{role} doesn't think {pronoun} little {denigrating_term} should have permission to wear clothes anymore~", |                 "{role} doesn't think {pronoun} little {denigrating_term} should have permission to wear clothes anymore~", | ||||||
|                 "never forget you belong to {role}~", |                 "never forget you belong to {role}~", | ||||||
|                 "does {role} need to put you in the {denigrating_term} wiggler~?", |                 "does {role} need to put you in the {denigrating_term} wiggler~?", | ||||||
|                 "{role} is starting to wonder if you should just give up and become {pronoun} breeding stock~" |                 "{role} is starting to wonder if you should just give up and become {pronoun} breeding stock~", | ||||||
|  |                 "on your knees {denigrating_term}~", | ||||||
|  |                 "oh dear. {role} is not pleased", | ||||||
|  |                 "one spank per error sounds appropriate, don't you think {denigrating_term}?", | ||||||
|  |                 "no more {part} for you {denigrating_term}" | ||||||
|  |             ], | ||||||
|  |             "overflow": [ | ||||||
|  |                 "brats like you don't get to talk to {role}" | ||||||
|             ] |             ] | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
| @@ -108,9 +144,7 @@ | |||||||
|             ] |             ] | ||||||
|         }, |         }, | ||||||
|         "role": { |         "role": { | ||||||
|             "defaults": [ |             "defaults": [] | ||||||
|                 "mommy" |  | ||||||
|             ] |  | ||||||
|         }, |         }, | ||||||
|         "affectionate_term": { |         "affectionate_term": { | ||||||
|             "defaults": [ |             "defaults": [ | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ serious_logger = logging.getLogger("serious") | |||||||
|  |  | ||||||
| PREFIX = "MOMMY" | PREFIX = "MOMMY" | ||||||
|  |  | ||||||
| RESPONSES_URL = "https://raw.githubusercontent.com/diamondburned/go-mommy/refs/heads/main/responses.json" | RESPONSES_URL = "https://raw.githubusercontent.com/Gankra/cargo-mommy/refs/heads/main/responses.json" | ||||||
| RESPONSES_FILE = Path(__file__).parent / "responses.json" | RESPONSES_FILE = Path(__file__).parent / "responses.json" | ||||||
| ADDITIONAL_ENV_VARS = { | ADDITIONAL_ENV_VARS = { | ||||||
|     "pronoun": "PRONOUNS", |     "pronoun": "PRONOUNS", | ||||||
| @@ -25,7 +25,7 @@ ADDITIONAL_ENV_VARS = { | |||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def _load_config_file(config_file: Path) -> Dict[str, List[str]]: | def _load_config_file(config_file: Path) -> dict: | ||||||
|     with config_file.open("r") as f: |     with config_file.open("r") as f: | ||||||
|         data = toml.load(f) |         data = toml.load(f) | ||||||
|  |  | ||||||
| @@ -71,8 +71,12 @@ def compile_config(disable_requests: bool = False) -> dict: | |||||||
|     if not disable_requests: |     if not disable_requests: | ||||||
|         mommy_logger.info("mommy downloads newest responses for her girl~ %s", RESPONSES_URL) |         mommy_logger.info("mommy downloads newest responses for her girl~ %s", RESPONSES_URL) | ||||||
|         serious_logger.info("downloading cargo mommy responses: %s", RESPONSES_URL) |         serious_logger.info("downloading cargo mommy responses: %s", RESPONSES_URL) | ||||||
|  |         try: | ||||||
|             r = requests.get(RESPONSES_URL) |             r = requests.get(RESPONSES_URL) | ||||||
|             data = r.json() |             data = r.json() | ||||||
|  |         except requests.exceptions.ConnectionError: | ||||||
|  |             mommy_logger.info("mommy couldn't fetch the url~") | ||||||
|  |             serious_logger.info("couldnt fetch the url") | ||||||
|  |  | ||||||
|     config_definition: Dict[str, dict] = data["vars"] |     config_definition: Dict[str, dict] = data["vars"] | ||||||
|     mood_definitions: Dict[str, dict] = data["moods"] |     mood_definitions: Dict[str, dict] = data["moods"] | ||||||
| @@ -91,7 +95,22 @@ def compile_config(disable_requests: bool = False) -> dict: | |||||||
|     # load config file |     # load config file | ||||||
|     config_file = get_config_file() |     config_file = get_config_file() | ||||||
|     if config_file is not None: |     if config_file is not None: | ||||||
|         config.update(_load_config_file(config_file)) |         c = _load_config_file(config_file) | ||||||
|  |         serious_logger.debug( | ||||||
|  |             "config at %s:\n%s\n", | ||||||
|  |             config_file, | ||||||
|  |             json.dumps(c, indent=4) | ||||||
|  |         ) | ||||||
|  |  | ||||||
|  |         config["mood"] = c.get("moods", config["mood"]) | ||||||
|  |         c_vars: dict = c.get("vars", {}) | ||||||
|  |         # validate the config var values | ||||||
|  |         for key, val in c_vars.items(): | ||||||
|  |             if not isinstance(val, list): | ||||||
|  |                 mommy_logger.error("mommy needs the value of %s to be a list~", key) | ||||||
|  |                 serious_logger.error("the value of %s is not a list", key) | ||||||
|  |                 exit(1) | ||||||
|  |         config.update(c_vars) | ||||||
|  |  | ||||||
|     # fill config with env |     # fill config with env | ||||||
|     for key, conf in config_definition.items(): |     for key, conf in config_definition.items(): | ||||||
| @@ -99,6 +118,23 @@ def compile_config(disable_requests: bool = False) -> dict: | |||||||
|         if val is not None: |         if val is not None: | ||||||
|             config[key] = val.split("/") |             config[key] = val.split("/") | ||||||
|  |  | ||||||
|  |     # validate empty variables | ||||||
|  |     empty_values = [] | ||||||
|  |     for key, value in config.items(): | ||||||
|  |         if len(value) == 0: | ||||||
|  |             empty_values.append(key) | ||||||
|  |     if len(empty_values) > 0: | ||||||
|  |         empty_values_sting = ", ".join(empty_values) | ||||||
|  |         mommy_logger.error( | ||||||
|  |             "mommy is very displeased that you didn't config the key(s) %s", | ||||||
|  |             empty_values_sting, | ||||||
|  |         ) | ||||||
|  |         serious_logger.error( | ||||||
|  |             "the following keys have empty values and need to be configured: %s", | ||||||
|  |             empty_values_sting | ||||||
|  |         ) | ||||||
|  |         exit(1) | ||||||
|  |  | ||||||
|     # validate moods |     # validate moods | ||||||
|     for mood in config["mood"]: |     for mood in config["mood"]: | ||||||
|         if mood not in mood_definitions: |         if mood not in mood_definitions: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user