mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-06-26 01:15:28 -06:00
Create a proper Pyhton packages for printer-linter
Such that it can be downloaded, installed and used locally and on other repo's actions etc
This commit is contained in:
parent
49305474ea
commit
0c7807e0cd
9 changed files with 53 additions and 13 deletions
17
printer-linter/pyproject.toml
Normal file
17
printer-linter/pyproject.toml
Normal file
|
@ -0,0 +1,17 @@
|
|||
[project]
|
||||
name = "printerlinter"
|
||||
description = "Cura UltiMaker printer linting tool"
|
||||
version = "0.1.0"
|
||||
authors = [
|
||||
{ name = "UltiMaker", email = "cura@ultimaker.com" }
|
||||
]
|
||||
dependencies = [
|
||||
"pyyaml"
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
printer-linter = "printerlinter.terminal:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
10
printer-linter/setup.cfg
Normal file
10
printer-linter/setup.cfg
Normal file
|
@ -0,0 +1,10 @@
|
|||
[metadata]
|
||||
name = printerlinter
|
||||
|
||||
[options]
|
||||
package_dir=
|
||||
=src
|
||||
packages=find:
|
||||
|
||||
[options.packages.find]
|
||||
where=src
|
6
printer-linter/setup.py
Normal file
6
printer-linter/setup.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||
|
||||
import yaml
|
||||
|
||||
from tidy import create
|
||||
from . import create
|
||||
|
||||
|
||||
def examineFile(file, settings):
|
||||
|
@ -72,7 +72,24 @@ def formatFile(file: Path, settings):
|
|||
config.write(f, space_around_delimiters=settings["format"].get("format-profile-space-around-delimiters", True))
|
||||
|
||||
|
||||
def main(files, setting_path, to_format, to_fix, to_diagnose, report):
|
||||
def main():
|
||||
parser = ArgumentParser(
|
||||
description="UltiMaker Cura printer linting, static analysis and formatting of Cura printer definitions and other resources")
|
||||
parser.add_argument("--setting", required=False, type=Path, help="Path to the `.printer-linter` setting file")
|
||||
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("--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")
|
||||
|
||||
args = parser.parse_args()
|
||||
files = args.Files
|
||||
setting_path = args.setting
|
||||
to_format = args.format
|
||||
to_fix = args.fix
|
||||
to_diagnose = args.diagnose
|
||||
report = args.report
|
||||
|
||||
if not setting_path:
|
||||
setting_path = Path(getcwd(), ".printer-linter")
|
||||
|
||||
|
@ -118,14 +135,4 @@ def main(files, setting_path, to_format, to_fix, to_diagnose, report):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser(
|
||||
description="UltiMaker Cura printer linting, static analysis and formatting of Cura printer definitions and other resources")
|
||||
parser.add_argument("--setting", required=False, type=Path, help="Path to the `.printer-linter` setting file")
|
||||
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("--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")
|
||||
|
||||
args = parser.parse_args()
|
||||
main(args.Files, args.setting, args.format, args.fix, args.diagnose, args.report)
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue