Refactoring

- drop _printer suffix from printer classes.
This commit is contained in:
Dhananjay Balan
2013-07-13 16:31:59 +05:30
committed by Chris Johns
parent a785e254f2
commit 0967a1b679
8 changed files with 30 additions and 75 deletions

View File

@@ -245,53 +245,4 @@ class control:
def name(self):
is_string = information.is_string(self._id.api(), self._id._class())
return str(name(self.object['name'], is_string))
class control_printer:
class iterator:
"""Use an iterator for each field expanded from the id so GDB output
is formatted correctly."""
def __init__(self, object):
self.object = object
self.count = 0
def __iter__(self):
return self
def next(self):
self.count += 1
if self.count == 1:
return self.object.node()
elif self.count == 2:
return self.object.id()
elif self.count == 3:
return self.object.name()
raise StopIteration
def to_string(self):
return ''
def __init__(self, object):
self.object = control(object)
@staticmethod
def key(i):
if i == 0:
return 'Node'
elif i == 1:
return 'id'
elif i == 2:
return 'name'
return 'bad'
def children(self):
counter = itertools.imap (self.key, itertools.count())
return itertools.izip (counter, self.iterator(self.object))
def display_hint (self):
return 'struct'
return str(name(self.object['name'], is_string))