Package Pyblio :: Package Parsers :: Package Syntax :: Module Tagged :: Class Parser
[show private | hide private]
[frames | no frames]

Type Parser

object --+
         |
        Parser

Known Subclasses:
ISIParser, RISParser

Generic Parser for 'tagged' records, to be derived by actual parsers. An actual subclass will need to at least override the self.line_handler () method to generate events by calling self.push (). The parser is in charge of general state bookkeeping, and that sort of things...
Method Summary
  __init__(self, fd, charset)
Create a new parser for a file containing 'tagged' records
  field_data(self, data)
  field_end(self)
  field_handler(self, tag, value)
Transforms a single field of a record
  field_start(self, tag, line)
  file_start(self)
Override me to have a function called before the first record is to be parsed
  file_stop(self)
Override me to be called after the last record has been parsed
  file_stopping(self)
Override me to be called just at the end of file
  line_handler(self, line, number)
Override me to handle each line of input and generate self.push () events.
  metadata_add(self, tag, value)
Call me to notify the availability of a new meta data
  next(self)
Call this function to get the next record as a list of tuples
  push(self, *ev)
Emit a new event.
  record_end(self)
  record_start(self)
  unread(self, line, count)
Put back a line so that it will be returned by self._pop when it is next invoked.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
int EV_DONE = 6                                                                     
int EV_FIELD_DATA = 3                                                                     
int EV_FIELD_END = 4                                                                     
int EV_FIELD_START = 2                                                                     
int EV_FILE_END = 5                                                                     
int EV_METADATA = 7                                                                     
int EV_RECORD_END = 1                                                                     
int EV_RECORD_START = 0                                                                     
int ST_IN_FIELD = 1                                                                     
int ST_IN_RECORD = 0                                                                     
int ST_OUTSIDE = 2                                                                     

Method Details

__init__(self, fd, charset='UTF-8')
(Constructor)

Create a new parser for a file containing 'tagged' records
Overrides:
__builtin__.object.__init__

field_handler(self, tag, value)

Transforms a single field of a record

file_start(self)

Override me to have a function called before the first record is to be parsed

file_stop(self)

Override me to be called after the last record has been parsed

file_stopping(self)

Override me to be called just at the end of file

line_handler(self, line, number)

Override me to handle each line of input and generate self.push () events. Will be called with line == '' when the end of file is reached.

metadata_add(self, tag, value)

Call me to notify the availability of a new meta data

next(self)

Call this function to get the next record as a list of tuples

('D', [ (tag, value), ...]) ('M', tag, value)

or None when there are no more records

push(self, *ev)

Emit a new event. Available events are listed below, with their additional parameters listed, when needed:
  • self.EV_RECORD_START
  • self.EV_RECORD_END
  • self.EV_FIELD_START, tag, line
  • self.EV_FIELD_DATA, data
  • self.EV_FIELD_END
  • self.EV_FILE_END

unread(self, line, count)

Put back a line so that it will be returned by self._pop when it is next invoked.

Class Variable Details

EV_DONE

Type:
int
Value:
6                                                                     

EV_FIELD_DATA

Type:
int
Value:
3                                                                     

EV_FIELD_END

Type:
int
Value:
4                                                                     

EV_FIELD_START

Type:
int
Value:
2                                                                     

EV_FILE_END

Type:
int
Value:
5                                                                     

EV_METADATA

Type:
int
Value:
7                                                                     

EV_RECORD_END

Type:
int
Value:
1                                                                     

EV_RECORD_START

Type:
int
Value:
0                                                                     

ST_IN_FIELD

Type:
int
Value:
1                                                                     

ST_IN_RECORD

Type:
int
Value:
0                                                                     

ST_OUTSIDE

Type:
int
Value:
2                                                                     

Generated by Epydoc 2.1 on Sun Sep 24 23:52:42 2006 http://epydoc.sf.net