Compare commits

...

2 Commits

Author SHA1 Message Date
Hazel Noack
3213e8a21f added option for local compile 2025-07-29 12:22:41 +02:00
Hazel Noack
94c585fa7a added verbose option 2025-07-29 12:19:06 +02:00

View File

@ -4,8 +4,8 @@ import stat
import subprocess
import logging
import json
import argparse
from . import get_response
from .responses import compile_config
from .static import IS_VENV, VENV_DIRECTORY, CONFIG_DIRECTORY, COMPILED_CONFIG_FILE_NAME
@ -22,6 +22,17 @@ serious_logger = logging.getLogger("serious")
serious_logger.setLevel(logging.WARNING)
def config_logging(verbose: bool):
if verbose:
logging.basicConfig(
format=logging.BASIC_FORMAT,
force=True,
)
logging.getLogger().setLevel(logging.DEBUG)
mommy_logger.setLevel(logging.ERROR)
serious_logger.setLevel(logging.DEBUG)
def development():
s = "positive"
if len(sys.argv) > 1:
@ -135,22 +146,37 @@ def install_pip_hook(path: Path):
f.write(text)
def mommify_venv():
parser = argparse.ArgumentParser(description="patch the virtual environment to use mommy")
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"
)
args = parser.parse_args()
config_logging(args.verbose)
assert_venv()
compile_local = False
compiled_base_dir = VENV_DIRECTORY if compile_local else CONFIG_DIRECTORY
compiled_base_dir = VENV_DIRECTORY if args.local else CONFIG_DIRECTORY
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)
serious_logger.info("")
mommy_logger.info("")
bin_path = VENV_DIRECTORY / "bin"