Compare commits
No commits in common. "3213e8a21f2f8b696d6b50218b821a75a0ec7f06" and "a8a1f425ccc0e9def00b98089373ff90a86deb79" have entirely different histories.
3213e8a21f
...
a8a1f425cc
@ -4,8 +4,8 @@ import stat
|
|||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import argparse
|
|
||||||
|
|
||||||
|
from . import get_response
|
||||||
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
|
||||||
|
|
||||||
@ -22,17 +22,6 @@ serious_logger = logging.getLogger("serious")
|
|||||||
serious_logger.setLevel(logging.WARNING)
|
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():
|
def development():
|
||||||
s = "positive"
|
s = "positive"
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
@ -146,37 +135,22 @@ def install_pip_hook(path: Path):
|
|||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def mommify_venv():
|
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()
|
assert_venv()
|
||||||
|
|
||||||
compiled_base_dir = VENV_DIRECTORY if args.local else CONFIG_DIRECTORY
|
compile_local = False
|
||||||
|
compiled_base_dir = VENV_DIRECTORY if compile_local else CONFIG_DIRECTORY
|
||||||
compiled_config_file = compiled_base_dir / COMPILED_CONFIG_FILE_NAME
|
compiled_config_file = compiled_base_dir / COMPILED_CONFIG_FILE_NAME
|
||||||
|
|
||||||
compiled = compile_config()
|
compiled = compile_config()
|
||||||
mommy_logger.info("mommy writes its moods in %s", compiled_config_file)
|
mommy_logger.info("mommy writes its moods in %s", compiled_config_file)
|
||||||
serious_logger.info("writing compiled config file to %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)
|
compiled_base_dir.mkdir(parents=True, exist_ok=True)
|
||||||
with compiled_config_file.open("w") as f:
|
with compiled_config_file.open("w") as f:
|
||||||
json.dump(compiled, f, indent=4)
|
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("")
|
mommy_logger.info("")
|
||||||
|
|
||||||
bin_path = VENV_DIRECTORY / "bin"
|
bin_path = VENV_DIRECTORY / "bin"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user