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

Class _POFileParser

source code

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

Instance Methods [hide private]
 
__init__(self, fpath)
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_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
Method Details [hide private]

__init__(self, fpath)
(Constructor)

source code 

Constructor.

Keyword argument:
  • fpath: string, path to the po file

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