| OLD | NEW |
| 1 # # Copyright (c) 2000-2013 LOGILAB S.A. (Paris, FRANCE). | 1 # # Copyright (c) 2000-2013 LOGILAB S.A. (Paris, FRANCE). |
| 2 # http://www.logilab.fr/ -- mailto:contact@logilab.fr | 2 # http://www.logilab.fr/ -- mailto:contact@logilab.fr |
| 3 # | 3 # |
| 4 # This program is free software; you can redistribute it and/or modify it under | 4 # This program is free software; you can redistribute it and/or modify it under |
| 5 # the terms of the GNU General Public License as published by the Free Software | 5 # the terms of the GNU General Public License as published by the Free Software |
| 6 # Foundation; either version 2 of the License, or (at your option) any later | 6 # Foundation; either version 2 of the License, or (at your option) any later |
| 7 # version. | 7 # version. |
| 8 # | 8 # |
| 9 # This program is distributed in the hope that it will be useful, but WITHOUT | 9 # This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | 11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 12 # | 12 # |
| 13 # You should have received a copy of the GNU General Public License along with | 13 # You should have received a copy of the GNU General Public License along with |
| 14 # this program; if not, write to the Free Software Foundation, Inc., | 14 # this program; if not, write to the Free Software Foundation, Inc., |
| 15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 """ | 16 """ |
| 17 %prog [options] <packages> | 17 %prog [options] <packages> |
| 18 | 18 |
| 19 create UML diagrams for classes and modules in <packages> | 19 create UML diagrams for classes and modules in <packages> |
| 20 """ | 20 """ |
| 21 from __future__ import print_function |
| 21 | 22 |
| 22 import sys, os | 23 import sys, os |
| 23 from logilab.common.configuration import ConfigurationMixIn | 24 from logilab.common.configuration import ConfigurationMixIn |
| 24 from astroid.manager import AstroidManager | 25 from astroid.manager import AstroidManager |
| 25 from astroid.inspector import Linker | 26 from astroid.inspector import Linker |
| 26 | 27 |
| 27 from pylint.pyreverse.diadefslib import DiadefsHandler | 28 from pylint.pyreverse.diadefslib import DiadefsHandler |
| 28 from pylint.pyreverse import writer | 29 from pylint.pyreverse import writer |
| 29 from pylint.pyreverse.utils import insert_default_options | 30 from pylint.pyreverse.utils import insert_default_options |
| 30 | 31 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ConfigurationMixIn.__init__(self, usage=__doc__) | 93 ConfigurationMixIn.__init__(self, usage=__doc__) |
| 93 insert_default_options() | 94 insert_default_options() |
| 94 self.manager = AstroidManager() | 95 self.manager = AstroidManager() |
| 95 self.register_options_provider(self.manager) | 96 self.register_options_provider(self.manager) |
| 96 args = self.load_command_line_configuration() | 97 args = self.load_command_line_configuration() |
| 97 sys.exit(self.run(args)) | 98 sys.exit(self.run(args)) |
| 98 | 99 |
| 99 def run(self, args): | 100 def run(self, args): |
| 100 """checking arguments and run project""" | 101 """checking arguments and run project""" |
| 101 if not args: | 102 if not args: |
| 102 print self.help() | 103 print(self.help()) |
| 103 return 1 | 104 return 1 |
| 104 # insert current working directory to the python path to recognize | 105 # insert current working directory to the python path to recognize |
| 105 # dependencies to local modules even if cwd is not in the PYTHONPATH | 106 # dependencies to local modules even if cwd is not in the PYTHONPATH |
| 106 sys.path.insert(0, os.getcwd()) | 107 sys.path.insert(0, os.getcwd()) |
| 107 try: | 108 try: |
| 108 project = self.manager.project_from_files(args) | 109 project = self.manager.project_from_files(args) |
| 109 linker = Linker(project, tag=True) | 110 linker = Linker(project, tag=True) |
| 110 handler = DiadefsHandler(self.config) | 111 handler = DiadefsHandler(self.config) |
| 111 diadefs = handler.get_diadefs(project, linker) | 112 diadefs = handler.get_diadefs(project, linker) |
| 112 finally: | 113 finally: |
| 113 sys.path.pop(0) | 114 sys.path.pop(0) |
| 114 | 115 |
| 115 if self.config.output_format == "vcg": | 116 if self.config.output_format == "vcg": |
| 116 writer.VCGWriter(self.config).write(diadefs) | 117 writer.VCGWriter(self.config).write(diadefs) |
| 117 else: | 118 else: |
| 118 writer.DotWriter(self.config).write(diadefs) | 119 writer.DotWriter(self.config).write(diadefs) |
| 119 return 0 | 120 return 0 |
| 120 | 121 |
| 121 | 122 |
| 122 if __name__ == '__main__': | 123 if __name__ == '__main__': |
| 123 Run(sys.argv[1:]) | 124 Run(sys.argv[1:]) |
| OLD | NEW |