diff options
author | Mark Byrne <mbyrnepr2@gmail.com> | 2021-03-06 22:13:43 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-03-07 13:22:45 +0100 |
commit | 76368cf1b241cfc92aac422b6d75e8cb2ebb1af1 (patch) | |
tree | dd3ce543211079228e8f7e1a0d5d34644a805625 | |
parent | 1f7b77b7f5c0f96d0ce11dead92ec2a17d3a313a (diff) | |
download | pylint-git-76368cf1b241cfc92aac422b6d75e8cb2ebb1af1.tar.gz |
pyreverse: Add output directory command-line option
Issue: #4159
-rw-r--r-- | CONTRIBUTORS.txt | 2 | ||||
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/pyreverse/main.py | 11 | ||||
-rw-r--r-- | pylint/pyreverse/writer.py | 6 | ||||
-rw-r--r-- | tests/unittest_pyreverse_writer.py | 1 |
5 files changed, 24 insertions, 0 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 395c80484..cad49c23c 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -456,3 +456,5 @@ contributors: * Louis Sautier: contributor * Alexander Kapshuna: contributor + +* Mark Byrne: contributor @@ -19,6 +19,10 @@ Release date: TBA .. Put bug fixes that will be cherry-picked to latest major version here +* Introduce a command-line option to specify pyreverse output directory + + Closes #4159 + * Fix issue with Enums and ``class-attribute-naming-style=snake_case`` Closes #4149 diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py index 3c3381cb2..a71de203d 100644 --- a/pylint/pyreverse/main.py +++ b/pylint/pyreverse/main.py @@ -157,6 +157,17 @@ this disables -f values", "help": "set the project name.", }, ), + ( + "output-directory", + { + "default": "", + "type": "string", + "short": "d", + "action": "store", + "metavar": "<output_directory>", + "help": "set the output directory path.", + }, + ), ) diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py index 8d19ffa96..3c75f06a0 100644 --- a/pylint/pyreverse/writer.py +++ b/pylint/pyreverse/writer.py @@ -14,6 +14,8 @@ """Utilities for creating VCG and Dot diagrams""" +import os + from pylint.graph import DotBackend from pylint.pyreverse.utils import is_exception from pylint.pyreverse.vcgutils import VCGPrinter @@ -32,6 +34,10 @@ class DiagramWriter: for diagram in diadefs: basename = diagram.title.strip().replace(" ", "_") file_name = f"{basename}.{self.config.output_format}" + if os.path.exists(self.config.output_directory): + file_name = os.path.join( + self.config.output_directory, + file_name) self.set_printer(file_name, basename) if diagram.TYPE == "class": self.write_classes(diagram) diff --git a/tests/unittest_pyreverse_writer.py b/tests/unittest_pyreverse_writer.py index bf353bd0d..e10e1599f 100644 --- a/tests/unittest_pyreverse_writer.py +++ b/tests/unittest_pyreverse_writer.py @@ -42,6 +42,7 @@ _DEFAULTS = { "mode": "PUB_ONLY", "show_builtin": False, "only_classnames": False, + "output_directory": "", } |