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

Unified Diff: third_party/pylint/pyreverse/diagrams.py

Issue 719313003: Revert "pylint: upgrade to 1.3.1" (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pylint/pyreverse/diadefslib.py ('k') | third_party/pylint/pyreverse/main.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pylint/pyreverse/diagrams.py
diff --git a/third_party/pylint/pyreverse/diagrams.py b/third_party/pylint/pyreverse/diagrams.py
index 28cc500108dcb053175bfd4cf20b91b29b1d0932..23d23eff8bdaf32a6c7b2e38f6ff74051da95674 100644
--- a/third_party/pylint/pyreverse/diagrams.py
+++ b/third_party/pylint/pyreverse/diagrams.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2004-2013 LOGILAB S.A. (Paris, FRANCE).
+# Copyright (c) 2004-2010 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This program is free software; you can redistribute it and/or modify it under
@@ -12,16 +12,24 @@
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""diagram objects
"""
-import astroid
+from logilab import astng
from pylint.pyreverse.utils import is_interface, FilterMixIn
-class Figure(object):
+def set_counter(value):
+ """Figure counter (re)set"""
+ Figure._UID_COUNT = value
+
+class Figure:
"""base class for counter handling"""
-
+ _UID_COUNT = 0
+ def __init__(self):
+ Figure._UID_COUNT += 1
+ self.fig_id = Figure._UID_COUNT
+
class Relationship(Figure):
"""a relation ship from an object in the diagram to another
"""
@@ -31,10 +39,10 @@ class Relationship(Figure):
self.to_object = to_object
self.type = relation_type
self.name = name
-
-
+
+
class DiagramEntity(Figure):
- """a diagram object, i.e. a label associated to an astroid node
+ """a diagram object, i.e. a label associated to an astng node
"""
def __init__(self, title='No name', node=None):
Figure.__init__(self)
@@ -54,12 +62,7 @@ class ClassDiagram(Figure, FilterMixIn):
self._nodes = {}
self.depends = []
- def get_relationships(self, role):
- # sorted to get predictable (hence testable) results
- return sorted(self.relationships.get(role, ()),
- key=lambda x: (x.from_object.fig_id, x.to_object.fig_id))
-
- def add_relationship(self, from_object, to_object,
+ def add_relationship(self, from_object, to_object,
relation_type, name=None):
"""create a relation ship
"""
@@ -85,15 +88,12 @@ class ClassDiagram(Figure, FilterMixIn):
if names:
node_name = "%s : %s" % (node_name, ", ".join(names))
attrs.append(node_name)
- return sorted(attrs)
+ return attrs
def get_methods(self, node):
"""return visible methods"""
- methods = [
- m for m in node.values()
- if isinstance(m, astroid.Function) and self.show_attr(m.name)
- ]
- return sorted(methods, key=lambda n: n.name)
+ return [m for m in node.values()
+ if isinstance(m, astng.Function) and self.show_attr(m.name)]
def add_object(self, title, node):
"""create a diagram object
@@ -107,9 +107,9 @@ class ClassDiagram(Figure, FilterMixIn):
"""return class names if needed in diagram"""
names = []
for ass_node in nodes:
- if isinstance(ass_node, astroid.Instance):
+ if isinstance(ass_node, astng.Instance):
ass_node = ass_node._proxied
- if isinstance(ass_node, astroid.Class) \
+ if isinstance(ass_node, astng.Class) \
and hasattr(ass_node, "name") and not self.has_node(ass_node):
if ass_node.name not in names:
ass_name = ass_node.name
@@ -125,15 +125,15 @@ class ClassDiagram(Figure, FilterMixIn):
"""return true if the given node is included in the diagram
"""
return node in self._nodes
-
+
def object_from_node(self, node):
"""return the diagram object mapped to node
"""
return self._nodes[node]
-
+
def classes(self):
"""return all class nodes in the diagram"""
- return [o for o in self.objects if isinstance(o.node, astroid.Class)]
+ return [o for o in self.objects if isinstance(o.node, astng.Class)]
def classe(self, name):
"""return a class by its name, raise KeyError if not found
@@ -142,7 +142,7 @@ class ClassDiagram(Figure, FilterMixIn):
if klass.node.name == name:
return klass
raise KeyError(name)
-
+
def extract_relationships(self):
"""extract relation ships between nodes in the diagram
"""
@@ -173,9 +173,9 @@ class ClassDiagram(Figure, FilterMixIn):
for name, values in node.instance_attrs_type.items() + \
node.locals_type.items():
for value in values:
- if value is astroid.YES:
+ if value is astng.YES:
continue
- if isinstance(value, astroid.Instance):
+ if isinstance( value, astng.Instance):
value = value._proxied
try:
ass_obj = self.object_from_node(value)
@@ -188,10 +188,10 @@ class PackageDiagram(ClassDiagram):
"""package diagram handling
"""
TYPE = 'package'
-
+
def modules(self):
"""return all module nodes in the diagram"""
- return [o for o in self.objects if isinstance(o.node, astroid.Module)]
+ return [o for o in self.objects if isinstance(o.node, astng.Module)]
def module(self, name):
"""return a module by its name, raise KeyError if not found
@@ -216,12 +216,12 @@ class PackageDiagram(ClassDiagram):
if mod_name == "%s.%s" % (package.rsplit('.', 1)[0], name):
return mod
raise KeyError(name)
-
+
def add_from_depend(self, node, from_module):
"""add dependencies created by from-imports
"""
mod_name = node.root().name
- obj = self.module(mod_name)
+ obj = self.module( mod_name )
if from_module not in obj.node.depends:
obj.node.depends.append(from_module)
« no previous file with comments | « third_party/pylint/pyreverse/diadefslib.py ('k') | third_party/pylint/pyreverse/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698