Package translate :: Package storage :: Module pypo :: Class pounit

[hide private]
[frames] | no frames]

# Class pounit

source code

Instance Methods | [hide private]

__init__(self, source=None, encoding="UTF-8") Constructs a TranslationUnit containing the given source string. | source code

_initallcomments(self, blankall=False) Initialises allcomments | source code

_get_all_comments(self) | source code

allcomments(self) | source code

getalttrans(self) Return a list of alternate units. | source code

__deepcopy__(self, memo={}) | source code

copy(self) | source code

_msgidlen(self) | source code

_msgstrlen(self) | source code

merge(self, otherpo, overwrite=False, comments=True, authoritative=False) Merges the otherpo (with the same msgid) into this one. | source code

isheader(self) Indicates whether this unit is a header. | source code

isblank(self) Used to see if this unit has no source or target string. | source code

hastypecomment(self, typecomment) Check whether the given type comment is present | source code

hasmarkedcomment(self, commentmarker) Check whether the given comment marker is present as # (commentmarker) ... | source code

settypecomment(self, typecomment, present=True) Alters whether a given typecomment is present | source code

isfuzzy(self) Indicates whether this unit is fuzzy. | source code

markfuzzy(self, present=True) Marks the unit as fuzzy or not. | source code

_domarkfuzzy(self, present=True) | source code

infer_state(self) Empty method that should be overridden in sub-classes to infer the current state(_n) of the unit from its current state. | source code

isobsolete(self) indicate whether a unit is obsolete | source code

makeobsolete(self) Makes this unit obsolete | source code

resurrect(self) Makes an obsolete unit normal | source code

hasplural(self) returns whether this pounit contains plural strings... | source code

parse(self, src) | source code

_getmsgpartstr(self, partname, partlines, partcomments="") | source code

_encodeifneccessary(self, output) encodes unicode strings and returns other strings unchanged | source code

__str__(self) convert to a string. | source code

_getoutput(self) return this po element as a string | source code

String

_extract_msgidcomments(self, text=None) Extract KDE style msgid comments from the unit. | source code

setmsgidcomment(self, msgidcomment) | source code

getcontext(self) Get the message context. | source code

setcontext(self, context) Set the message context | source code

string

getid(self) Returns a unique identifier for this unit. | source code

