Cura/printer-linter/src/printerlinter/factory.py
Saumya Jain 38382eeec7 Add detection for deleted files in printer linter
This update adds a new check for deleted files in the printer linter. This will alert the user when a file has been deleted that could potentially disrupt upgrade scripts. An argument "--deleted" is also added to terminal.py to facilitate this new check. Additionally, the printer-linter version has been incremented to 0.1.2.

CURA-10903
2024-04-05 15:55:30 +02:00

27 lines
916 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 [Directory(file, settings)]
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)]