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

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

Issue 753543006: pylint: upgrade to 1.4.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « third_party/pylint/lint.py ('k') | third_party/pylint/pyreverse/diagrams.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-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
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return 92 return
93 for ancestor in node.ancestors(recurs=False): 93 for ancestor in node.ancestors(recurs=False):
94 if not self.show_node(ancestor): 94 if not self.show_node(ancestor):
95 continue 95 continue
96 yield ancestor 96 yield ancestor
97 97
98 def get_associated(self, klass_node, level): 98 def get_associated(self, klass_node, level):
99 """return associated nodes of a class node""" 99 """return associated nodes of a class node"""
100 if level == 0: 100 if level == 0:
101 return 101 return
102 for ass_nodes in klass_node.instance_attrs_type.values() + \ 102 for ass_nodes in list(klass_node.instance_attrs_type.values()) + \
103 klass_node.locals_type.values(): 103 list(klass_node.locals_type.values()):
104 for ass_node in ass_nodes: 104 for ass_node in ass_nodes:
105 if isinstance(ass_node, astroid.Instance): 105 if isinstance(ass_node, astroid.Instance):
106 ass_node = ass_node._proxied 106 ass_node = ass_node._proxied
107 if not (isinstance(ass_node, astroid.Class) 107 if not (isinstance(ass_node, astroid.Class)
108 and self.show_node(ass_node)): 108 and self.show_node(ass_node)):
109 continue 109 continue
110 yield ass_node 110 yield ass_node
111 111
112 def extract_classes(self, klass_node, anc_level, ass_level): 112 def extract_classes(self, klass_node, anc_level, ass_level):
113 """extract recursively classes related to klass_node""" 113 """extract recursively classes related to klass_node"""
(...skipping 24 matching lines...) Expand all
138 138
139 create a diagram definition for packages 139 create a diagram definition for packages
140 """ 140 """
141 mode = self.config.mode 141 mode = self.config.mode
142 if len(node.modules) > 1: 142 if len(node.modules) > 1:
143 self.pkgdiagram = PackageDiagram('packages %s' % node.name, mode) 143 self.pkgdiagram = PackageDiagram('packages %s' % node.name, mode)
144 else: 144 else:
145 self.pkgdiagram = None 145 self.pkgdiagram = None
146 self.classdiagram = ClassDiagram('classes %s' % node.name, mode) 146 self.classdiagram = ClassDiagram('classes %s' % node.name, mode)
147 147
148 def leave_project(self, node): 148 def leave_project(self, node): # pylint: disable=unused-argument
149 """leave the astroid.Project node 149 """leave the astroid.Project node
150 150
151 return the generated diagram definition 151 return the generated diagram definition
152 """ 152 """
153 if self.pkgdiagram: 153 if self.pkgdiagram:
154 return self.pkgdiagram, self.classdiagram 154 return self.pkgdiagram, self.classdiagram
155 return self.classdiagram, 155 return self.classdiagram,
156 156
157 def visit_module(self, node): 157 def visit_module(self, node):
158 """visit an astroid.Module node 158 """visit an astroid.Module node
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 related klasses 191 related klasses
192 """ 192 """
193 193
194 self.classdiagram = ClassDiagram(klass, self.config.mode) 194 self.classdiagram = ClassDiagram(klass, self.config.mode)
195 if len(project.modules) > 1: 195 if len(project.modules) > 1:
196 module, klass = klass.rsplit('.', 1) 196 module, klass = klass.rsplit('.', 1)
197 module = project.get_module(module) 197 module = project.get_module(module)
198 else: 198 else:
199 module = project.modules[0] 199 module = project.modules[0]
200 klass = klass.split('.')[-1] 200 klass = klass.split('.')[-1]
201 klass = module.ilookup(klass).next() 201 klass = next(module.ilookup(klass))
202 202
203 anc_level, ass_level = self._get_levels() 203 anc_level, ass_level = self._get_levels()
204 self.extract_classes(klass, anc_level, ass_level) 204 self.extract_classes(klass, anc_level, ass_level)
205 return self.classdiagram 205 return self.classdiagram
206 206
207 # diagram handler ############################################################# 207 # diagram handler #############################################################
208 208
209 class DiadefsHandler(object): 209 class DiadefsHandler(object):
210 """handle diagram definitions : 210 """handle diagram definitions :
211 211
(...skipping 12 matching lines...) Expand all
224 # read and interpret diagram definitions (Diadefs) 224 # read and interpret diagram definitions (Diadefs)
225 diagrams = [] 225 diagrams = []
226 generator = ClassDiadefGenerator(linker, self) 226 generator = ClassDiadefGenerator(linker, self)
227 for klass in self.config.classes: 227 for klass in self.config.classes:
228 diagrams.append(generator.class_diagram(project, klass)) 228 diagrams.append(generator.class_diagram(project, klass))
229 if not diagrams: 229 if not diagrams:
230 diagrams = DefaultDiadefGenerator(linker, self).visit(project) 230 diagrams = DefaultDiadefGenerator(linker, self).visit(project)
231 for diagram in diagrams: 231 for diagram in diagrams:
232 diagram.extract_relationships() 232 diagram.extract_relationships()
233 return diagrams 233 return diagrams
OLDNEW
« no previous file with comments | « third_party/pylint/lint.py ('k') | third_party/pylint/pyreverse/diagrams.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698