Cura/printer-linter/src/printerlinter/factory.py
jellespijker b401ecee02 Add MacOS directory naming linting
A new Linter subclass - 'Directory' has been created and integrated into the linting process to handle directory naming conventions, specifically for MacOS. MacOS has issues when signing and notarizing directories with '.' in their names. The new class will trigger an 'Error' level diagnostic if this convention is violated. The linter will become a required check with this update, as its new check configuration was added to '.printer-linter'. The version number in 'pyproject.toml' was also incremented to reflect these changes.

Contributes to CURA-11014
2023-09-22 01:29:22 +02:00

27 lines
893 B
Python

from pathlib import Path
from typing import Optional, List
from .linters.profile import Profile
from .linters.defintion import Definition
from .linters.linter import Linter
from .linters.meshes import Meshes
from .linters.directory import Directory
def getLinter(file: Path, settings: dict) -> Optional[List[Linter]]:
""" Returns a Linter depending on the file format """
if not file.exists():
return None
if ".inst" in file.suffixes and ".cfg" in file.suffixes:
return [Directory(file, settings), Profile(file, settings)]
if ".def" in file.suffixes and ".json" in file.suffixes:
if file.stem in ("fdmprinter.def", "fdmextruder.def"):
return None
return [Directory(file, settings), Definition(file, settings)]
if file.parent.stem == "meshes":
return [Meshes(file, settings)]
return [Directory(file, settings)]