Skip to content

Commit 14cd177

Browse files
committed
Use factory function to get the corresponding writer for the desired output format (Open-Closed-Principle).
1 parent 7938bf1 commit 14cd177

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pylint/pyreverse/main.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import sys
2626

2727
from pylint.config import ConfigurationMixIn
28-
from pylint.pyreverse import writer
2928
from pylint.pyreverse.diadefslib import DiadefsHandler
3029
from pylint.pyreverse.inspector import Linker, project_from_files
3130
from pylint.pyreverse.utils import insert_default_options
31+
from pylint.pyreverse.writer import get_writer_for_filetype
3232

3333
OPTIONS = (
3434
(
@@ -239,12 +239,8 @@ def run(self, args):
239239
finally:
240240
sys.path.pop(0)
241241

242-
if self.config.output_format == "vcg":
243-
writer.VCGWriter(self.config).write(diadefs)
244-
elif self.config.output_format == "puml":
245-
writer.PlantUmlWriter(self.config).write(diadefs)
246-
else:
247-
writer.DotWriter(self.config).write(diadefs)
242+
writer = get_writer_for_filetype(self.config.output_format)
243+
writer(self.config).write(diadefs)
248244
return 0
249245

250246

0 commit comments

Comments
 (0)