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

Class POEntry

source code

object --+    
         |    
_BaseEntry --+
             |
            POEntry

Represents a po file entry.

**Examples**:

>>> entry = POEntry(msgid='Welcome', msgstr='Bienvenue')
>>> entry.occurrences = [('welcome.py', 12), ('anotherfile.py', 34)]
>>> print(entry)
#: welcome.py:12 anotherfile.py:34
msgid "Welcome"
msgstr "Bienvenue"
<BLANKLINE>
>>> entry = POEntry()
>>> entry.occurrences = [('src/spam.c', 32), ('src/eggs.c', 45)]
>>> entry.tcomment = 'A plural translation'
>>> entry.flags.append('c-format')
>>> entry.msgid = 'I have spam but no egg !'
>>> entry.msgid_plural = 'I have spam and %d eggs !'
>>> entry.msgstr_plural[0] = "J'ai du jambon mais aucun oeuf !"
>>> entry.msgstr_plural[1] = "J'ai du jambon et %d oeufs !"
>>> print(entry)
# A plural translation
#: src/spam.c:32 src/eggs.c:45
#, c-format
msgid "I have spam but no egg !"
msgid_plural "I have spam and %d eggs !"
msgstr[0] "J'ai du jambon mais aucun oeuf !"
msgstr[1] "J'ai du jambon et %d oeufs !"
<BLANKLINE>
Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
POEntry constructor.
source code
 
__str__(self, wrapwidth=78)
Return the string representation of the entry.
source code
 
__cmp__(self, other)
Called by comparison operations if rich comparison is not defined.
source code
 
translated(self)
Return True if the entry has been translated or False
source code

Inherited from _BaseEntry: __repr__

Inherited from _BaseEntry (private): _decode, _str_field

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

POEntry constructor.

Overrides: object.__init__

__str__(self, wrapwidth=78)
(Informal representation operator)

source code 

Return the string representation of the entry.

Overrides: object.__str__

__cmp__(self, other)
(Comparison operator)

source code 

Called by comparison operations if rich comparison is not defined.

**Tests**: >>> a = POEntry(msgid='a', occurrences=[('b.py', 1), ('b.py', 3)]) >>> b = POEntry(msgid='b', occurrences=[('b.py', 1), ('b.py', 3)]) >>> c1 = POEntry(msgid='c1', occurrences=[('a.py', 1), ('b.py', 1)]) >>> c2 = POEntry(msgid='c2', occurrences=[('a.py', 1), ('a.py', 3)]) >>> po = POFile() >>> po.append(a) >>> po.append(b) >>> po.append(c1) >>> po.append(c2) >>> po.sort() >>> print(po) # msgid "" msgstr "" <BLANKLINE> #: a.py:1 a.py:3 msgid "c2" msgstr "" <BLANKLINE> #: a.py:1 b.py:1 msgid "c1" msgstr "" <BLANKLINE> #: b.py:1 b.py:3 msgid "a" msgstr "" <BLANKLINE> #: b.py:1 b.py:3 msgid "b" msgstr "" <BLANKLINE>