mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Added a linting tool for Cura Printers and Profiles
printer-linter works of definitions, profiles and meshes;
It has various diagnostic checks. With possible suggestions for fixes.
It should also be able to fix certain diagnostic issues and it can be used
to format the files according to code-style.
It can output the diagnostics in a yaml file, which can then be used to comment
on PR's with suggestions to the author. Future PR.
The settings for the diagnostics and checks are defined in `.printer-linter`
and are very self explanatory.
```
checks:
diagnostic-mesh-file-extension: true
diagnostic-mesh-file-size: true
diagnostic-definition-redundant-override: true
fixes:
diagnostic-definition-redundant-override: true
format:
format-definition-bracket-newline: false
format-definition-paired-coordinate-array: true
format-definition-sort-keys: true
format-definition-indent: 4
format-profile-space-around-delimiters: true
format-profile-sort-keys: true
diagnostic-mesh-file-size: 1200000
```
This commit is contained in:
parent
fb69cff511
commit
104bc585f4
8 changed files with 388 additions and 0 deletions
34
printer-linter/tidy/meshes.py
Normal file
34
printer-linter/tidy/meshes.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from .diagnostic import Diagnostic
|
||||
|
||||
|
||||
class Meshes:
|
||||
def __init__(self, file, settings):
|
||||
self._settings = settings
|
||||
self._file = file
|
||||
self._max_file_size = self._settings.get("diagnostic-mesh-file-size", 1e6)
|
||||
|
||||
def check(self):
|
||||
if self._settings["checks"].get("diagnostic-mesh-file-extension", False):
|
||||
for check in self.checkFileFormat():
|
||||
yield check
|
||||
|
||||
if self._settings["checks"].get("diagnostic-mesh-file-size", False):
|
||||
for check in self.checkFileSize():
|
||||
yield check
|
||||
|
||||
yield
|
||||
|
||||
def checkFileFormat(self):
|
||||
if self._file.suffix.lower() not in (".3mf", ".obj", ".stl"):
|
||||
yield Diagnostic("diagnostic-mesh-file-extension",
|
||||
f"Extension **{self._file.suffix}** not supported, use **3mf**, **obj** or **stl**",
|
||||
self._file)
|
||||
yield
|
||||
|
||||
def checkFileSize(self):
|
||||
|
||||
if self._file.stat().st_size > self._max_file_size:
|
||||
yield Diagnostic("diagnostic-mesh-file-size",
|
||||
f"Mesh file with a size **{self._file.stat().st_size}** is bigger then allowed maximum of **{self._max_file_size}**",
|
||||
self._file)
|
||||
yield
|
||||
Loading…
Add table
Add a link
Reference in a new issue