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
This commit is contained in:
Saumya Jain 2024-04-05 15:55:30 +02:00
parent 8020b9d97d
commit 38382eeec7
6 changed files with 36 additions and 5 deletions

View file

@ -19,6 +19,7 @@ def main() -> None:
parser.add_argument("--report", required=False, type=Path, help="Path where the diagnostic report should be stored")
parser.add_argument("--format", action="store_true", help="Format the files")
parser.add_argument("--diagnose", action="store_true", help="Diagnose the files")
parser.add_argument("--deleted", action="store_true", help="Check for deleted files")
parser.add_argument("--fix", action="store_true", help="Attempt to apply the suggested fixes on the files")
parser.add_argument("Files", metavar="F", type=Path, nargs="+", help="Files or directories to format")
@ -47,6 +48,18 @@ def main() -> None:
print(f"Can't find the file: {file}")
return
if args.deleted and files ==[]:
for file in args.Files:
deletedFiles = diagnoseIssuesWithFile(file, settings )
full_body_check["Diagnostics"].extend([d.toDict() for d in deletedFiles])
results = yaml.dump(full_body_check, default_flow_style=False, indent=4, width=240)
if report:
report.write_text(results)
else:
print(results)
if to_fix or to_diagnose:
for file in files:
diagnostics = diagnoseIssuesWithFile(file, settings)
@ -82,7 +95,6 @@ def diagnoseIssuesWithFile(file: Path, settings: dict) -> List[Diagnostic]:
return linter_results
def applyFixesToFile(file, settings, full_body_check) -> None:
if not file.exists():
return