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

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

Issue 1920403002: [content/test/gpu] Run pylint check of gpu tests in unittest instead of PRESUBMIT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update path to LICENSE.txt of logilab/README.chromium Created 4 years, 7 months 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
OLDNEW
(Empty)
1 # # Copyright (c) 2000-2013 LOGILAB S.A. (Paris, FRANCE).
2 # http://www.logilab.fr/ -- mailto:contact@logilab.fr
3 #
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
6 # Foundation; either version 2 of the License, or (at your option) any later
7 # version.
8 #
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
11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 #
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.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 """
17 %prog [options] <packages>
18
19 create UML diagrams for classes and modules in <packages>
20 """
21 from __future__ import print_function
22
23 import sys, os
24 from logilab.common.configuration import ConfigurationMixIn
25 from astroid.manager import AstroidManager
26 from astroid.inspector import Linker
27
28 from pylint.pyreverse.diadefslib import DiadefsHandler
29 from pylint.pyreverse import writer
30 from pylint.pyreverse.utils import insert_default_options
31
32 OPTIONS = (
33 ("filter-mode",
34 dict(short='f', default='PUB_ONLY', dest='mode', type='string',
35 action='store', metavar='<mode>',
36 help="""filter attributes and functions according to
37 <mode>. Correct modes are :
38 'PUB_ONLY' filter all non public attributes
39 [DEFAULT], equivalent to PRIVATE+SPECIAL_A
40 'ALL' no filter
41 'SPECIAL' filter Python special functions
42 except constructor
43 'OTHER' filter protected and private
44 attributes""")),
45
46 ("class",
47 dict(short='c', action="append", metavar="<class>", dest="classes", default =[],
48 help="create a class diagram with all classes related to <class>;\
49 this uses by default the options -ASmy")),
50
51 ("show-ancestors",
52 dict(short="a", action="store", metavar='<ancestor>', type='int',
53 help='show <ancestor> generations of ancestor classes not in <projects >')),
54 ("all-ancestors",
55 dict(short="A", default=None,
56 help="show all ancestors off all classes in <projects>")),
57 ("show-associated",
58 dict(short='s', action="store", metavar='<ass_level>', type='int',
59 help='show <ass_level> levels of associated classes not in <projects>' )),
60 ("all-associated",
61 dict(short='S', default=None,
62 help='show recursively all associated off all associated classes')),
63 ("show-builtin",
64 dict(short="b", action="store_true", default=False,
65 help='include builtin objects in representation of classes')),
66
67 ("module-names",
68 dict(short="m", default=None, type='yn', metavar='[yn]',
69 help='include module name in representation of classes')),
70 # TODO : generate dependencies like in pylint
71 # ("package-dependencies",
72 # dict(short="M", action="store", metavar='<package_depth>', type='int',
73 # help='show <package_depth> module dependencies beyond modules in \
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")),
79 ("output", dict(short="o", dest="output_format", action="store",
80 default="dot", metavar="<format>",
81 help="create a *.<format> output file if format available.") ),
82 )
83 # FIXME : quiet mode
84 #( ('quiet',
85 #dict(help='run quietly', action='store_true', short='q')), )
86
87 class Run(ConfigurationMixIn):
88 """base class providing common behaviour for pyreverse commands"""
89
90 options = OPTIONS
91
92 def __init__(self, args):
93 ConfigurationMixIn.__init__(self, usage=__doc__)
94 insert_default_options()
95 self.manager = AstroidManager()
96 self.register_options_provider(self.manager)
97 args = self.load_command_line_configuration()
98 sys.exit(self.run(args))
99
100 def run(self, args):
101 """checking arguments and run project"""
102 if not args:
103 print(self.help())
104 return 1
105 # insert current working directory to the python path to recognize
106 # dependencies to local modules even if cwd is not in the PYTHONPATH
107 sys.path.insert(0, os.getcwd())
108 try:
109 project = self.manager.project_from_files(args)
110 linker = Linker(project, tag=True)
111 handler = DiadefsHandler(self.config)
112 diadefs = handler.get_diadefs(project, linker)
113 finally:
114 sys.path.pop(0)
115
116 if self.config.output_format == "vcg":
117 writer.VCGWriter(self.config).write(diadefs)
118 else:
119 writer.DotWriter(self.config).write(diadefs)
120 return 0
121
122
123 if __name__ == '__main__':
124 Run(sys.argv[1:])
OLDNEW
« no previous file with comments | « third_party/pylint/pylint/pyreverse/diagrams.py ('k') | third_party/pylint/pylint/pyreverse/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698