Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: third_party/pylint/pyreverse/main.py

Issue 739393004: Revert "Revert "pylint: upgrade to 1.3.1"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/pylint/pyreverse/diagrams.py ('k') | third_party/pylint/pyreverse/utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # # Copyright (c) 2000-2010 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 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 21
22 import sys, os 22 import sys, os
23 from logilab.common.configuration import ConfigurationMixIn 23 from logilab.common.configuration import ConfigurationMixIn
24 from logilab.astng.manager import ASTNGManager 24 from astroid.manager import AstroidManager
25 from logilab.astng.inspector import Linker 25 from astroid.inspector import Linker
26 26
27 from pylint.pyreverse.diadefslib import DiadefsHandler 27 from pylint.pyreverse.diadefslib import DiadefsHandler
28 from pylint.pyreverse import writer 28 from pylint.pyreverse import writer
29 from pylint.pyreverse.utils import insert_default_options 29 from pylint.pyreverse.utils import insert_default_options
30 30
31 OPTIONS = ( 31 OPTIONS = (
32 ("filter-mode", 32 ("filter-mode",
33 dict(short='f', default='PUB_ONLY', dest='mode', type='string', 33 dict(short='f', default='PUB_ONLY', dest='mode', type='string',
34 action='store', metavar='<mode>', 34 action='store', metavar='<mode>',
35 help="""filter attributes and functions according to 35 help="""filter attributes and functions according to
36 <mode>. Correct modes are : 36 <mode>. Correct modes are :
37 'PUB_ONLY' filter all non public attributes 37 'PUB_ONLY' filter all non public attributes
38 [DEFAULT], equivalent to PRIVATE+SPECIAL_A 38 [DEFAULT], equivalent to PRIVATE+SPECIAL_A
39 'ALL' no filter 39 'ALL' no filter
40 'SPECIAL' filter Python special functions 40 'SPECIAL' filter Python special functions
41 except constructor 41 except constructor
42 'OTHER' filter protected and private 42 'OTHER' filter protected and private
43 attributes""")), 43 attributes""")),
44 44
45 ("class", 45 ("class",
46 dict(short='c', action="append", metavar="<class>", dest="classes", default=[], 46 dict(short='c', action="append", metavar="<class>", dest="classes", default =[],
47 help="create a class diagram with all classes related to <class>;\ 47 help="create a class diagram with all classes related to <class>;\
48 this uses by default the options -ASmy")), 48 this uses by default the options -ASmy")),
49 49
50 ("show-ancestors", 50 ("show-ancestors",
51 dict(short="a", action="store", metavar='<ancestor>', type='int', 51 dict(short="a", action="store", metavar='<ancestor>', type='int',
52 help='show <ancestor> generations of ancestor classes not in <projects>')), 52 help='show <ancestor> generations of ancestor classes not in <projects >')),
53 ("all-ancestors", 53 ("all-ancestors",
54 dict(short="A", default=None, 54 dict(short="A", default=None,
55 help="show all ancestors off all classes in <projects>") ), 55 help="show all ancestors off all classes in <projects>")),
56 ("show-associated", 56 ("show-associated",
57 dict(short='s', action="store", metavar='<ass_level>', type='int', 57 dict(short='s', action="store", metavar='<ass_level>', type='int',
58 help='show <ass_level> levels of associated classes not in <projects>')), 58 help='show <ass_level> levels of associated classes not in <projects>' )),
59 ("all-associated", 59 ("all-associated",
60 dict(short='S', default=None, 60 dict(short='S', default=None,
61 help='show recursively all associated off all associated classes')), 61 help='show recursively all associated off all associated classes')),
62 ("show-builtin",
63 dict(short="b", action="store_true", default=False,
64 help='include builtin objects in representation of classes')),
62 65
63 ("show-builtin", 66 ("module-names",
64 dict(short="b", action="store_true", default=False, 67 dict(short="m", default=None, type='yn', metavar='[yn]',
65 help='include builtin objects in representation of classes')), 68 help='include module name in representation of classes')),
66 69 # TODO : generate dependencies like in pylint
67 ("module-names", 70 # ("package-dependencies",
68 dict(short="m", default=None, type='yn', metavar='[yn]', 71 # dict(short="M", action="store", metavar='<package_depth>', type='int',
69 help='include module name in representation of classes')), 72 # help='show <package_depth> module dependencies beyond modules in \
70 # TODO : generate dependencies like in pylint 73 # <projects> (for the package diagram)')),
71 #("package-dependencies", 74 ("only-classnames",
72 #dict(short="M", action="store", metavar='<package_depth>', type='int', 75 dict(short='k', action="store_true", default=False,
73 #help='show <package_depth> module dependencies beyond modules in \ 76 help="don't show attributes and methods in the class boxes; \
74 #<projects> (for the package diagram)')),
75 ("only-classnames",
76 dict(short='k', action="store_true", default=False,
77 help="don't show attributes and methods in the class boxes; \
78 this disables -f values")), 77 this disables -f values")),
79 ("output", dict(short="o", dest="output_format", action="store", 78 ("output", dict(short="o", dest="output_format", action="store",
80 default="dot", metavar="<format>", 79 default="dot", metavar="<format>",
81 help="create a *.<format> output file if format available.")), 80 help="create a *.<format> output file if format available.") ),
82 ) 81 )
83 # FIXME : quiet mode 82 # FIXME : quiet mode
84 #( ('quiet', 83 #( ('quiet',
85 #dict(help='run quietly', action='store_true', short='q')), ) 84 #dict(help='run quietly', action='store_true', short='q')), )
86 85
87 class PyreverseCommand(ConfigurationMixIn): 86 class Run(ConfigurationMixIn):
88 """base class providing common behaviour for pyreverse commands""" 87 """base class providing common behaviour for pyreverse commands"""
89 88
90 options = OPTIONS 89 options = OPTIONS
91 90
92 def __init__(self, args): 91 def __init__(self, args):
93 ConfigurationMixIn.__init__(self, usage=__doc__) 92 ConfigurationMixIn.__init__(self, usage=__doc__)
94 insert_default_options() 93 insert_default_options()
95 self.manager = ASTNGManager() 94 self.manager = AstroidManager()
96 self.register_options_provider(self.manager) 95 self.register_options_provider(self.manager)
97 args = self.load_command_line_configuration() 96 args = self.load_command_line_configuration()
98 self.run(args) 97 sys.exit(self.run(args))
99 98
100 def run(self, args): 99 def run(self, args):
101 """checking arguments and run project""" 100 """checking arguments and run project"""
102 if not args: 101 if not args:
103 print self.help() 102 print self.help()
104 return 103 return 1
105 # insert current working directory to the python path to recognize 104 # insert current working directory to the python path to recognize
106 # dependencies to local modules even if cwd is not in the PYTHONPATH 105 # dependencies to local modules even if cwd is not in the PYTHONPATH
107 sys.path.insert(0, os.getcwd()) 106 sys.path.insert(0, os.getcwd())
108 try: 107 try:
109 project = self.manager.project_from_files(args) 108 project = self.manager.project_from_files(args)
110 linker = Linker(project, tag=True) 109 linker = Linker(project, tag=True)
111 handler = DiadefsHandler(self.config) 110 handler = DiadefsHandler(self.config)
112 diadefs = handler.get_diadefs(project, linker) 111 diadefs = handler.get_diadefs(project, linker)
113 finally: 112 finally:
114 sys.path.pop(0) 113 sys.path.pop(0)
115 114
116 if self.config.output_format == "vcg": 115 if self.config.output_format == "vcg":
117 writer.VCGWriter(self.config).write(diadefs) 116 writer.VCGWriter(self.config).write(diadefs)
118 else: 117 else:
119 writer.DotWriter(self.config).write(diadefs) 118 writer.DotWriter(self.config).write(diadefs)
119 return 0
120 120
121 121
122 class Run:
123 """pyreverse main class"""
124 def __init__(self, args):
125 """run pyreverse"""
126 PyreverseCommand(args)
127
128 if __name__ == '__main__': 122 if __name__ == '__main__':
129 Run(sys.argv[1:]) 123 Run(sys.argv[1:])
OLDNEW
« no previous file with comments | « third_party/pylint/pyreverse/diagrams.py ('k') | third_party/pylint/pyreverse/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698