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
14 changes: 11 additions & 3 deletions compile/tspl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def render(self, context: Mapping[str, Any]) -> bytes:
result = handler(element, context)
if not result:
continue
if isinstance(result, Iterable) and not isinstance(result, (bytes, bytearray)):
if isinstance(result, Iterable) and not isinstance(
result, (bytes, bytearray)
):
parts.extend(self._ensure_bytes(item) for item in result)
else:
parts.append(self._ensure_bytes(result))
Expand Down Expand Up @@ -102,7 +104,9 @@ def _int_setting(value: Any) -> int | None:
gap_offset = float(self.template.get("gap_offset_mm", 0.0))
mark_mm = self.template.get("mark_mm", self.template.get("black_mark_mm"))
mark_offset = float(
self.template.get("mark_offset_mm", self.template.get("black_mark_offset_mm", 0.0))
self.template.get(
"mark_offset_mm", self.template.get("black_mark_offset_mm", 0.0)
)
)
fine_offset = float(self.template.get("fine_offset_mm", 0.0))
calibrate = bool(self.template.get("calibrate_next_print"))
Expand Down Expand Up @@ -248,7 +252,11 @@ def _resolve_raster_settings(self, element: Mapping[str, Any]) -> dict[str, Any]
return settings

def _bitmap_command(
self, element: Mapping[str, Any], image: Image.Image, *, digest: str | None = None
self,
element: Mapping[str, Any],
image: Image.Image,
*,
digest: str | None = None,
) -> bytes:
settings = self._resolve_raster_settings(element)
width = self.optional_dimension(element, "width", axis="x")
Expand Down
10 changes: 8 additions & 2 deletions compile/zpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def render(self, context: Mapping[str, Any]) -> bytes:
result = handler(element, context)
if not result:
continue
if isinstance(result, Iterable) and not isinstance(result, (bytes, bytearray)):
if isinstance(result, Iterable) and not isinstance(
result, (bytes, bytearray)
):
parts.extend(self._ensure_bytes(item) for item in result)
else:
parts.append(self._ensure_bytes(result))
Expand Down Expand Up @@ -215,7 +217,11 @@ def _resolve_raster_settings(self, element: Mapping[str, Any]) -> dict[str, Any]
return settings

def _graphic_field(
self, element: Mapping[str, Any], image: Image.Image, *, digest: str | None = None
self,
element: Mapping[str, Any],
image: Image.Image,
*,
digest: str | None = None,
) -> bytes:
settings = self._resolve_raster_settings(element)
width = self.optional_dimension(element, "width", axis="x")
Expand Down
4 changes: 2 additions & 2 deletions db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
default_db_path,
delete_vars_preset,
find_raster_cache,
get_conn,
get_asset_id_by_hash,
get_conn,
get_template_id_by_name,
init,
load_printer_profile,
insert_or_get_raster_cache,
list_vars_presets,
load_printer_profile,
load_vars_preset,
save_printer_profile,
save_vars_preset,
Expand Down
5 changes: 3 additions & 2 deletions db/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from __future__ import annotations

from collections.abc import Callable
import hashlib
import json
import sqlite3
from collections.abc import Callable


