mirror of
https://fuchsia.googlesource.com/third_party/github.com/pylint-dev/pylint
synced 2024-09-21 07:58:04 +00:00
Move VNode into ureports.nodes.
This commit is contained in:
parent
2adf87ad3c
commit
d63283e165
|
@ -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):
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
Loading…
Reference in New Issue
Block a user