Package horizons :: Package ext :: Module polib :: Class _POFileParser
[hide private]
[frames] | no frames]

Class _POFileParser

source code

object --+
         |
        _POFileParser

A finite state machine to parse efficiently and correctly po file format.

Instance Methods [hide private]
 
__init__(self, pofile, *args, **kwargs)
Constructor.
source code
 
parse(self)
Run the state machine, parse the file line by line and call process() with the current matched symbol.
source code
 
add(self, symbol, states, next_state)
Add a transition to the state machine.
source code
 
process(self, symbol, linenum)
Process the transition corresponding to the current state and the symbol provided.
source code
 
handle_he(self)
Handle a header comment.
source code
 
handle_tc(self)
Handle a translator comment.
source code
 
handle_gc(self)
Handle a generated comment.
source code
 
handle_oc(self)
Handle a file:num occurence.
source code
 
handle_fl(self)
Handle a flags line.
source code
 
handle_pp(self)
Handle a previous msgid_plural line.
source code
 
handle_pm(self)
Handle a previous msgid line.
source code
 
handle_pc(self)
Handle a previous msgctxt line.
source code
 
handle_ct(self)
Handle a msgctxt.
source code
 
handle_mi(self)
Handle a msgid.
source code
 
handle_mp(self)
Handle a msgid plural.
source code
 
handle_ms(self)
Handle a msgstr.
source code
 
handle_mx(self)
Handle a msgstr plural.
source code
 
handle_mc(self)
Handle a msgid or msgstr continuation line.
source code
    Inherited from object
 
__delattr__(...)
x.__delattr__('name') <==> del x.name
 
__format__(...)
default object formatter
 
__getattribute__(...)
x.__getattribute__('name') <==> x.name
 
__hash__(x)
hash(x)
a new object with type S, a subtype of T
__new__(T, S, ...)
 
__reduce__(...)
helper for pickle
 
__reduce_ex__(...)
helper for pickle
 
__repr__(x)
repr(x)
 
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
int
__sizeof__()
size of object in memory, in bytes
 
__str__(x)
str(x)
 
__subclasshook__(...)
Abstract classes can override this to customize issubclass().
Properties [hide private]
    Inherited from object
  __class__
the object's class
Method Details [hide private]

__init__(self, pofile, *args, **kwargs)
(Constructor)

source code 

Constructor.

Keyword arguments:

``pofile``
    string, path to the po file or its content

``encoding``
    string, the encoding to use, defaults to ``default_encoding``
    global variable (optional).

``check_for_duplicates``
    whether to check for duplicate entries when adding entries to the
    file (optional, default: ``False``).

Overrides: object.__init__

add(self, symbol, states, next_state)

source code 

Add a transition to the state machine.

Keywords arguments:

``symbol``
    string, the matched token (two chars symbol).

``states``
    list, a list of states (two chars symbols).

``next_state``
    the next state the fsm will have after the action.

process(self, symbol, linenum)

source code 

Process the transition corresponding to the current state and the
symbol provided.

Keywords arguments:

``symbol``
    string, the matched token (two chars symbol).

``linenum``
    integer, the current line number of the parsed file.