From d63283e1657dee36bf8fde58ac61c20921a59388 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Fri, 16 Oct 2015 15:44:55 +0300 Subject: [PATCH] Move VNode into ureports.nodes. --- pylint/reporters/ureports/nodes.py | 41 ++++++++++++++++++++- pylint/reporters/ureports/tree.py | 57 ------------------------------ 2 files changed, 40 insertions(+), 58 deletions(-) delete mode 100644 pylint/reporters/ureports/tree.py diff --git a/pylint/reporters/ureports/nodes.py b/pylint/reporters/ureports/nodes.py index 7a0dba41f..1c0dc7d37 100644 --- a/pylint/reporters/ureports/nodes.py +++ b/pylint/reporters/ureports/nodes.py @@ -22,7 +22,46 @@ A micro report is a tree of layout and content objects. from six import string_types -from pylint.reporters.ureports.tree import VNode + +class VNode(object): + + def __init__(self, nid=None): + self.id = nid + # navigation + self.parent = None + self.children = [] + + def __iter__(self): + return iter(self.children) + + def append(self, child): + """add a node to children""" + self.children.append(child) + child.parent = self + + def insert(self, index, child): + """insert a child node""" + self.children.insert(index, child) + child.parent = self + + def _get_visit_name(self): + """ + return the visit name for the mixed class. When calling 'accept', the + method <'visit_' + name returned by this method> will be called on the + visitor + """ + try: + return self.TYPE.replace('-', '_') + except Exception: + return self.__class__.__name__.lower() + + def accept(self, visitor, *args, **kwargs): + func = getattr(visitor, 'visit_%s' % self._get_visit_name()) + return func(self, *args, **kwargs) + + def leave(self, visitor, *args, **kwargs): + func = getattr(visitor, 'leave_%s' % self._get_visit_name()) + return func(self, *args, **kwargs) class BaseComponent(VNode): diff --git a/pylint/reporters/ureports/tree.py b/pylint/reporters/ureports/tree.py deleted file mode 100644 index 0e69772db..000000000 --- a/pylint/reporters/ureports/tree.py +++ /dev/null @@ -1,57 +0,0 @@ -# copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved. -# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr -# -# This file is part of pylint. -# -# logilab-common is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, either version 2.1 of the License, or (at your option) any -# later version. -# -# pylint is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License along -# with pylint. If not, see . - -class VNode(object): - - def __init__(self, nid=None): - self.id = nid - # navigation - self.parent = None - self.children = [] - - def __iter__(self): - return iter(self.children) - - def append(self, child): - """add a node to children""" - self.children.append(child) - child.parent = self - - def insert(self, index, child): - """insert a child node""" - self.children.insert(index, child) - child.parent = self - - def _get_visit_name(self): - """ - return the visit name for the mixed class. When calling 'accept', the - method <'visit_' + name returned by this method> will be called on the - visitor - """ - try: - return self.TYPE.replace('-', '_') - except Exception: - return self.__class__.__name__.lower() - - def accept(self, visitor, *args, **kwargs): - func = getattr(visitor, 'visit_%s' % self._get_visit_name()) - return func(self, *args, **kwargs) - - def leave(self, visitor, *args, **kwargs): - func = getattr(visitor, 'leave_%s' % self._get_visit_name()) - return func(self, *args, **kwargs)