Inherited from `pocommon.pounit`: `isreview`, `istranslatable`, `istranslated`, `markreviewneeded` Inherited from `base.TranslationUnit`: `__eq__`, `get_state_id`, `get_state_n`, `getunits`, `multistring_to_rich`, `set_state_n`, `setid`, `unit_iter` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`
Source

_get_source_vars(self, msgid, msgid_plural) | source code

_set_source_vars(self, source) | source code

getsource(self) Returns the unescaped msgid | source code

setsource(self, source) Sets the msgid to the given (unescaped) value. | source code

_get_prev_source(self) Returns the unescaped msgid | source code

_set_prev_source(self, source) Sets the msgid to the given (unescaped) value. | source code

Inherited from `base.TranslationUnit`: `getsourcelanguage` Inherited from `base.TranslationUnit` (private): `_get_rich_source`, `_set_rich_source`
Target

gettarget(self) Returns the unescaped msgstr | source code

settarget(self, target) Sets the msgstr to the given (unescaped) value | source code

Inherited from `base.TranslationUnit`: `gettargetlanguage`, `gettargetlen` Inherited from `base.TranslationUnit` (private): `_get_rich_target`, `_set_rich_target`
Notes

getnotes(self, origin=None) Return comments based on origin value (programmer, developer, source code and translator) | source code

addnote(self, text, origin=None, position="append") This is modeled on the XLIFF method. | source code

removenotes(self) Remove all the translator's notes (other comments) | source code

Locations

List

getlocations(self) Get a list of locations from sourcecomments in the PO unit | source code

addlocation(self, location) Add a location to sourcecomments in the PO unit | source code

Inherited from `base.TranslationUnit`: `addlocations`
Errors
Inherited from `pocommon.pounit`: `adderror`, `geterrors`

Class Methods | [hide private]

Inherited from `base.TranslationUnit`: `buildfromunit`, `rich_to_multistring`

Class Variables | [hide private]

| __shallow__ = `['_store']`
| msgidcomment = `property(_extract_msgidcomments, setmsgidcomment)`
Inherited from `base.TranslationUnit`: `STATE`, `S_EMPTY`, `S_FINAL`, `S_NEEDS_REVIEW`, `S_NEEDS_WORK`, `S_OBSOLETE`, `S_REJECTED`, `S_UNREVIEWED`, `rich_parsers`
Source
| source = `property(getsource, setsource)`
| prev_source = `property(_get_prev_source, _set_prev_source)`
Target
| target = `property(gettarget, settarget)`

Properties | [hide private]

Inherited from `base.TranslationUnit`: `rid`, `xid` Inherited from `object`: `__class__`
Source
Inherited from `base.TranslationUnit`: `rich_source`
Target
Inherited from `base.TranslationUnit`: `rich_target`

Method Details | [hide private]

### __init__(self, source=None, encoding="UTF-8")
(Constructor)

source code

Constructs a TranslationUnit containing the given source string.

Overrides: object.__init__
  (inherited documentation)

### setsource(self, source)

source code

Sets the msgid to the given (unescaped) value.

Parameters:
  - `source` - an unescaped source string.
Overrides: base.TranslationUnit.setsource

### _set_prev_source(self, source)

source code

Sets the msgid to the given (unescaped) value.

Parameters:
  - `source` - an unescaped source string.

### settarget(self, target)

source code

Sets the msgstr to the given (unescaped) value

Overrides: base.TranslationUnit.settarget

### getalttrans(self)

source code

Return a list of alternate units.

Previous msgid and current msgstr is combined to form a single alternative unit.

### getnotes(self, origin=None)

source code

Return comments based on origin value (programmer, developer, source code and translator)

Overrides: base.TranslationUnit.getnotes

### addnote(self, text, origin=None, position="append")

source code

This is modeled on the XLIFF method. See xliff.py::xliffunit.addnote

Parameters:
  - `text` - Usually just a sentence or two.
  - `origin` - Specifies who/where the comment comes from. Origin can be one of the following text strings:
    - 'translator'
    - 'developer', 'programmer', 'source code' (synonyms)
Overrides: base.TranslationUnit.addnote

### removenotes(self)

source code

Remove all the translator's notes (other comments)

Overrides: base.TranslationUnit.removenotes

### merge(self, otherpo, overwrite=False, comments=True, authoritative=False)

source code

Merges the otherpo (with the same msgid) into this one.

Overwrite non-blank self.msgstr only if overwrite is True merge comments only if comments is True

Overrides: base.TranslationUnit.merge

### isheader(self)

source code

Indicates whether this unit is a header.

Overrides: base.TranslationUnit.isheader
  (inherited documentation)

### isblank(self)

source code

Used to see if this unit has no source or target string.

Overrides: base.TranslationUnit.isblank
  (inherited documentation)

### isfuzzy(self)

source code

Indicates whether this unit is fuzzy.

Overrides: base.TranslationUnit.isfuzzy
  (inherited documentation)

### markfuzzy(self, present=True)

source code

Marks the unit as fuzzy or not.

Overrides: base.TranslationUnit.markfuzzy
  (inherited documentation)

### infer_state(self)

source code

Empty method that should be overridden in sub-classes to infer the current state(_n) of the unit from its current state.

Overrides: base.TranslationUnit.infer_state
  (inherited documentation)

### isobsolete(self)

source code

indicate whether a unit is obsolete

Overrides: base.TranslationUnit.isobsolete
  (inherited documentation)

### makeobsolete(self)

source code

Makes this unit obsolete

Overrides: base.TranslationUnit.makeobsolete

### hasplural(self)

source code

returns whether this pounit contains plural strings...

Overrides: base.TranslationUnit.hasplural

### __str__(self)
(Informal representation operator)

source code

convert to a string. double check that unicode is handled somehow here

Overrides: object.__str__

### getlocations(self)

source code

Get a list of locations from sourcecomments in the PO unit

rtype: List return: A list of the locations with '#: ' stripped

Returns: List
Overrides: base.TranslationUnit.getlocations

### addlocation(self, location)

source code

Add a location to sourcecomments in the PO unit

Parameters:
  - `location` (String) - Text location e.g. 'file.c:23' does not include #:
Overrides: base.TranslationUnit.addlocation

### _extract_msgidcomments(self, text=None)

source code

Extract KDE style msgid comments from the unit.

Returns: String
  Returns the extracted msgidcomments found in this unit's msgid.

### getcontext(self)

source code

Get the message context.

Overrides: base.TranslationUnit.getcontext

### setcontext(self, context)

source code

Set the message context

Overrides: base.TranslationUnit.setcontext
  (inherited documentation)

### getid(self)

source code

Returns a unique identifier for this unit.

Returns: string
  an identifier for this unit that is unique in the store

  Derived classes should override this in a way that guarantees a unique identifier for each unit in the store.

Overrides: base.TranslationUnit.getid