mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
feat(common): provide some useful paths for the mako templates
This commit is contained in:
parent
03298ca80f
commit
9c72c7c99d
@ -25,6 +25,9 @@ DEFINITIONS_LATEST_URL = (
|
||||
"https://raw.githubusercontent.com/trezor/definitions/main/definitions-latest.json"
|
||||
)
|
||||
|
||||
HERE = Path(__file__).parent.resolve()
|
||||
ROOT = HERE.parent.parent
|
||||
|
||||
try:
|
||||
import termcolor
|
||||
except ImportError:
|
||||
@ -148,10 +151,13 @@ def render_file(
|
||||
eth_defs_date = datetime.datetime.fromisoformat(
|
||||
DEFINITIONS_TIMESTAMP_PATH.read_text().strip()
|
||||
)
|
||||
this_file = Path(src)
|
||||
result = template.render(
|
||||
support_info=support_info,
|
||||
supported_on=make_support_filter(support_info),
|
||||
ethereum_defs_timestamp=int(eth_defs_date.timestamp()),
|
||||
THIS_FILE=this_file,
|
||||
ROOT=ROOT,
|
||||
**coins,
|
||||
**MAKO_FILTERS,
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// generated from librust_qstr.h.mako
|
||||
// generated from ${THIS_FILE.name}
|
||||
// (by running `make templates` in `core`)
|
||||
// do not edit manually!
|
||||
#pragma GCC diagnostic ignored "-Wunused-value"
|
||||
@ -11,9 +11,7 @@ import sys
|
||||
from pathlib import Path
|
||||
from typing import Union, Set
|
||||
|
||||
THIS = Path(local.filename).resolve()
|
||||
HERE = THIS.parent
|
||||
RUST_SRC = HERE / "src"
|
||||
RUST_SRC = THIS_FILE.parent / "src"
|
||||
|
||||
def find_unique_patterns_in_dir(directory: Union[str, Path], pattern: str) -> Set[str]:
|
||||
command = f"grep -ro '{pattern}' {directory}"
|
||||
|
@ -1,14 +1,10 @@
|
||||
# generated from trezortranslate_keys.pyi.mako
|
||||
# generated from ${THIS_FILE.name}
|
||||
# (by running `make templates` in `core`)
|
||||
# do not edit manually!
|
||||
<%
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
THIS = Path(local.filename).resolve()
|
||||
CORE_DIR = THIS.parent.parent
|
||||
|
||||
en_file = CORE_DIR / "embed" / "rust" / "src" / "translations" / "en.json"
|
||||
en_file = ROOT / "core" / "translations" / "en.json"
|
||||
en_data = json.loads(en_file.read_text())["translations"]
|
||||
|
||||
%>\
|
||||
|
@ -1,15 +1,13 @@
|
||||
# generated from all_modules.py.mako
|
||||
# generated from ${THIS_FILE.name}
|
||||
# (by running `make templates` in `core`)
|
||||
# do not edit manually!
|
||||
# flake8: noqa
|
||||
# fmt: off
|
||||
# isort:skip_file
|
||||
<%
|
||||
from pathlib import Path
|
||||
from itertools import chain
|
||||
|
||||
THIS = Path(local.filename).resolve()
|
||||
SRCDIR = THIS.parent
|
||||
SRCDIR = THIS_FILE.parent
|
||||
|
||||
PATTERNS = (
|
||||
"*.py",
|
||||
|
Loading…
Reference in New Issue
Block a user