l.t.u.t.TranslationMerger : class documentation

Part of lp.translations.utilities.translationmerger View In Hierarchy

Merge translations across a set of potemplates.
Static Method findMergeablePackagings Find packagings where both product and package have templates.
Class Method mergePackagingTemplates Undocumented
Class Method mergeModifiedTemplates Undocumented
Method mergeAll Properly merge POTMsgSets and TranslationMessages.
Method __init__ Constructor.
Method mergePOTMsgSets Merge POTMsgSets for given sequence of sharing templates.
Method mergeTranslationMessages Share `TranslationMessage`s between templates where possible.
Class Method _mergeTemplates Undocumented
Method _removeDuplicateMessages Get rid of duplicate TranslationMessages where needed.
Method _mapRepresentatives Map out POTMsgSets' subordinates and templates.
Static Method _getPOTMsgSetIds Get list of ids for `template`'s `POTMsgSet`s.
Static Method _getPOTMsgSetTranslationMessageKey Return tuple that identifies a TranslationMessage in a POTMsgSet.
Static Method _partitionTranslationMessageIds Partition `TranslationMessage`s by language.
Method _scrubPOTMsgSetTranslations Map out translations for potmsgset, and eliminate duplicates.
Static Method _findClashes What would clash if we moved message to the target environment?
Method _saveByDiverging Avoid a TranslationMessage clash during POTMsgSet merge.
Class Method _divergeTo Attempt to save message by diverging to target_potemplate.
@staticmethod
def findMergeablePackagings():
Find packagings where both product and package have templates.
@classmethod
def mergePackagingTemplates(cls, productseries, sourcepackagename, distroseries, tm):
Undocumented
@classmethod
def mergeModifiedTemplates(cls, potemplate, tm):
Undocumented
@classmethod
def _mergeTemplates(cls, templates, tm):
Undocumented
def mergeAll(self):
Properly merge POTMsgSets and TranslationMessages.
def __init__(self, potemplates, tm):
Constructor.
ParameterspotemplatesThe templates to merge across.
def _removeDuplicateMessages(self):
Get rid of duplicate TranslationMessages where needed.
def _mapRepresentatives(self):
Map out POTMsgSets' subordinates and templates.
ReturnsA tuple of dicts. The first maps each POTMsgSet's key (as returned by get_potmsgset_key) to a list of its subordinate POTMsgSet`s. The second maps each representative `POTMsgSet to its representative POTemplate.
def mergePOTMsgSets(self):
Merge POTMsgSets for given sequence of sharing templates.
@staticmethod
def _getPOTMsgSetIds(template):
Get list of ids for `template`'s `POTMsgSet`s.
def mergeTranslationMessages(self):
Share `TranslationMessage`s between templates where possible.
@staticmethod
def _getPOTMsgSetTranslationMessageKey(tm):
Return tuple that identifies a TranslationMessage in a POTMsgSet.

A TranslationMessage is identified by (potemplate, potmsgset, language, msgstr0, ...). In this case we leave out the potmsgset (because we start out with one) and potemplate (because that's sorted out in the nested dicts).

@staticmethod
def _partitionTranslationMessageIds(potmsgset):
Partition `TranslationMessage`s by language.

Only the ids are stored, not the `TranslationMessage` objects
themselves, so as to avoid pinning the objects in memory.

:param potmsgset: A `POTMsgSet`.  All its `TranslationMessage`s
    will be read and partitioned.
:return: A list of lists of `TranslationMessage` ids.  Each of
    the inner lists represents one language.
def _scrubPOTMsgSetTranslations(self, potmsgset):
Map out translations for potmsgset, and eliminate duplicates.

In the transition period for message sharing, there may be duplicate TranslationMessages that may upset assumptions in the code. Clean those up.

@staticmethod
def _findClashes(message, target_potmsgset, target_potemplate):
What would clash if we moved message to the target environment?

A clash can be either message being current when the target environment already has a current message for that language, or similar for the message being imported.

Returnsa tuple of a clashing ubuntu message or None, a clashing upstream message or None, and a message that is identical to the one you passed in, if present.
def _saveByDiverging(self, message, target_potmsgset, source_potmsgset):
Avoid a TranslationMessage clash during POTMsgSet merge.

The clash in this case is that we're trying to move message into a target environment (POTMsgSet and either POTemplate or shared status) that already has a current/imported message.

This function tries to preserve the message for its original environment by making it diverged. If successful, the message will become a diverged one for one POTemplate that source_potmsgset is linked to, preferring the one it was linked to first.

@classmethod
def _divergeTo(cls, message, target_potmsgset, target_potemplate):
Attempt to save message by diverging to target_potemplate.
Parametersmessagea TranslationMessage to save by diverging.
target_potmsgsetthe POTMsgSet that message is to be attached to.
target_potemplatea POTemplate that the message might be able to diverge to.
Returnswhether a solution was found for this message. If True, you're done with message. If False, you'll have to find another place for it.
API Documentation for Launchpad, generated by pydoctor at 2020-04-03 00:00:14.