def add_column_if_missing(
Expand Down Expand Up @@ -215,7 +215,8 @@ def table_columns(name: str) -> set[str]:
conn.execute(create_print_jobs_sql)

cursor = conn.execute(
"SELECT id, created_at, template_name, payload, status FROM print_jobs_legacy"
"SELECT id, created_at, template_name, payload, status "
"FROM print_jobs_legacy"
)
for row in cursor.fetchall():
legacy_id, created_at, template_name, payload_value, status = row
Expand Down
9 changes: 6 additions & 3 deletions db/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
from pathlib import Path
from typing import Mapping, Sequence

from . import migrations
from utils import recurso_caminho
from utils.fs import canonical_path as canonical_file_path

from . import migrations

__all__ = [
"backup",
"configure_default_path",
Expand Down Expand Up @@ -253,7 +254,8 @@ def load_printer_profile(

with contextlib.closing(get_conn(database)) as conn:
row = conn.execute(
"SELECT settings, calibrate_next_print FROM printer_profiles WHERE name = ?",
"SELECT settings, calibrate_next_print "
"FROM printer_profiles WHERE name = ?",
(name,),
).fetchone()

Expand Down Expand Up @@ -989,7 +991,8 @@ def get_job_payload(

with contextlib.closing(get_conn(database)) as conn:
cursor = conn.execute(
f"SELECT payload FROM print_jobs WHERE {where_clause} ORDER BY id DESC LIMIT 1",
"SELECT payload FROM print_jobs "
f"WHERE {where_clause} ORDER BY id DESC LIMIT 1",
params,
)
row = cursor.fetchone()
Expand Down
5 changes: 4 additions & 1 deletion editor/arrange_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def __init__(self, parent=None) -> None:
form_layout.addRow("Colunas (N):", self._columns)
form_layout.addRow("Linhas (M):", self._rows)

button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
button_box = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
self,
)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)

Expand Down
14 changes: 10 additions & 4 deletions editor/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from typing import Optional

from qt_compat import (
QIcon,
QListWidget,
QListWidgetItem,
QSize,
Qt,
QVBoxLayout,
QWidget,
QIcon,
Qt,
)

from .scene import LabelScene
Expand All @@ -20,7 +20,11 @@
class UndoHistoryPanel(QWidget):
"""Display undo/redo history entries with canvas thumbnails."""

def __init__(self, scene: Optional[LabelScene] = None, parent: QWidget | None = None) -> None:
def __init__(
self,
scene: Optional[LabelScene] = None,
parent: QWidget | None = None,
) -> None:
super().__init__(parent)
self._scene: LabelScene | None = None
self._updating_selection = False
Expand Down Expand Up @@ -77,7 +81,9 @@ def _refresh_items(self) -> None:
count = stack.count()
snapshots = scene.history_snapshots()
if len(snapshots) < count + 1:
snapshots.extend(scene.capture_thumbnail() for _ in range(count + 1 - len(snapshots)))
snapshots.extend(
scene.capture_thumbnail() for _ in range(count + 1 - len(snapshots))
)

self._updating_selection = True
try:
Expand Down
10 changes: 7 additions & 3 deletions editor/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
QInputDialog,
QListWidget,
QListWidgetItem,
QToolButton,
Qt,
QToolButton,
QVBoxLayout,
QWidget,
pyqtSignal,
Expand Down Expand Up @@ -130,8 +130,12 @@ def __init__(self, parent: QWidget | None = None) -> None:
super().__init__(parent)
self._scene: LabelScene | None = None
self._updating_selection = False
self._row_items: Dict[GraphicsElementItem | TextGraphicsItem, QListWidgetItem] = {}
self._widgets: Dict[GraphicsElementItem | TextGraphicsItem, _LayerRow] = {}
self._row_items: Dict[
GraphicsElementItem | TextGraphicsItem, QListWidgetItem
] = {}
self._widgets: Dict[
GraphicsElementItem | TextGraphicsItem, _LayerRow
] = {}
self._change_handlers: Dict[
GraphicsElementItem | TextGraphicsItem, object
] = {}
Expand Down
2 changes: 1 addition & 1 deletion editor/preset_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
QListWidgetItem,
QMessageBox,
QPushButton,
QVBoxLayout,
Qt,
QVBoxLayout,
)

from .preset_manager import PresetManager
Expand Down
2 changes: 1 addition & 1 deletion editor/roll_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
QHBoxLayout,
QLabel,
QPainter,
QPointF,
QPixmap,
QPointF,
QSlider,
QStackedWidget,
Qt,
Expand Down
11 changes: 9 additions & 2 deletions editor/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ def can_duplicate_selected_items(self) -> bool:

def duplicate_selected_items(self) -> bool:
selected = [
item for item in self.selected_items() if not getattr(item, "_locked", False)
item
for item in self.selected_items()
if not getattr(item, "_locked", False)
]
if not selected:
return False
Expand Down Expand Up @@ -463,7 +465,12 @@ def set_alignment_tolerance(self, tolerance: float) -> None:
"""Update the snapping tolerance used for object alignment."""

tolerance = max(0.0, float(tolerance))
if math.isclose(tolerance, self._alignment_tolerance, rel_tol=0.0, abs_tol=1e-6):
if math.isclose(
tolerance,
self._alignment_tolerance,
rel_tol=0.0,
abs_tol=1e-6,
):
return
self._alignment_tolerance = tolerance
self.clear_guides()
Expand Down
9 changes: 4 additions & 5 deletions editor/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@

from model.template import TemplateVariable
from qt_compat import (
QAbstractItemView,
QCheckBox,
QColor,
QComboBox,
QCheckBox,
QAbstractItemView,
QHeaderView,
QHBoxLayout,
QHeaderView,
QIcon,
QLabel,
QLineEdit,
QPlainTextEdit,
QPushButton,
QStyle,
Qt,
QTreeWidget,
QTreeWidgetItem,
QVBoxLayout,
QWidget,
Qt,
pyqtSignal,
)


_TYPE_INFO: dict[str, tuple[str, str]] = {
"text": ("Texto", "#eef2ff"),
"multiline": ("Texto", "#eef2ff"),
Expand Down
5 changes: 2 additions & 3 deletions editor/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
from qt_compat import (
QBrush,
QCheckBox,
QComboBox,
QColor,
QComboBox,
QGraphicsPixmapItem,
QGraphicsScene,
QGraphicsView,
QGridLayout,
QHBoxLayout,
QLabel,
QPainter,
QPointF,
QPixmap,
QPointF,
QSlider,
QSplitter,
QStackedWidget,
Expand All @@ -43,7 +43,6 @@
from .scene import LabelScene, build_model_from_scene
from .view import LabelView


MM_PER_INCH = 25.4


Expand Down
Loading
Loading