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)
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 occurrence.
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__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __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)

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.