queue_item_printer.py 1.0 KB

1234567891011121314151617181920212223242526272829
  1. """What a queue item keeps when its printer changes.
  2. Some of an item's settings were worked out for one printer: its AMS tray
  3. mapping (that printer's trays), "Print Anyway" (an answer to that printer's
  4. filament check) and its nozzle choice (that printer's nozzle rack). On
  5. another printer they mean something else, so they go with the old printer;
  6. the next dispatch works them out again. What the user chose for the print
  7. itself (plate, AMS on or off, filament overrides, print options) stays.
  8. """
  9. from __future__ import annotations
  10. from collections.abc import Iterable
  11. from typing import Any
  12. PRINTER_RESOLVED_DEFAULTS: dict[str, Any] = {
  13. "ams_mapping": None,
  14. "skip_filament_check": False,
  15. "nozzle_mapping": None,
  16. "nozzle_rack_choice": None,
  17. }
  18. def drop_printer_resolved(item: Any, keep: Iterable[str] = ()) -> None:
  19. """Reset *item*'s printer-specific settings, except those named in *keep*."""
  20. kept = set(keep)
  21. for field, default in PRINTER_RESOLVED_DEFAULTS.items():
  22. if field not in kept:
  23. setattr(item, field, default)