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

Class POFile

source code

object --+        
         |        
      list --+    
             |    
     _BaseFile --+
                 |
                POFile

Po (or Pot) file reader/writer. POFile objects inherit the list objects methods.

Example:

>>> po = POFile()
>>> entry1 = POEntry(
...     msgid="Some english text",
...     msgstr="Un texte en anglais"
... )
>>> entry1.occurences = [('testfile', 12),('another_file', 1)]
>>> entry1.comment = "Some useful comment"
>>> entry2 = POEntry(
...     msgid="I need my dirty cheese",
...     msgstr="Je veux mon sale fromage"
... )
>>> entry2.occurences = [('testfile', 15),('another_file', 5)]
>>> entry2.comment = "Another useful comment"
>>> po.append(entry1)
>>> po.append(entry2)
>>> po.header = "Some Header"
>>> print po
# Some Header
msgid ""
msgstr ""
<BLANKLINE>
#. Some useful comment
#: testfile:12 another_file:1
msgid "Some english text"
msgstr "Un texte en anglais"
<BLANKLINE>
#. Another useful comment
#: testfile:15 another_file:5
msgid "I need my dirty cheese"
msgstr "Je veux mon sale fromage"
<BLANKLINE>


Instance Methods [hide private]
 
__str__(self)
Return the string representation of the po file
source code
 
save_as_mofile(self, fpath)
Save the binary representation of the file to fpath.
source code
 
percent_translated(self)
Convenience method that return the percentage of translated messages.
source code
 
translated_entries(self)
Convenience method that return a list of translated entries.
source code
 
untranslated_entries(self)
Convenience method that return a list of untranslated entries.
source code
 
fuzzy_entries(self)
Convenience method that return the list of 'fuzzy' entries.
source code
 
obsolete_entries(self)
Convenience method that return the list of obsolete entries.
source code

Inherited from _BaseFile: __init__, __repr__, charset, metadata_as_entry, ordered_metadata, save, to_binary

Inherited from list: __add__, __contains__, __delitem__, __delslice__, __eq__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __hash__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __reversed__, __rmul__, __setitem__, __setslice__, append, count, extend, index, insert, pop, remove, reverse, sort

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__str__(self)
(Informal representation operator)

source code 
Return the string representation of the po file
Overrides: _BaseFile.__str__

save_as_mofile(self, fpath)

source code 

Save the binary representation of the file to fpath.

Keyword arguments:
  • fpath: string, full or relative path to the file.

percent_translated(self)

source code 

Convenience method that return the percentage of translated messages.

Example:

>>> import polib
>>> po = polib.pofile('tests/test_pofile_helpers.po')
>>> po.percent_translated()
50

translated_entries(self)

source code 

Convenience method that return a list of translated entries.

Example:

>>> import polib
>>> po = polib.pofile('tests/test_pofile_helpers.po')
>>> len(po.translated_entries())
5

untranslated_entries(self)

source code 

Convenience method that return a list of untranslated entries.

Example:

>>> import polib
>>> po = polib.pofile('tests/test_pofile_helpers.po')
>>> len(po.untranslated_entries())
5

fuzzy_entries(self)

source code 

Convenience method that return the list of 'fuzzy' entries.

Example:

>>> import polib
>>> po = polib.pofile('tests/test_pofile_helpers.po')
>>> len(po.fuzzy_entries())
2

obsolete_entries(self)

source code 

Convenience method that return the list of obsolete entries.

Example:

>>> import polib
>>> po = polib.pofile('tests/test_pofile_helpers.po')
>>> len(po.obsolete_entries())
4