l.t.m.t.TranslationImportQueue : class documentation

Part of lp.translations.model.translationimportqueue View In Hierarchy

No class docstring
Method __iter__ See ITranslationImportQueue.
Method __getitem__ See ITranslationImportQueue.
Method countEntries See ITranslationImportQueue.
Method addOrUpdateEntry See ITranslationImportQueue.
Method addOrUpdateEntriesFromTarball See ITranslationImportQueue.
Method get See ITranslationImportQueue.
Method getAllEntries See ITranslationImportQueue.
Method getFirstEntryToImport See ITranslationImportQueue.
Method getRequestTargets See ITranslationImportQueue.
Method executeOptimisticApprovals See ITranslationImportQueue.
Method executeOptimisticBlock See ITranslationImportQueue.
Method cleanUpQueue See ITranslationImportQueue.
Method remove See ITranslationImportQueue.
Method _iterNeedsReview Iterate over all entries in the queue that need review.
Method _getMatchingEntry Find an entry that best matches the given parameters, if such an
Method _getFormatAndImporter Get the appropriate format and importer for this upload.
Method _getFileObjectAndSize Get the size of a seekable file object.
Method _iterTarballFiles Iterate through all non-emtpy files in the tarball.
Method _makePath Make the file path from the name stored in the tarball.
Method _isTranslationFile Is this a translation file that should be uploaded?
Method _getQueryByFiltering See ITranslationImportQueue.
Method _attemptToSet Set potemplate or pofile on a TranslationImportQueueEntry.
Method _attemptToApprove Attempt to approve one queue entry.
Method _getSlaveStore Return the slave store for the import queue.
Method _getBlockableDirectories Describe all directories where uploads are to be blocked.
Method _isBlockable Is entry one that should be blocked according to blocklist?
Method _cleanUpObsoleteEntries Delete obsolete queue entries.
Method _cleanUpInactiveProductEntries Delete queue entries for deactivated `Product`s.
Method _cleanUpObsoleteDistroEntries Delete some queue entries for obsolete DistroSeries.
def __iter__(self):
See ITranslationImportQueue.
def __getitem__(self, id):
See ITranslationImportQueue.
def countEntries(self):
See ITranslationImportQueue.
def _iterNeedsReview(self):
Iterate over all entries in the queue that need review.
def _getMatchingEntry(self, path, importer, potemplate, pofile, sourcepackagename, distroseries, productseries):
Find an entry that best matches the given parameters, if such an entry exists.

When the user uploads a file, we need to figure out whether to update an existing entry or create a new one. There may be zero, one, or multiple entries that match the new upload. If it's more than one, that will be because one matching entry is more specific than the other. 'More specific' refers to how well the import location has been specified for this entry. There are three cases, ordered from least specific to most specific:

  1. potemplate and pofile are None,
  2. potemplate is not None but pofile is None,
  3. potemplate and pofile are both not None.

If no exactly matching entry can be found, the next more specific entry is chosen, if it exists. If there is more than one such entry, there is no best choice and TranslationImportQueueConflictError is raised.

ReturnsThe matching entry or None, if no matching entry was found at all.
def _getFormatAndImporter(self, filename, content, format=None):
Get the appropriate format and importer for this upload.
ParametersfilenameName of the uploaded file.
contentContents of the uploaded file.
formatOptional hard choice of format. If none is given, a format will be divined from the file's name and contents.
Returnsa tuple of the selected format and its importer.
def _getFileObjectAndSize(self, file_or_data):
Get the size of a seekable file object.
def addOrUpdateEntry(self, path, content, by_maintainer, importer, sourcepackagename=None, distroseries=None, productseries=None, potemplate=None, pofile=None, format=None):
See ITranslationImportQueue.
def _iterTarballFiles(self, tarball):
Iterate through all non-emtpy files in the tarball.
def _makePath(self, name, path_filter):
Make the file path from the name stored in the tarball.
def _isTranslationFile(self, path, only_templates):
Is this a translation file that should be uploaded?
def addOrUpdateEntriesFromTarball(self, content, by_maintainer, importer, sourcepackagename=None, distroseries=None, productseries=None, potemplate=None, filename_filter=None, approver_factory=None, only_templates=False):
See ITranslationImportQueue.
def get(self, id):
See ITranslationImportQueue.
def _getQueryByFiltering(self, target=None, status=None, file_extensions=None):
See ITranslationImportQueue.
def getAllEntries(self, target=None, import_status=None, file_extensions=None):
See ITranslationImportQueue.
def getFirstEntryToImport(self, target=None):
See ITranslationImportQueue.
def getRequestTargets(self, user, status=None):
See ITranslationImportQueue.
def _attemptToSet(self, entry, potemplate=None, pofile=None):
Set potemplate or pofile on a TranslationImportQueueEntry.

This will do nothing if setting potemplate or pofile would clash with another entry.

def _attemptToApprove(self, entry):
Attempt to approve one queue entry.
def executeOptimisticApprovals(self, txn=None):
See ITranslationImportQueue.
def _getSlaveStore(self):
Return the slave store for the import queue.

Tests can override this to avoid unnecessary synchronization issues.

def _getBlockableDirectories(self):
Describe all directories where uploads are to be blocked.

Returns a set of tuples, each containing:
  • DistroSeries id
  • SourcePackageName id
  • ProductSeries id
  • Directory path.

A TranslationImportQueueEntry should be blocked if the tuple of its distroseries.id, sourcepackagename.id, productseries.id, and the directory component of its path is found in the result set.

See _isBlockable, which matches a queue entry against the set returned by this method.

def _isBlockable(self, entry, blocklist):
Is entry one that should be blocked according to blocklist?
ParametersentryA TranslationImportQueueEntry that may be a candidate for blocking.
blocklistA description of blockable directories as returned by _getBlockableDirectories.
def executeOptimisticBlock(self, txn=None):
See ITranslationImportQueue.
def _cleanUpObsoleteEntries(self, store):
Delete obsolete queue entries.
ParametersstoreThe Store to delete from.
ReturnsNumber of entries deleted.
def _cleanUpInactiveProductEntries(self, store):
Delete queue entries for deactivated `Product`s.

:param store: The Store to delete from.
:return: Number of entries deleted.
def _cleanUpObsoleteDistroEntries(self, store):
Delete some queue entries for obsolete DistroSeries.
ParametersstoreThe Store to delete from.
ReturnsNumber of entries deleted.
def cleanUpQueue(self):
See ITranslationImportQueue.
def remove(self, entry):
See ITranslationImportQueue.
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.