move hook gen code out of anki/

It's not needed at runtime, and this allows hooks to be updated
even when the code is broken.
This commit is contained in:
Damien Elmes 2020-01-15 09:11:20 +10:00
parent cb14963066
commit c67aefa3ea
6 changed files with 9 additions and 5 deletions

View file

@ -27,7 +27,7 @@ PROTODEPS := $(wildcard ../proto/*.proto)
protoc --proto_path=../proto --python_out=anki --mypy_out=anki $(PROTODEPS)
@touch $@
.build/hooks: tools/genhooks.py anki/hooks_gen.py
.build/hooks: tools/genhooks.py tools/hookslib.py
python tools/genhooks.py
black anki/hooks.py
@touch $@

0
pylib/tools/__init__.py Normal file
View file

View file

@ -11,7 +11,7 @@ To add a new hook:
"""
import os
from anki.hooks_gen import Hook, update_file
from hookslib import Hook, update_file
# Hook/filter list
######################################################################

View file

@ -35,8 +35,8 @@ TSDEPS := $(wildcard ts/src/*.ts)
(cd ts && npm i && npm run build)
@touch $@
.build/hooks: tools/genhooks.py ../pylib/anki/hooks_gen.py
python tools/genhooks.py
.build/hooks: tools/genhooks_gui.py ../pylib/tools/hookslib.py
python tools/genhooks_gui.py
black aqt/gui_hooks.py
@touch $@

View file

@ -6,8 +6,12 @@ See pylib/tools/genhooks.py for more info.
"""
import os
import sys
from anki.hooks_gen import Hook, update_file
pylib = os.path.join(os.path.dirname(__file__), "..", "..", "pylib")
sys.path.append(pylib)
from tools.hookslib import Hook, update_file
# Hook list
######################################################################