forked from pklaus/brother_ql_web
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afe701c
commit 7c724c3
Showing
25 changed files
with
231 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
def main(): | ||
def main() -> None: | ||
import logging | ||
|
||
from brother_ql_web import cli, utils, web | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
from brother_ql.backends import backend_factory, guess_backend | ||
from __future__ import annotations | ||
|
||
from typing import cast | ||
|
||
from brother_ql.backends import backend_factory, BrotherQLBackendGeneric, guess_backend | ||
from brother_ql.devicedependent import label_type_specs, label_sizes | ||
from brother_ql_web.configuration import Configuration | ||
from brother_ql_web.font_helpers import get_fonts | ||
|
||
|
||
def collect_fonts(configuration): | ||
def collect_fonts(configuration: Configuration) -> dict[str, dict[str, str]]: | ||
fonts = get_fonts() | ||
if configuration.server.additional_font_folder: | ||
fonts.update(get_fonts(configuration.server.additional_font_folder)) | ||
return fonts | ||
|
||
|
||
def get_label_sizes(): | ||
return [(name, label_type_specs[name]["name"]) for name in label_sizes] | ||
def get_label_sizes() -> list[tuple[str, str]]: | ||
return [(name, cast(str, label_type_specs[name]["name"])) for name in label_sizes] | ||
|
||
|
||
class BackendGuessingError(ValueError): | ||
pass | ||
|
||
|
||
def get_backend_class(configuration): | ||
def get_backend_class(configuration: Configuration) -> type[BrotherQLBackendGeneric]: | ||
try: | ||
selected_backend = guess_backend(configuration.printer.printer) | ||
except ValueError: | ||
raise BackendGuessingError( | ||
"Couln't guess the backend to use from the printer string descriptor" | ||
) | ||
return backend_factory(selected_backend)["backend_class"] | ||
return cast( | ||
type[BrotherQLBackendGeneric], | ||
backend_factory(selected_backend)["backend_class"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ requires = [ | |
|
||
[tool.mypy] | ||
mypy_path = '$MYPY_CONFIG_FILE_DIR/stubs' | ||
strict = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
from .generic import BrotherQLBackendGeneric as BrotherQLBackendGeneric | ||
from _typeshed import Incomplete | ||
|
||
def list_available_devices(): ... | ||
def list_available_devices() -> list[dict[str, str | None]]: ... | ||
|
||
class BrotherQLBackendLinuxKernel(BrotherQLBackendGeneric): | ||
read_timeout: float | ||
strategy: str | ||
dev: Incomplete | ||
write_dev: Incomplete | ||
read_dev: Incomplete | ||
def __init__(self, device_specifier) -> None: ... | ||
def __init__(self, device_specifier: str) -> None: ... |
Oops, something went wrong.