mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 14:15:56 +08:00
Merge pull request #16784 from Ultimaker/CURA-11014_fix_missing_definitions
Only filter files in directories starting with .
This commit is contained in:
commit
a278ad057f
@ -2,6 +2,7 @@ checks:
|
|||||||
diagnostic-mesh-file-extension: true
|
diagnostic-mesh-file-extension: true
|
||||||
diagnostic-mesh-file-size: true
|
diagnostic-mesh-file-size: true
|
||||||
diagnostic-definition-redundant-override: true
|
diagnostic-definition-redundant-override: true
|
||||||
|
diagnostic-resources-macos-app-directory-name: true
|
||||||
fixes:
|
fixes:
|
||||||
diagnostic-definition-redundant-override: true
|
diagnostic-definition-redundant-override: true
|
||||||
format:
|
format:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "printerlinter"
|
name = "printerlinter"
|
||||||
description = "Cura UltiMaker printer linting tool"
|
description = "Cura UltiMaker printer linting tool"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "UltiMaker", email = "cura@ultimaker.com" }
|
{ name = "UltiMaker", email = "cura@ultimaker.com" }
|
||||||
]
|
]
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional, List
|
||||||
|
|
||||||
from .linters.profile import Profile
|
from .linters.profile import Profile
|
||||||
from .linters.defintion import Definition
|
from .linters.defintion import Definition
|
||||||
from .linters.linter import Linter
|
from .linters.linter import Linter
|
||||||
from .linters.meshes import Meshes
|
from .linters.meshes import Meshes
|
||||||
|
from .linters.directory import Directory
|
||||||
|
|
||||||
|
|
||||||
def getLinter(file: Path, settings: dict) -> Optional[Linter]:
|
def getLinter(file: Path, settings: dict) -> Optional[List[Linter]]:
|
||||||
""" Returns a Linter depending on the file format """
|
""" Returns a Linter depending on the file format """
|
||||||
if not file.exists():
|
if not file.exists():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if ".inst" in file.suffixes and ".cfg" in file.suffixes:
|
if ".inst" in file.suffixes and ".cfg" in file.suffixes:
|
||||||
return Profile(file, settings)
|
return [Directory(file, settings), Profile(file, settings)]
|
||||||
|
|
||||||
if ".def" in file.suffixes and ".json" in file.suffixes:
|
if ".def" in file.suffixes and ".json" in file.suffixes:
|
||||||
if file.stem in ("fdmprinter.def", "fdmextruder.def"):
|
if file.stem in ("fdmprinter.def", "fdmextruder.def"):
|
||||||
return None
|
return None
|
||||||
return Definition(file, settings)
|
return [Directory(file, settings), Definition(file, settings)]
|
||||||
|
|
||||||
if file.parent.stem == "meshes":
|
if file.parent.stem == "meshes":
|
||||||
return Meshes(file, settings)
|
return [Meshes(file, settings)]
|
||||||
|
|
||||||
return None
|
return [Directory(file, settings)]
|
||||||
|
31
printer-linter/src/printerlinter/linters/directory.py
Normal file
31
printer-linter/src/printerlinter/linters/directory.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
from typing import Iterator
|
||||||
|
|
||||||
|
from ..diagnostic import Diagnostic
|
||||||
|
from .linter import Linter
|
||||||
|
|
||||||
|
|
||||||
|
class Directory(Linter):
|
||||||
|
def __init__(self, file: Path, settings: dict) -> None:
|
||||||
|
""" Finds issues in the parent directory"""
|
||||||
|
super().__init__(file, settings)
|
||||||
|
|
||||||
|
def check(self) -> Iterator[Diagnostic]:
|
||||||
|
if self._settings["checks"].get("diagnostic-resources-macos-app-directory-name", False):
|
||||||
|
for check in self.checkForDotInDirName():
|
||||||
|
yield check
|
||||||
|
|
||||||
|
yield
|
||||||
|
|
||||||
|
def checkForDotInDirName(self) -> Iterator[Diagnostic]:
|
||||||
|
""" Check if there is a dot in the directory name, MacOS has trouble signing and notarizing otherwise """
|
||||||
|
if any("." in p for p in self._file.parent.parts):
|
||||||
|
yield Diagnostic(
|
||||||
|
file = self._file,
|
||||||
|
diagnostic_name = "diagnostic-resources-macos-app-directory-name",
|
||||||
|
message = f"Directory name containing a `.` not allowed {self._file.suffix}, rename directory containing this file e.q: `_`",
|
||||||
|
level = "Error",
|
||||||
|
offset = 1
|
||||||
|
)
|
||||||
|
yield
|
||||||
|
|
@ -71,12 +71,16 @@ def main() -> None:
|
|||||||
|
|
||||||
def diagnoseIssuesWithFile(file: Path, settings: dict) -> List[Diagnostic]:
|
def diagnoseIssuesWithFile(file: Path, settings: dict) -> List[Diagnostic]:
|
||||||
""" For file, runs all diagnostic checks in settings and returns a list of diagnostics """
|
""" For file, runs all diagnostic checks in settings and returns a list of diagnostics """
|
||||||
linter = factory.getLinter(file, settings)
|
linters = factory.getLinter(file, settings)
|
||||||
|
|
||||||
if not linter:
|
if not linters:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return list(filter(lambda d: d is not None, linter.check()))
|
linter_results = []
|
||||||
|
for linter in linters:
|
||||||
|
linter_results.extend(list(filter(lambda d: d is not None, linter.check())))
|
||||||
|
|
||||||
|
return linter_results
|
||||||
|
|
||||||
|
|
||||||
def applyFixesToFile(file, settings, full_body_check) -> None:
|
def applyFixesToFile(file, settings, full_body_check) -> None:
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user