Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions aiogram_i18n/utils/cli/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def extract(
style(
text="This function is removed. Use FTL-Extract instead.\n"
"pip install ftl-extract\n"
"\n"
"ftl extract <code_path> <output_file> [OPTIONS]\n"
"\n"
"https://pypi.org/project/FTL-Extract/",
fg="red",
),
Expand Down
3 changes: 3 additions & 0 deletions aiogram_i18n/utils/cli/multiple_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def multiple_extract(
style(
text="This function is removed. Use FTL-Extract instead.\n"
"pip install ftl-extract\n"
"\n"
"ftl extract <code_path> <output_file> [OPTIONS]\n"
"\n"
"https://pypi.org/project/FTL-Extract/",
fg="red",
),
Expand Down
48 changes: 13 additions & 35 deletions aiogram_i18n/utils/fluent_stub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
from collections.abc import Sequence
from pathlib import Path

from aiogram_i18n.exceptions import NoModuleError
from aiogram_i18n.utils.stub_tree import Key
from click import echo, style

try:
from fluent.syntax import FluentParser

from aiogram_i18n.utils.fluent_stub.visitor import FluentVisitor
except ImportError:
raise NoModuleError(name="Fluent stub generator", module_name="fluent.syntax") from None

MESSAGES = dict[str, set[str]]


def parse(text: str) -> MESSAGES:
resource = FluentParser().parse(text)
if not resource.body:
msg = "no body"
raise ValueError(msg)

ftl_visitor = FluentVisitor()
ftl_visitor.visit(resource)

return ftl_visitor.messages


def parse_file(file: str) -> MESSAGES:
return parse(text=Path(file).read_text(encoding="utf8"))


def from_files_to_file_ex(files: Sequence[str], to_file: str) -> None:
if file_dir := Path(to_file).parent:
file_dir.mkdir(exist_ok=True, parents=True)
Path(to_file).write_text(
Key().run(
messages={k: list(v) for file in files for k, v in parse_file(file).items()},
def from_files_to_file_ex(files: Sequence[str], to_file: str) -> None: # noqa: ARG001
echo(
style(
text="This function is removed. Use FTL-Extract instead.\n"
"pip install ftl-extract\n"
"\n"
"ftl stub <locale_path> <stub_output_path>\n"
"\n"
"https://pypi.org/project/FTL-Extract/",
fg="red",
),
encoding="utf8",
err=True,
color=True,
)
32 changes: 0 additions & 32 deletions aiogram_i18n/utils/fluent_stub/visitor.py

This file was deleted.

Loading