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

Class MOFile

source code

object --+        
         |        
      list --+    
             |    
     _BaseFile --+
                 |
                MOFile

Mo file reader/writer. MOFile objects inherit the list objects methods.

**Example**:

>>> mo = MOFile()
>>> entry1 = POEntry(
...     msgid="Some english text",
...     msgstr="Un texte en anglais"
... )
>>> entry2 = POEntry(
...     msgid="I need my dirty cheese",
...     msgstr="Je veux mon sale fromage"
... )
>>> entry3 = MOEntry(
...     msgid='Some entry with quotes " \"',
...     msgstr='Un message unicode avec des quotes " \"'
... )
>>> mo.append(entry1)
>>> mo.append(entry2)
>>> mo.append(entry3)
>>> print(mo)
msgid ""
msgstr ""
<BLANKLINE>
msgid "Some english text"
msgstr "Un texte en anglais"
<BLANKLINE>
msgid "I need my dirty cheese"
msgstr "Je veux mon sale fromage"
<BLANKLINE>
msgid "Some entry with quotes \" \""
msgstr "Un message unicode avec des quotes \" \""
<BLANKLINE>
Instance Methods [hide private]
new list
__init__(self, *args, **kwargs)
MOFile constructor.
source code
 
save_as_pofile(self, fpath)
Save the string representation of the file to *fpath*.
source code
 
save(self, fpath)
Save the binary representation of the file to *fpath*.
source code
 
percent_translated(self)
Convenience method to keep the same interface with POFile instances.
source code
 
translated_entries(self)
Convenience method to keep the same interface with POFile instances.
source code
 
untranslated_entries(self)
Convenience method to keep the same interface with POFile instances.
source code
 
fuzzy_entries(self)
Convenience method to keep the same interface with POFile instances.
source code
 
obsolete_entries(self)
Convenience method to keep the same interface with POFile instances.
source code

Inherited from _BaseFile: __repr__, __str__, find, metadata_as_entry, ordered_metadata, to_binary

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

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __subclasshook__

Class Variables [hide private]

Inherited from list: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

MOFile constructor. Mo files have two other properties:

  • magic_number: the magic_number of the binary file,
  • version: the version of the mo spec.
Returns: new list
Overrides: object.__init__

save_as_pofile(self, fpath)

source code 

Save the string representation of the file to *fpath*.

**Keyword argument**:

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

save(self, fpath)

source code 

Save the binary representation of the file to *fpath*.

**Keyword argument**:

  • *fpath*: string, full or relative path to the file.
Overrides: _BaseFile.save