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"
|
"https://raw.githubusercontent.com/trezor/definitions/main/definitions-latest.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
HERE = Path(__file__).parent.resolve()
|
||||||
|
ROOT = HERE.parent.parent
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import termcolor
|
import termcolor
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -148,10 +151,13 @@ def render_file(
|
|||||||
eth_defs_date = datetime.datetime.fromisoformat(
|
eth_defs_date = datetime.datetime.fromisoformat(
|
||||||
DEFINITIONS_TIMESTAMP_PATH.read_text().strip()
|
DEFINITIONS_TIMESTAMP_PATH.read_text().strip()
|
||||||
)
|
)
|
||||||
|
this_file = Path(src)
|
||||||
result = template.render(
|
result = template.render(
|
||||||
support_info=support_info,
|
support_info=support_info,
|
||||||
supported_on=make_support_filter(support_info),
|
supported_on=make_support_filter(support_info),
|
||||||
ethereum_defs_timestamp=int(eth_defs_date.timestamp()),
|
ethereum_defs_timestamp=int(eth_defs_date.timestamp()),
|
||||||
|
THIS_FILE=this_file,
|
||||||
|
ROOT=ROOT,
|
||||||
**coins,
|
**coins,
|
||||||
**MAKO_FILTERS,
|
**MAKO_FILTERS,
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// generated from librust_qstr.h.mako
|
// generated from ${THIS_FILE.name}
|
||||||
// (by running `make templates` in `core`)
|
// (by running `make templates` in `core`)
|
||||||
// do not edit manually!
|
// do not edit manually!
|
||||||
#pragma GCC diagnostic ignored "-Wunused-value"
|
#pragma GCC diagnostic ignored "-Wunused-value"
|
||||||
@ -11,9 +11,7 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union, Set
|
from typing import Union, Set
|
||||||
|
|
||||||
THIS = Path(local.filename).resolve()
|
RUST_SRC = THIS_FILE.parent / "src"
|
||||||
HERE = THIS.parent
|
|
||||||
RUST_SRC = HERE / "src"
|
|
||||||
|
|
||||||
def find_unique_patterns_in_dir(directory: Union[str, Path], pattern: str) -> Set[str]:
|
def find_unique_patterns_in_dir(directory: Union[str, Path], pattern: str) -> Set[str]:
|
||||||
command = f"grep -ro '{pattern}' {directory}"
|
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`)
|
# (by running `make templates` in `core`)
|
||||||
# do not edit manually!
|
# do not edit manually!
|
||||||
<%
|
<%
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
THIS = Path(local.filename).resolve()
|
en_file = ROOT / "core" / "translations" / "en.json"
|
||||||
CORE_DIR = THIS.parent.parent
|
|
||||||
|
|
||||||
en_file = CORE_DIR / "embed" / "rust" / "src" / "translations" / "en.json"
|
|
||||||
en_data = json.loads(en_file.read_text())["translations"]
|
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`)
|
# (by running `make templates` in `core`)
|
||||||
# do not edit manually!
|
# do not edit manually!
|
||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
# fmt: off
|
# fmt: off
|
||||||
# isort:skip_file
|
# isort:skip_file
|
||||||
<%
|
<%
|
||||||
from pathlib import Path
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
THIS = Path(local.filename).resolve()
|
SRCDIR = THIS_FILE.parent
|
||||||
SRCDIR = THIS.parent
|
|
||||||
|
|
||||||
PATTERNS = (
|
PATTERNS = (
|
||||||
"*.py",
|
"*.py",
|
||||||
|
Loading…
Reference in New Issue
Block a user