l.t.s.scrub_pofiletranslator : module documentation

Part of lp.translations.scripts

Keep POFileTranslator more or less consistent with the real data.
Function get_pofile_ids Retrieve ids of POFiles to scrub.
Function summarize_pofiles Retrieve relevant parts of `POFile`s with given ids.
Function get_potmsgset_ids Get the ids for each current POTMsgSet in a POTemplate.
Function summarize_contributors Return the set of ids of persons who contributed to a POFile.
Function get_contributions Map all users' most recent contributions to a POFile.
Function get_pofiletranslators Get Person ids from POFileTranslator entries for a POFile.
Function remove_pofiletranslators Delete POFileTranslator records.
Function remove_unwarranted_pofiletranslators Delete POFileTranslator records that shouldn't be there.
Function create_missing_pofiletranslators Create POFileTranslator records that were missing.
Function fix_pofile This POFile needs fixing. Load its data & fix it.
Function needs_fixing Does the POFile with given details need POFileTranslator changes?
Function gather_work_items Produce `WorkItem`s for those `POFile`s that need fixing.
Function preload_work_items Bulk load data that will be needed to process work_items.
Function process_work_items Fix the POFileTranslator records covered by work_items.
Class ScrubPOFileTranslator Tunable loop, meant for running from inside Garbo.
def get_pofile_ids():
Retrieve ids of POFiles to scrub.

The result's ordering is aimed at maximizing cache effectiveness: by POTemplate name for locality of shared POTMsgSets, and by language for locality of shared TranslationMessages.

def summarize_pofiles(pofile_ids):
Retrieve relevant parts of `POFile`s with given ids.

This gets just enough information to determine whether any of the
`POFile`s need their `POFileTranslator` records fixed.

:param pofile_ids: Iterable of `POFile` ids.
:return: Dict mapping each id in `pofile_ids` to a duple of
    `POTemplate` id and `Language` id for the associated `POFile`.
def get_potmsgset_ids(potemplate_id):
Get the ids for each current POTMsgSet in a POTemplate.
def summarize_contributors(potemplate_id, language_id, potmsgset_ids):
Return the set of ids of persons who contributed to a POFile.

This is a limited version of get_contributions that is easier to compute.

def get_contributions(pofile, potmsgset_ids):
Map all users' most recent contributions to a POFile.

Returns a dict mapping Person id to the creation time of their most recent TranslationMessage in POFile.

This leaves some small room for error: a contribution that is masked by a diverged entry in this POFile will nevertheless produce a POFileTranslator record. Fixing that would complicate the work more than it is probably worth.

ParameterspofileThe POFile to find contributions for.
potmsgset_idsThe ids of the POTMsgSet`s to look for, as returned by `get_potmsgset_ids.
def get_pofiletranslators(pofile_id):
Get Person ids from POFileTranslator entries for a POFile.

Returns a set of Person ids.

def remove_pofiletranslators(logger, pofile, person_ids):
Delete POFileTranslator records.
def remove_unwarranted_pofiletranslators(logger, pofile, pofts, contribs):
Delete POFileTranslator records that shouldn't be there.
def create_missing_pofiletranslators(logger, pofile, pofts, contribs):
Create POFileTranslator records that were missing.
def fix_pofile(logger, pofile, potmsgset_ids, pofiletranslators):
This POFile needs fixing. Load its data & fix it.
def needs_fixing(template_id, language_id, potmsgset_ids, pofiletranslators):
Does the POFile with given details need POFileTranslator changes?
Parameterstemplate_idid of the POTemplate for the POFile.
language_idid of the Language the POFile translates to.
potmsgset_idsids of the POTMsgSet items participating in the template.
pofiletranslatorsPOFileTranslator objects for the POFile.
ReturnsBool: does the existing set of POFileTranslator need fixing?
def gather_work_items(pofile_ids):
Produce `WorkItem`s for those `POFile`s that need fixing.

:param pofile_ids: An iterable of `POFile` ids to check.
:param pofile_summaries: Dict as returned by `summarize_pofiles`.
:return: A sequence of `WorkItem`s for those `POFile`s that need fixing.
def preload_work_items(work_items):
Bulk load data that will be needed to process work_items.
Parameterswork_itemsA sequence of WorkItem records.
ReturnsA dict mapping POFile ids from work_items to their respective POFile objects.
def process_work_items(logger, work_items, pofiles):
Fix the POFileTranslator records covered by work_items.
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.