Back to index

python-biopython  1.60
Public Member Functions | Private Member Functions | Private Attributes
Bio.ParserSupport.TaggingConsumer Class Reference
Inheritance diagram for Bio.ParserSupport.TaggingConsumer:
Inheritance graph
[legend]
Collaboration diagram for Bio.ParserSupport.TaggingConsumer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def unhandled_section
def unhandled
def __getattr__

Private Member Functions

def _print_name

Private Attributes

 _handle
 _colwidth
 _maxwidth

Detailed Description

A Consumer that tags the data stream with the event and
prints it to a handle.  Useful for debugging.

Definition at line 86 of file ParserSupport.py.


Constructor & Destructor Documentation

def Bio.ParserSupport.TaggingConsumer.__init__ (   self,
  handle = None,
  colwidth = 15,
  maxwidth = 80 
)
TaggingConsumer(handle=sys.stdout, colwidth=15, maxwidth=80)

Definition at line 91 of file ParserSupport.py.

00091 
00092     def __init__(self, handle=None, colwidth=15, maxwidth=80):
00093         """TaggingConsumer(handle=sys.stdout, colwidth=15, maxwidth=80)"""
00094         # I can't assign sys.stdout to handle in the argument list.
00095         # If I do that, handle will be assigned the value of sys.stdout
00096         # the first time this function is called.  This will fail if
00097         # the user has assigned sys.stdout to some other file, which may
00098         # be closed or invalid at a later time.
00099         if handle is None:
00100             handle = sys.stdout
00101         self._handle = handle
00102         self._colwidth = colwidth
00103         self._maxwidth = maxwidth


Member Function Documentation

Reimplemented from Bio.ParserSupport.AbstractConsumer.

Definition at line 120 of file ParserSupport.py.

00120 
00121     def __getattr__(self, attr):
00122         if attr[:6] == 'start_' or attr[:4] == 'end_':
00123             method = lambda a=attr, s=self: s._print_name(a)
00124         else:
00125             method = lambda x, a=attr, s=self: s._print_name(a, x)
00126         return method

def Bio.ParserSupport.TaggingConsumer._print_name (   self,
  name,
  data = None 
) [private]

Definition at line 110 of file ParserSupport.py.

00110 
00111     def _print_name(self, name, data=None):
00112         if data is None:
00113             # Write the name of a section.
00114             self._handle.write("%s %s\n" % ("*"*self._colwidth, name))
00115         else:
00116             # Write the tag and line.
00117             self._handle.write("%-*s: %s\n" % (
00118                 self._colwidth, name[:self._colwidth],
00119                 data[:self._maxwidth-self._colwidth-2].rstrip()))

Here is the caller graph for this function:

def Bio.ParserSupport.TaggingConsumer.unhandled (   self,
  data 
)

Definition at line 107 of file ParserSupport.py.

00107 
00108     def unhandled(self, data):
00109         self._print_name('unhandled', data)

Here is the call graph for this function:

Definition at line 104 of file ParserSupport.py.

00104 
00105     def unhandled_section(self):
00106         self._print_name('unhandled_section')

Here is the call graph for this function:


Member Data Documentation

Definition at line 101 of file ParserSupport.py.

Definition at line 100 of file ParserSupport.py.

Definition at line 102 of file ParserSupport.py.


The documentation for this class was generated from the following file: