move dev script out of module

This commit is contained in:
Izalia Mae 2024-04-02 12:36:06 -04:00
parent 437075e512
commit 7064adb000

View file

@ -7,12 +7,10 @@ import time
from datetime import datetime, timedelta from datetime import datetime, timedelta
from pathlib import Path from pathlib import Path
from relay import __version__, logger as logging
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from typing import Sequence from typing import Sequence
from . import __version__
from . import logger as logging
try: try:
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler from watchdog.events import PatternMatchingEventHandler
@ -22,8 +20,7 @@ except ImportError:
pass pass
SCRIPT = Path(__file__).parent REPO = Path(__file__).parent
REPO = SCRIPT.parent
IGNORE_EXT = { IGNORE_EXT = {
'.py', '.py',
'.pyc' '.pyc'
@ -58,8 +55,8 @@ def cli_lint(path: Path, strict: bool, watch: bool) -> None:
handle_run_watcher([sys.executable, "-m", "relay.dev", "lint", str(path)], wait = True) handle_run_watcher([sys.executable, "-m", "relay.dev", "lint", str(path)], wait = True)
return return
flake8 = [sys.executable, '-m', 'flake8', str(path)] flake8 = [sys.executable, '-m', 'flake8', "dev.py", str(path)]
mypy = [sys.executable, '-m', 'mypy', str(path)] mypy = [sys.executable, '-m', 'mypy', "dev.py", str(path)]
if strict: if strict:
mypy.append('--strict') mypy.append('--strict')
@ -108,7 +105,7 @@ def cli_build():
cmd.append('--console') cmd.append('--console')
# putting the spec path on a different drive than the source dir breaks # putting the spec path on a different drive than the source dir breaks
if str(SCRIPT)[0] == tmp[0]: if str(REPO)[0] == tmp[0]:
cmd.extend(['--specpath', tmp]) cmd.extend(['--specpath', tmp])
else: else:
@ -136,7 +133,7 @@ def handle_run_watcher(*commands: Sequence[str], wait: bool = False):
handler.run_procs() handler.run_procs()
watcher = Observer() watcher = Observer()
watcher.schedule(handler, str(SCRIPT), recursive=True) watcher.schedule(handler, str(REPO), recursive=True)
watcher.start() watcher.start()
try: try:
@ -151,7 +148,6 @@ def handle_run_watcher(*commands: Sequence[str], wait: bool = False):
watcher.join() watcher.join()
class WatchHandler(PatternMatchingEventHandler): class WatchHandler(PatternMatchingEventHandler):
patterns = ['*.py'] patterns = ['*.py']