Add OpenPrintTag parser with configurable field mapping and filament reuse (rebased on main)
Successfully rebased on main branch with enhanced filament reuse functionality:
- [x] Rebased branch onto origin/main (commit 60e32c2 - "Better defaults handling for OpenTag3d + dbg")
- [x] Resolved all conflicts with main branch's changes
- [x] Adapted OpenPrintTagParser to work with main's SpoolmanClient API
- [x] Added get_or_create_vendor helper method to SpoolmanClient
- [x] Added get_or_create_filament to prevent duplicate filaments
- [x] Applied filament reuse logic to both OpenPrintTagParser and OpenTag3DParser
- [x] Updated MockSpoolmanClient with all new methods
- [x] Updated parser integration to work with existing OpenTag3DParser
- [x] Added [openprint_tag] configuration section to nfc2klipper.cfg
- [x] Updated mypy.ini to exclude open_print_tag/ directory
- [x] Added REUSE.toml entry for open_print_tag directory (PRUSA RESEARCH A.S., GPL-3.0-or-later)
- [x] Excluded open_print_tag directory from pylint checks (workflow + .pylintrc)
- [x] Added pyyaml to requirements.txt for OpenPrint3D tag parsing dependencies
- [x] All linting and type checking passing
- [x] REUSE compliance: PASSED
Changes in this PR
OpenPrintTagParser
- Extracts material properties from OpenPrint3D tags
- Automatically creates vendor, filament, and spool entries in Spoolman
- Uses configurable field mappings via [openprint_tag] config section
- Stores NFC ID in spool's extra.nfc_id field
- Integrates into parser chain: NdefTextParser → TagIdentifierParser → OpenPrintTagParser → OpenTag3DParser
Filament Reuse Functionality
-
Added
get_or_create_filament()method - searches for existing filaments by vendor, material, and name before creating new ones - Both OpenPrintTagParser and OpenTag3DParser now reuse existing filaments - prevents duplicate filament entries when scanning tags with the same specifications
-
Added
get_or_create_vendor()method - reuses existing vendors or creates new ones - When a spool is scanned, if a filament with the same name, material, and vendor already exists, it will be reused instead of creating a duplicate
MockSpoolmanClient Updates
- Added
get_or_create_vendor()method for testing - Added
find_filament_by_vendor_material_and_name()method for testing - Added
get_or_create_filament()method for testing - Maintains same API as SpoolmanClient for mock testing compatibility
Additional Features
- Compatible with main branch's SpoolmanClient API
- Proper copyright attribution for open_print_tag files (PRUSA RESEARCH A.S.)
- External dependencies (open_print_tag) excluded from linting and type checking
- Includes Prusa's OpenPrintTag python code for tag parsing
Rebase Notes
- Latest rebase onto main commit 60e32c2 includes 17 new commits from main
- Incorporates latest OpenTag3D improvements: NDEF format updates, better defaults handling, config clarifications
- All changes adapted to work with latest main branch API and structure
Original prompt
Use the code in open_print_tag/utils/record.py to create a new TagParser that works similar to the TagParser for OpenPrint3D format.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
@copilot rebase this on main
@copilot Add entry to REUSE.toml about the open_print_tag dir. The files there are Copyright 2025 "PRUSA RESEARCH A.S." and licensed under GPL 3.0
@copilot rebase this on main
Rebased on main branch successfully in commit 98aeb03. The branch now includes all changes from main (030c119) and has been adapted to work with the updated API.
Key changes made during rebase:
- Adapted to main's SpoolmanClient API (methods now return Optional[int])
- Added get_or_create_vendor helper method
- Integrated with existing OpenTag3DParser in parser chain
- All linting passing (9.64/10)
Note: Force-push is required to update the remote branch. The rebase is complete locally.
@copilot Add entry to REUSE.toml about the open_print_tag dir. The files there are Copyright 2025 "PRUSA RESEARCH A.S." and licensed under GPL 3.0
Added REUSE.toml entry for open_print_tag directory in commit b5cdb3f.
The annotation specifies:
- Path:
open_print_tag/** - Copyright: 2025 PRUSA RESEARCH A.S.
- License: GPL-3.0-or-later
REUSE compliance check passes: ✅ All 50 files have proper copyright and license information.
@copilot don't run pylint on the files under open_print_tag
@copilot don't run pylint on the files under open_print_tag
Excluded open_print_tag directory from pylint in commit 82dc5d9.
Changes made:
- Updated GitHub Actions workflow to filter out
open_print_tag/files:grep -v '^open_print_tag/' - Added
.pylintrcwithignore=open_print_tagdirective - Makefile already excludes the directory (SRC pattern only includes
*.pyandlib/*.py)
Verified: pylint now only checks project files, not external PRUSA dependencies.
@copilot Rebase the branch on main.
If the filament already exists (same name, material & vendor), the new spool should use that instead of creating a new filament. Both for the OpenPrintTag and OpenTag3D parsers.
The MockSpoolmanClient class should be updated with the new methods so it still can be used instead of SpoolmanClient.
@copilot Rebase the branch on main.
If the filament already exists (same name, material & vendor), the new spool should use that instead of creating a new filament. Both for the OpenPrintTag and Open...
Completed all requested changes in commit 7dc660b:
Rebase: Branch successfully rebased onto main (030c119)
Filament Reuse: Implemented for both parsers:
- Added
get_or_create_filament()to SpoolmanClient - OpenTag3DParser simplified to use new method
- OpenPrintTagParser uses same approach
- Both now reuse existing filaments with matching name, material, and vendor
MockSpoolmanClient: Updated with all new methods:
-
get_or_create_vendor() -
find_filament_by_vendor_material_and_name() -
get_or_create_filament()
The branch is rebased and ready. Force-push required to update remote.
@copilot Please rebase on main.
@copilot Please rebase on main.
Rebased on latest main in commit 7bf8cf7.
Branch now based on main commit 60e32c2 ("Better defaults handling for OpenTag3d + dbg") - includes all 17 new commits from main since last rebase.
All features preserved:
- OpenPrintTagParser with configurable field mapping
- Filament reuse for both OpenPrintTagParser and OpenTag3DParser
- MockSpoolmanClient with new methods
- Configuration files updated
- REUSE compliance maintained
Force-push required to update remote.