third_party.pylibs.pylint.src/pylint/pyreverse/printer_factory.py
Andreas Finkler 4da3862f49
`pyreverse`: add PlantUML output (#4846)
* Extract helper method to get annotated arguments into ``Printer`` base class.

* Add ``Printer`` subclass for PlantUML output

* Add functional test for ``PlantUmlPrinter``

* Add tests for specific layout for ``PlantUmlPrinter``

* Extract test helper function to remove code duplication

* Add new test class to check type annotations

* Cleanup generated .puml files after tests finished

* Create a factory function to get the correct ``Printer`` class for a given filetype.

* Fix unittest after adding a new class to the test data.

* Add changelog and whatsnew entry

* Add "plantuml" as possible extension for PlantUML output
2021-08-14 21:34:00 +02:00

23 lines
702 B
Python

# Copyright (c) 2021 Andreas Finkler <andi.finkler@gmail.com>
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
from typing import Type
from pylint.pyreverse.dot_printer import DotPrinter
from pylint.pyreverse.plantuml_printer import PlantUmlPrinter
from pylint.pyreverse.printer import Printer
from pylint.pyreverse.vcg_printer import VCGPrinter
filetype_to_printer = {
"vcg": VCGPrinter,
"plantuml": PlantUmlPrinter,
"puml": PlantUmlPrinter,
"dot": DotPrinter,
}
def get_printer_for_filetype(filetype: str) -> Type[Printer]:
return filetype_to_printer.get(filetype, DotPrinter)