launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28843
[Merge] ~cjwatson/launchpad:rename-dummy-po-file into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:rename-dummy-po-file into launchpad:master.
Commit message:
Rename DummyPOFile to PlaceholderPOFile
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/427086
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:rename-dummy-po-file into launchpad:master.
diff --git a/lib/lp/translations/browser/pofile.py b/lib/lp/translations/browser/pofile.py
index e636631..6f3f897 100644
--- a/lib/lp/translations/browser/pofile.py
+++ b/lib/lp/translations/browser/pofile.py
@@ -508,7 +508,7 @@ class POFileUploadView(POFileView):
by_maintainer = False
if self.context.path is None:
- # The POFile is a dummy one, we use the filename as the path.
+ # The POFile is a placeholder one, we use the filename as the path.
path = filename
else:
path = self.context.path
@@ -541,15 +541,15 @@ class POFileBatchNavigator(BatchNavigator):
class POFileTranslateView(BaseTranslationView, POFileMetadataViewMixin):
- """The View class for a `POFile` or a `DummyPOFile`.
+ """The View class for a `POFile` or a `PlaceholderPOFile`.
This view is based on `BaseTranslationView` and implements the API
defined by that class.
- `DummyPOFile`s are presented where there is no `POFile` in the
+ `PlaceholderPOFile`s are presented where there is no `POFile` in the
database but the user may want to translate. See how `POTemplate`
traversal is done for details about how we decide between a `POFile`
- or a `DummyPOFile`.
+ or a `PlaceholderPOFile`.
"""
DEFAULT_SHOW = 'all'
@@ -806,7 +806,7 @@ class POFileTranslateView(BaseTranslationView, POFileMetadataViewMixin):
return None
pofile = potemplate.getPOFileByLang(self.context.language.code)
if pofile is None:
- pofile = potemplate.getDummyPOFile(
+ pofile = potemplate.getPlaceholderPOFile(
self.context.language, check_for_existing=False)
return pofile
diff --git a/lib/lp/translations/browser/potemplate.py b/lib/lp/translations/browser/potemplate.py
index aa3d5f2..c707927 100644
--- a/lib/lp/translations/browser/potemplate.py
+++ b/lib/lp/translations/browser/potemplate.py
@@ -137,7 +137,7 @@ class POTemplateNavigation(Navigation):
language = getUtility(ILanguageSet).getLanguageByCode(name)
if language is None:
raise NotFoundError(name)
- return self.context.getDummyPOFile(
+ return self.context.getPlaceholderPOFile(
language, requester=user, check_for_existing=False)
else:
# It's a POST.
@@ -198,12 +198,12 @@ class POTemplateView(LaunchpadView,
self.description = self.context.description
def requestPoFiles(self):
- """Yield a POFile or DummyPOFile for each of the languages in the
- request, which includes country languages from the request IP,
+ """Yield a POFile or PlaceholderPOFile for each of the languages in
+ the request, which includes country languages from the request IP,
browser preferences, and/or personal Launchpad language prefs.
"""
for language in self._sortLanguages(self.translatable_languages):
- yield self._getPOFileOrDummy(language)
+ yield self._getPOFileOrPlaceholder(language)
def num_messages(self):
N = self.context.messageCount()
@@ -220,7 +220,7 @@ class POTemplateView(LaunchpadView,
Yields a POFileView object for each language this template has
been translated into, and for each of the user's languages.
Where the template has no POFile for that language, we use
- a DummyPOFile.
+ a PlaceholderPOFile.
"""
# This inline import is needed to workaround a circular import problem
# because lp.translations.browser.pofile imports
@@ -234,7 +234,7 @@ class POTemplateView(LaunchpadView,
languages = set(self.context.languages()) | set(languages)
for language in self._sortLanguages(languages):
- pofile = self._getPOFileOrDummy(language)
+ pofile = self._getPOFileOrPlaceholder(language)
pofileview = POFileView(pofile, self.request)
# Initialize the view.
pofileview.initialize()
@@ -294,11 +294,11 @@ class POTemplateView(LaunchpadView,
def _sortLanguages(self, languages):
return sorted(languages, key=operator.attrgetter('englishname'))
- def _getPOFileOrDummy(self, language):
+ def _getPOFileOrPlaceholder(self, language):
pofile = self.context.getPOFileByLang(language.code)
if pofile is None:
pofileset = getUtility(IPOFileSet)
- pofile = pofileset.getDummy(self.context, language)
+ pofile = pofileset.getPlaceholder(self.context, language)
return pofile
@property
diff --git a/lib/lp/translations/browser/productseries.py b/lib/lp/translations/browser/productseries.py
index e17dafc..f5c875d 100644
--- a/lib/lp/translations/browser/productseries.py
+++ b/lib/lp/translations/browser/productseries.py
@@ -401,7 +401,7 @@ class ProductSeriesView(LaunchpadView,
pot = self.context.getCurrentTranslationTemplates()[0]
pofile = pot.getPOFileByLang(lang.code)
if pofile is None:
- pofile = pot.getDummyPOFile(lang)
+ pofile = pot.getPlaceholderPOFile(lang)
productserieslang = (
productserieslangset.getProductSeriesLanguage(
self.context, lang, pofile=pofile))
diff --git a/lib/lp/translations/browser/tests/pofile-views.rst b/lib/lp/translations/browser/tests/pofile-views.rst
index 45b4751..ea86559 100644
--- a/lib/lp/translations/browser/tests/pofile-views.rst
+++ b/lib/lp/translations/browser/tests/pofile-views.rst
@@ -58,7 +58,7 @@ This time, we are going to see what happens if we get an IPOFile without
the plural form information.
>>> language_tlh = getUtility(ILanguageSet).getLanguageByCode('tlh')
- >>> pofile_tlh = potemplate.getDummyPOFile(language_tlh)
+ >>> pofile_tlh = potemplate.getPlaceholderPOFile(language_tlh)
>>> form = {'show': 'all' }
>>> pofile_view = create_view(pofile_tlh, '+translate', form=form)
>>> pofile_view.initialize()
diff --git a/lib/lp/translations/browser/tests/test_potemplate_navigation.py b/lib/lp/translations/browser/tests/test_potemplate_navigation.py
index ad4d30c..647dcac 100644
--- a/lib/lp/translations/browser/tests/test_potemplate_navigation.py
+++ b/lib/lp/translations/browser/tests/test_potemplate_navigation.py
@@ -8,7 +8,7 @@ from lp.services.webapp.servers import LaunchpadTestRequest
from lp.testing import TestCaseWithFactory
from lp.testing.layers import DatabaseFunctionalLayer
from lp.translations.browser.potemplate import POTemplateNavigation
-from lp.translations.model.pofile import DummyPOFile
+from lp.translations.model.pofile import PlaceholderPOFile
class TestPOTemplateNavigation(TestCaseWithFactory):
@@ -26,10 +26,10 @@ class TestPOTemplateNavigation(TestCaseWithFactory):
destination = nav.traverse('nl')
self.assertEqual(pofile, destination)
- def test_traverse_to_dummy_pofile(self):
+ def test_traverse_to_placeholder_pofile(self):
nav = self._makeNavigation(self.factory.makePOTemplate())
destination = nav.traverse('de')
- self.assertIsInstance(destination, DummyPOFile)
+ self.assertIsInstance(destination, PlaceholderPOFile)
self.assertEqual('de', destination.language.code)
def test_traverse_nonexistent_language(self):
diff --git a/lib/lp/translations/browser/tests/test_sharing_information.py b/lib/lp/translations/browser/tests/test_sharing_information.py
index 91ba3a7..a9d69b3 100644
--- a/lib/lp/translations/browser/tests/test_sharing_information.py
+++ b/lib/lp/translations/browser/tests/test_sharing_information.py
@@ -191,21 +191,21 @@ class TestPOFileSharingInfo(BrowserTestCase, TestSharingInfoMixin):
return None
-class TestDummyPOFileSharingInfo(BrowserTestCase, TestSharingInfoMixin):
- """Test display of DummyPOFile sharing info."""
+class TestPlaceholderPOFileSharingInfo(BrowserTestCase, TestSharingInfoMixin):
+ """Test display of PlaceholderPOFile sharing info."""
layer = DatabaseFunctionalLayer
def makeNotSharingObject(self):
template = self.factory.makePOTemplate()
- return template.getDummyPOFile(self.factory.makeLanguage())
+ return template.getPlaceholderPOFile(self.factory.makeLanguage())
NOT_SHARING_TEXT = None
def makeSharingObject(self):
template = self._makePackagingAndTemplates(TranslationSide.UPSTREAM)
# This will also create a copy of pofile in the sharing template.
- return template.getDummyPOFile(self.factory.makeLanguage())
+ return template.getPlaceholderPOFile(self.factory.makeLanguage())
SHARING_TEXT = """
These translations are shared with .*"""
diff --git a/lib/lp/translations/browser/tests/translationmessage-views.rst b/lib/lp/translations/browser/tests/translationmessage-views.rst
index 1c62063..1d936cc 100644
--- a/lib/lp/translations/browser/tests/translationmessage-views.rst
+++ b/lib/lp/translations/browser/tests/translationmessage-views.rst
@@ -26,7 +26,7 @@ without the plural form information.
>>> translationmessage = TranslationMessage.get(1)
>>> pofile = POFile.get(1)
>>> language_tlh = getUtility(ILanguageSet).getLanguageByCode('tlh')
- >>> pofile_tlh = pofile.potemplate.getDummyPOFile(language_tlh)
+ >>> pofile_tlh = pofile.potemplate.getPlaceholderPOFile(language_tlh)
>>> potmsgset = pofile_tlh.potemplate.getPOTMsgSetByMsgIDText(
... u'evolution addressbook')
>>> current_translationmessage = (
@@ -50,7 +50,7 @@ Basic checks
------------
Now, we will use objects that we have in our database, instead of
-dummy ones.
+placeholder ones.
>>> server_url = '/'.join(
... [canonical_url(current_translationmessage), '+translate'])
diff --git a/lib/lp/translations/configure.zcml b/lib/lp/translations/configure.zcml
index 421921d..fdb066c 100644
--- a/lib/lp/translations/configure.zcml
+++ b/lib/lp/translations/configure.zcml
@@ -320,10 +320,10 @@
provides="lp.translations.interfaces.translationcommonformat.ITranslationFileData"
factory="lp.translations.model.pofile.POFileToChangedFromPackagedAdapter"/>
- <!-- Dummy PO File -->
+ <!-- Placeholder PO File -->
<class
- class="lp.translations.model.pofile.DummyPOFile">
+ class="lp.translations.model.pofile.PlaceholderPOFile">
<allow
interface="lp.translations.interfaces.pofile.IPOFile"/>
</class>
diff --git a/lib/lp/translations/doc/distroseries-language.rst b/lib/lp/translations/doc/distroseries-language.rst
index 82b6e2f..a774281 100644
--- a/lib/lp/translations/doc/distroseries-language.rst
+++ b/lib/lp/translations/doc/distroseries-language.rst
@@ -49,14 +49,14 @@ There are however more templates than the ones that have messages:
pmount
We can ask the DistroSeriesLanguage to fetch existing POFiles for these
-templates where they exist, or create matching DummyPOFiles where they
+templates where they exist, or create matching PlaceholderPOFiles where they
don't.
>>> from zope.security.proxy import removeSecurityProxy
>>> def print_augmented_pofiles(distroserieslanguage, templates):
... """Print `POFile`s for each of `templates`.
...
- ... Creates `DummyPOFile`s where needed. Prints types.
+ ... Creates `PlaceholderPOFile`s where needed. Prints types.
... """
... for pofile in distroserieslanguage.getPOFilesFor(templates):
... print("%s (%s) %s" % (
@@ -66,13 +66,13 @@ don't.
>>> print_augmented_pofiles(hoary_spanish, hoary_templates)
evolution-2.2 (es) <class '...pofile.POFile'>
man (es) <class '...pofile.POFile'>
- man (es) <class '...pofile.DummyPOFile'>
+ man (es) <class '...pofile.PlaceholderPOFile'>
pkgconf-mozilla (es) <class '...pofile.POFile'>
pmount (es) <class '...pofile.POFile'>
Note that the sorting is by template name, and there are two 'man'
templates of which one has a real translation and the other uses a
-DummyPOFile.
+PlaceholderPOFile.
When we ask for the whole list of templates, including non-current ones,
we see one extra template that was not shown in the DistroSeriesLanguage
@@ -120,11 +120,11 @@ An EmptyDistroSeriesLanguage gives you the same set of templates to
translate as a regular DistroSeriesLanguage would.
>>> print_augmented_pofiles(hoary_amharic, hoary_templates)
- evolution-2.2 (am) <class '...pofile.DummyPOFile'>
- man (am) <class '...pofile.DummyPOFile'>
- man (am) <class '...pofile.DummyPOFile'>
- pkgconf-mozilla (am) <class '...pofile.DummyPOFile'>
- pmount (am) <class '...pofile.DummyPOFile'>
+ evolution-2.2 (am) <class '...pofile.PlaceholderPOFile'>
+ man (am) <class '...pofile.PlaceholderPOFile'>
+ man (am) <class '...pofile.PlaceholderPOFile'>
+ pkgconf-mozilla (am) <class '...pofile.PlaceholderPOFile'>
+ pmount (am) <class '...pofile.PlaceholderPOFile'>
Now, we should test that an EmptyDistroSeriesLanguage implements the full
interface of a normal DistroSeriesLanguage.
@@ -197,8 +197,8 @@ pofile sort order:
>>> print_augmented_pofiles(
... hoary_amharic, hoary.getCurrentTranslationTemplates())
- pmount (am) <class '...pofile.DummyPOFile'>
- pkgconf-mozilla (am) <class '...pofile.DummyPOFile'>
- man (am) <class '...pofile.DummyPOFile'>
- man (am) <class '...pofile.DummyPOFile'>
- evolution-2.2 (am) <class '...pofile.DummyPOFile'>
+ pmount (am) <class '...pofile.PlaceholderPOFile'>
+ pkgconf-mozilla (am) <class '...pofile.PlaceholderPOFile'>
+ man (am) <class '...pofile.PlaceholderPOFile'>
+ man (am) <class '...pofile.PlaceholderPOFile'>
+ evolution-2.2 (am) <class '...pofile.PlaceholderPOFile'>
diff --git a/lib/lp/translations/doc/pofile.rst b/lib/lp/translations/doc/pofile.rst
index 69b0780..5801840 100644
--- a/lib/lp/translations/doc/pofile.rst
+++ b/lib/lp/translations/doc/pofile.rst
@@ -30,29 +30,29 @@ Get Xhosa translation
>>> pofile = potemplate.getPOFileByLang('xh')
>>> language_pt_BR = getUtility(
... ILanguageSet).getLanguageByCode('pt_BR')
- >>> dummy_pofile = potemplate.getDummyPOFile(language_pt_BR)
+ >>> placeholder_pofile = potemplate.getPlaceholderPOFile(language_pt_BR)
Both implement the IPOFile interface:
>>> verifyObject(IPOFile, pofile)
True
- >>> verifyObject(IPOFile, dummy_pofile)
+ >>> verifyObject(IPOFile, placeholder_pofile)
True
-DummyPOFile returns empty SelectResults for getPOTMsgSet* methods,
+PlaceholderPOFile returns empty SelectResults for getPOTMsgSet* methods,
except for untranslated messages.
- >>> dummy_pofile.getPOTMsgSetTranslated().count()
+ >>> placeholder_pofile.getPOTMsgSetTranslated().count()
0
- >>> dummy_pofile.getPOTMsgSetDifferentTranslations().count()
+ >>> placeholder_pofile.getPOTMsgSetDifferentTranslations().count()
0
- >>> dummy_pofile.getPOTMsgSetWithNewSuggestions().count()
+ >>> placeholder_pofile.getPOTMsgSetWithNewSuggestions().count()
0
- >>> dummy_pofile.getPOTMsgSetUntranslated().count()
+ >>> placeholder_pofile.getPOTMsgSetUntranslated().count()
22
Get the set of POTMsgSets that are untranslated.
@@ -107,7 +107,7 @@ Returns the complete code for this POFile's language.
es
>>> sr_latin = factory.makeLanguage('sr@latin', 'Serbian Latin')
- >>> print(potemplate.getDummyPOFile(sr_latin).getFullLanguageCode())
+ >>> print(potemplate.getPlaceholderPOFile(sr_latin).getFullLanguageCode())
sr@latin
@@ -119,7 +119,7 @@ Returns the complete English name for this POFile's language.
>>> print(potemplate.getPOFileByLang('es').getFullLanguageName())
Spanish
- >>> print(potemplate.getDummyPOFile(sr_latin).getFullLanguageName())
+ >>> print(potemplate.getPlaceholderPOFile(sr_latin).getFullLanguageName())
Serbian Latin
@@ -130,11 +130,11 @@ It is common to want to find those POTMsgSets which contain a certain
substring in their original English string.
>>> found_potmsgsets = (
- ... dummy_pofile.findPOTMsgSetsContaining(u"contact"))
+ ... placeholder_pofile.findPOTMsgSetsContaining("contact"))
>>> found_potmsgsets.count()
4
- >>> print_potmsgsets(found_potmsgsets, dummy_pofile)
+ >>> print_potmsgsets(found_potmsgsets, placeholder_pofile)
7. contact's header: None
14. The location and ... None
15. %d contact %d contacts
@@ -143,11 +143,11 @@ substring in their original English string.
Search is case-insensitive.
>>> found_potmsgsets = (
- ... dummy_pofile.findPOTMsgSetsContaining(u"CONTact"))
+ ... placeholder_pofile.findPOTMsgSetsContaining("CONTact"))
>>> found_potmsgsets.count()
4
- >>> print_potmsgsets(found_potmsgsets, dummy_pofile)
+ >>> print_potmsgsets(found_potmsgsets, placeholder_pofile)
7. contact's header: None
14. The location and ... None
15. %d contact %d contacts
@@ -156,25 +156,26 @@ Search is case-insensitive.
Search will look through plural msgids as well.
>>> found_potmsgsets = (
- ... dummy_pofile.findPOTMsgSetsContaining(u"contacts"))
+ ... placeholder_pofile.findPOTMsgSetsContaining("contacts"))
>>> found_potmsgsets.count()
2
- >>> print_potmsgsets(found_potmsgsets, dummy_pofile)
+ >>> print_potmsgsets(found_potmsgsets, placeholder_pofile)
15. %d contact %d contacts
16. Opening %d contac... Opening %d contac...
Looking for a non-existing string returns an empty SelectResults.
>>> found_potmsgsets = (
- ... dummy_pofile.findPOTMsgSetsContaining(u"non-existing-string"))
+ ... placeholder_pofile.findPOTMsgSetsContaining(
+ ... "non-existing-string"))
>>> found_potmsgsets.count()
0
Trying to find a string shorter than two characters doesn't work.
>>> found_potmsgsets = (
- ... dummy_pofile.findPOTMsgSetsContaining(u"a"))
+ ... placeholder_pofile.findPOTMsgSetsContaining("a"))
Traceback (most recent call last):
...
AssertionError: You can not search for strings shorter than 2 characters.
@@ -406,7 +407,7 @@ used.
>>> serbian.pluralforms
3
- >>> evolution_sr = evolution_pot.getDummyPOFile(serbian)
+ >>> evolution_sr = evolution_pot.getPlaceholderPOFile(serbian)
>>> evolution_sr.plural_forms
3
@@ -417,7 +418,7 @@ the most common number of plural forms:
>>> print(divehi.pluralforms)
None
- >>> evolution_dv = evolution_pot.getDummyPOFile(divehi)
+ >>> evolution_dv = evolution_pot.getPlaceholderPOFile(divehi)
>>> evolution_dv.plural_forms
2
diff --git a/lib/lp/translations/doc/potemplate.rst b/lib/lp/translations/doc/potemplate.rst
index 3f91d27..4b9452d 100644
--- a/lib/lp/translations/doc/potemplate.rst
+++ b/lib/lp/translations/doc/potemplate.rst
@@ -196,16 +196,16 @@ We can get an IPOFile inside a template based on its path.
Spanish (es) translation of evolution-2.2 in Evolution trunk
-getDummyPOFile
---------------
+getPlaceholderPOFile
+--------------------
To get an IPOFile object even for languages which don't have a
-translation of this template, we use the getDummyPOFile method, passing
-in the language.
+translation of this template, we use the getPlaceholderPOFile method,
+passing in the language.
>>> xx_language = factory.makeLanguage(
... 'xx@test', name='Test language')
- >>> xx_pofile = potemplate.getDummyPOFile(xx_language)
+ >>> xx_pofile = potemplate.getPlaceholderPOFile(xx_language)
>>> print(xx_pofile.title)
Test language (xx@test) translation of evolution-2.2 in Evolution trunk
diff --git a/lib/lp/translations/doc/potmsgset.rst b/lib/lp/translations/doc/potmsgset.rst
index da86a39..a326a08 100644
--- a/lib/lp/translations/doc/potmsgset.rst
+++ b/lib/lp/translations/doc/potmsgset.rst
@@ -63,76 +63,81 @@ Plural forms
Let's focus on handling of messages with plural forms.
An empty translation does not need to exist in the database. If not,
-a DummyPOFile is used instead.
+a PlaceholderPOFile is used instead.
>>> evolution = getUtility(IProductSet).getByName('evolution')
>>> evolution_trunk = evolution.getSeries('trunk')
>>> evolution_potemplate = evolution_trunk.getPOTemplate('evolution-2.2')
>>> language_pt_BR = getUtility(
... ILanguageSet).getLanguageByCode('pt_BR')
- >>> pt_BR_dummypofile = evolution_potemplate.getDummyPOFile(
+ >>> pt_BR_placeholderpofile = evolution_potemplate.getPlaceholderPOFile(
... language_pt_BR)
We get a POTMsgSet and verify it's a singular form:
- >>> potmsgset = pt_BR_dummypofile.potemplate.getPOTMsgSetByMsgIDText(
- ... u'evolution addressbook')
+ >>> potmsgset = (
+ ... pt_BR_placeholderpofile.potemplate.getPOTMsgSetByMsgIDText(
+ ... 'evolution addressbook'))
>>> potmsgset.msgid_plural is None
True
>>> current = potmsgset.getCurrentTranslation(
- ... evolution_potemplate, pt_BR_dummypofile.language,
+ ... evolution_potemplate, pt_BR_placeholderpofile.language,
... evolution_potemplate.translation_side)
>>> print(current)
None
- >>> pt_BR_dummy_current = potmsgset.getCurrentTranslationMessageOrDummy(
- ... pt_BR_dummypofile)
- >>> pt_BR_dummy_current.plural_forms
+ >>> pt_BR_placeholder_current = (
+ ... potmsgset.getCurrentTranslationMessageOrDummy(
+ ... pt_BR_placeholderpofile))
+ >>> pt_BR_placeholder_current.plural_forms
1
- >>> pt_BR_dummy_current.translations
+ >>> pt_BR_placeholder_current.translations
[None]
A TranslationMessage knows what language it is in.
- >>> print(pt_BR_dummy_current.language.code)
+ >>> print(pt_BR_placeholder_current.language.code)
pt_BR
-Using another dummy pofile we'll get a POTMsgset that's not a singular
+Using another placeholder pofile we'll get a POTMsgset that's not a singular
form:
>>> language_apa = getUtility(ILanguageSet).getLanguageByCode('apa')
- >>> apa_dummypofile = evolution_potemplate.getDummyPOFile(language_apa)
- >>> plural_potmsgset = apa_dummypofile.potemplate.getPOTMsgSetByMsgIDText(
- ... u'%d contact', u'%d contacts')
- >>> print(apa_dummypofile.language.code)
+ >>> apa_placeholderpofile = evolution_potemplate.getPlaceholderPOFile(
+ ... language_apa)
+ >>> plural_potmsgset = (
+ ... apa_placeholderpofile.potemplate.getPOTMsgSetByMsgIDText(
+ ... '%d contact', '%d contacts'))
+ >>> print(apa_placeholderpofile.language.code)
apa
We don't know anything about pluralforms for this language, so we fall
back to the most common case:
- >>> print(apa_dummypofile.language.pluralforms)
+ >>> print(apa_placeholderpofile.language.pluralforms)
None
- >>> apa_dummy_current = (
+ >>> apa_placeholder_current = (
... plural_potmsgset.getCurrentTranslationMessageOrDummy(
- ... apa_dummypofile))
- >>> apa_dummy_current.plural_forms
+ ... apa_placeholderpofile))
+ >>> apa_placeholder_current.plural_forms
2
- >>> apa_dummy_current.translations
+ >>> apa_placeholder_current.translations
[None, None]
We can guess the pluralforms for this language through ILanguage.pluralforms:
>>> language_ru = getUtility(ILanguageSet).getLanguageByCode('ru')
- >>> ru_dummypofile = evolution_potemplate.getDummyPOFile(language_ru)
- >>> ru_dummy_current = (
+ >>> ru_placeholderpofile = evolution_potemplate.getPlaceholderPOFile(
+ ... language_ru)
+ >>> ru_placeholder_current = (
... plural_potmsgset.getCurrentTranslationMessageOrDummy(
- ... ru_dummypofile))
+ ... ru_placeholderpofile))
- >>> print(ru_dummypofile.language.pluralforms)
+ >>> print(ru_placeholderpofile.language.pluralforms)
3
- >>> ru_dummy_current.plural_forms
+ >>> ru_placeholder_current.plural_forms
3
- >>> ru_dummy_current.translations
+ >>> ru_placeholder_current.translations
[None, None, None]
@@ -482,7 +487,7 @@ dummy anymore.
>>> potmsgset_untranslated = pmount_man_template.getPOTMsgSetByMsgIDText(
... 'test man page')
>>> language_es = getUtility(ILanguageSet).getLanguageByCode('es')
- >>> pofile = pmount_man_template.getDummyPOFile(language_es)
+ >>> pofile = pmount_man_template.getPlaceholderPOFile(language_es)
>>> print(pofile.title)
Spanish (es) translation of man in Ubuntu Hoary package "pmount"
diff --git a/lib/lp/translations/doc/translationmessage.rst b/lib/lp/translations/doc/translationmessage.rst
index dd413ed..aff181d 100644
--- a/lib/lp/translations/doc/translationmessage.rst
+++ b/lib/lp/translations/doc/translationmessage.rst
@@ -10,7 +10,7 @@ Let's do some imports we will need to test this class.
>>> from lp.translations.interfaces.translationmessage import (
... ITranslationMessage)
>>> from lp.translations.interfaces.translator import ITranslatorSet
- >>> from lp.translations.model.pofile import DummyPOFile
+ >>> from lp.translations.model.pofile import PlaceholderPOFile
>>> login('carlos@xxxxxxxxxxxxx')
>>> pofile_es = factory.makePOFile(language_code='es')
@@ -52,7 +52,7 @@ language:
>>> serbian.pluralforms
3
>>> current_sr = potmsgset.getCurrentTranslationMessageOrDummy(
- ... DummyPOFile(potemplate, serbian))
+ ... PlaceholderPOFile(potemplate, serbian))
>>> current_sr.plural_forms
1
@@ -60,7 +60,7 @@ language:
>>> print(divehi.pluralforms)
None
>>> current_dv = potmsgset.getCurrentTranslationMessageOrDummy(
- ... DummyPOFile(potemplate, divehi))
+ ... PlaceholderPOFile(potemplate, divehi))
>>> current_dv.plural_forms
1
@@ -75,7 +75,7 @@ forms per language (3 for Serbian, as specified in the language).
>>> serbian.pluralforms
3
>>> current_sr = potmsgset_plural.getCurrentTranslationMessageOrDummy(
- ... DummyPOFile(potemplate, serbian))
+ ... PlaceholderPOFile(potemplate, serbian))
>>> current_sr.plural_forms
3
@@ -85,7 +85,7 @@ a default of 2, which is the most common number of plural forms:
>>> print(divehi.pluralforms)
None
>>> current_dv = potmsgset_plural.getCurrentTranslationMessageOrDummy(
- ... DummyPOFile(potemplate, divehi))
+ ... PlaceholderPOFile(potemplate, divehi))
>>> current_dv.plural_forms
2
diff --git a/lib/lp/translations/interfaces/distroserieslanguage.py b/lib/lp/translations/interfaces/distroserieslanguage.py
index 0dadcfe..ed47806 100644
--- a/lib/lp/translations/interfaces/distroserieslanguage.py
+++ b/lib/lp/translations/interfaces/distroserieslanguage.py
@@ -46,7 +46,7 @@ class IDistroSeriesLanguage(IRosettaStats):
"""Return `POFile`s for each of `potemplates`, in the same order.
For any `POTemplate` that does not have a translation to the
- required language, a `DummyPOFile` is provided.
+ required language, a `PlaceholderPOFile` is provided.
"""
diff --git a/lib/lp/translations/interfaces/pofile.py b/lib/lp/translations/interfaces/pofile.py
index 87fcb5d..892fe22 100644
--- a/lib/lp/translations/interfaces/pofile.py
+++ b/lib/lp/translations/interfaces/pofile.py
@@ -356,8 +356,8 @@ class IPOFileAlternativeLanguage(Interface):
class IPOFileSet(Interface):
"""A set of POFiles."""
- def getDummy(potemplate, language):
- """Return a dummy pofile for the given po template and language."""
+ def getPlaceholder(potemplate, language):
+ """Return a placeholder pofile for the given template and language."""
def getPOFilesByPathAndOrigin(path, productseries=None,
distroseries=None, sourcepackagename=None):
diff --git a/lib/lp/translations/interfaces/potemplate.py b/lib/lp/translations/interfaces/potemplate.py
index 164351c..bc7f844 100644
--- a/lib/lp/translations/interfaces/potemplate.py
+++ b/lib/lp/translations/interfaces/potemplate.py
@@ -416,8 +416,9 @@ class IPOTemplate(IRosettaStats):
loops when creating a new IPOTemplate.
"""
- def getDummyPOFile(language, requester=None, check_for_existing=True):
- """Return a DummyPOFile if there isn't already a persistent `IPOFile`
+ def getPlaceholderPOFile(language, requester=None,
+ check_for_existing=True):
+ """Return a placeholder if there isn't already a persistent `IPOFile`.
Raise `LanguageNotFound` if the language does not exist in the
database.
diff --git a/lib/lp/translations/interfaces/translatedlanguage.py b/lib/lp/translations/interfaces/translatedlanguage.py
index 78b6786..6239cf8 100644
--- a/lib/lp/translations/interfaces/translatedlanguage.py
+++ b/lib/lp/translations/interfaces/translatedlanguage.py
@@ -64,7 +64,7 @@ class IPOFilesByPOTemplates(IFiniteSequence):
"""Iterate `IPOFile`s for (`ILanguage`, `ITranslationTemplateCollection`).
This is a wrapper for Storm ResultSet that enables optimized slicing
- by doing it lazily on the query, thus allowing DummyPOFile objects
+ by doing it lazily on the query, thus allowing PlaceholderPOFile objects
to be returned while still not doing more than one database query.
It subclasses `IFiniteSequence` so it can easily be used with the
diff --git a/lib/lp/translations/model/distroserieslanguage.py b/lib/lp/translations/model/distroserieslanguage.py
index 994c8a4..3dec975 100644
--- a/lib/lp/translations/model/distroserieslanguage.py
+++ b/lib/lp/translations/model/distroserieslanguage.py
@@ -37,7 +37,7 @@ from lp.translations.interfaces.distroserieslanguage import (
IDistroSeriesLanguageSet,
)
from lp.translations.model.pofile import (
- DummyPOFile,
+ PlaceholderPOFile,
POFile,
)
from lp.translations.model.potemplate import (
@@ -194,7 +194,8 @@ class EmptyDistroSeriesLanguage(RosettaStats):
"""See `IDistroSeriesLanguage`."""
templates = list(potemplates)
language = self.language
- return [DummyPOFile(template, language) for template in templates]
+ return [
+ PlaceholderPOFile(template, language) for template in templates]
def currentCount(self, language=None):
return 0
diff --git a/lib/lp/translations/model/pofile.py b/lib/lp/translations/model/pofile.py
index d3a883a..6cb5118 100644
--- a/lib/lp/translations/model/pofile.py
+++ b/lib/lp/translations/model/pofile.py
@@ -4,8 +4,8 @@
"""`SQLObject` implementation of `IPOFile` interface."""
__all__ = [
+ 'PlaceholderPOFile',
'POFile',
- 'DummyPOFile',
'POFileSet',
'POFileToChangedFromPackagedAdapter',
'POFileToTranslationFileDataAdapter',
@@ -111,11 +111,11 @@ from lp.translations.utilities.translation_common_format import (
class POFileMixIn(RosettaStats):
- """Base class for `POFile` and `DummyPOFile`.
+ """Base class for `POFile` and `PlaceholderPOFile`.
Provides machinery for retrieving `TranslationMessage`s and populating
their submissions caches. That machinery is needed even for
- `DummyPOFile`s.
+ `PlaceholderPOFile`s.
"""
@property
@@ -276,7 +276,7 @@ class POFileMixIn(RosettaStats):
english_match = self._getTranslationSearchQuery(
en_pofile, 0, text)
- # Do not look for translations in a DummyPOFile.
+ # Do not look for translations in a PlaceholderPOFile.
search_clauses = [english_match]
if self.id is not None:
for plural_form in range(self.plural_forms):
@@ -1227,7 +1227,7 @@ class POFile(SQLBase, POFileMixIn):
@implementer(IPOFile)
-class DummyPOFile(POFileMixIn):
+class PlaceholderPOFile(POFileMixIn):
"""Represents a POFile where we do not yet actually HAVE a POFile for
that language for this template.
"""
@@ -1384,7 +1384,7 @@ class DummyPOFile(POFileMixIn):
def setPathIfUnique(self, path):
"""See `IPOFile`."""
- # Any path will do for a DummyPOFile.
+ # Any path will do for a PlaceholderPOFile.
self.path = path
def importFromQueue(self, entry_to_import, logger=None, txn=None):
@@ -1407,8 +1407,8 @@ class DummyPOFile(POFileMixIn):
@implementer(IPOFileSet)
class POFileSet:
- def getDummy(self, potemplate, language):
- return DummyPOFile(potemplate, language)
+ def getPlaceholder(self, potemplate, language):
+ return PlaceholderPOFile(potemplate, language)
def getPOFilesByPathAndOrigin(self, path, productseries=None,
distroseries=None, sourcepackagename=None,
diff --git a/lib/lp/translations/model/potemplate.py b/lib/lp/translations/model/potemplate.py
index ccd6457..c3cf9e0 100644
--- a/lib/lp/translations/model/potemplate.py
+++ b/lib/lp/translations/model/potemplate.py
@@ -174,7 +174,7 @@ def get_pofiles_for(potemplates, language):
:param language: the language that the `IPOFile`s should be for.
:return: a list of exactly one `IPOFile` for each `POTemplate`
in `potemplates`. They will be `POFile`s where available,
- and `DummyPOFile`s where not.
+ and `PlaceholderPOFile`s where not.
"""
potemplates = list(potemplates)
if len(potemplates) == 0:
@@ -191,7 +191,7 @@ def get_pofiles_for(potemplates, language):
for entry, pofile in enumerate(result):
assert pofile == result[entry], "This enumerate confuses me."
if pofile is None:
- result[entry] = potemplates[entry].getDummyPOFile(
+ result[entry] = potemplates[entry].getPlaceholderPOFile(
language, check_for_existing=False)
return result
@@ -820,11 +820,11 @@ class POTemplate(SQLBase, RosettaStats):
return pofile
- def getDummyPOFile(self, language, requester=None,
- check_for_existing=True):
+ def getPlaceholderPOFile(self, language, requester=None,
+ check_for_existing=True):
"""See `IPOTemplate`."""
# Avoid circular import.
- from lp.translations.model.pofile import DummyPOFile
+ from lp.translations.model.pofile import PlaceholderPOFile
if check_for_existing:
# see if a valid one exists.
@@ -832,7 +832,7 @@ class POTemplate(SQLBase, RosettaStats):
assert existingpo is None, (
'There is already a valid IPOFile (%s)' % existingpo.title)
- return DummyPOFile(self, language, owner=requester)
+ return PlaceholderPOFile(self, language, owner=requester)
def createPOTMsgSetFromMsgIDs(self, msgid_singular, msgid_plural=None,
context=None, sequence=0):
diff --git a/lib/lp/translations/model/translatedlanguage.py b/lib/lp/translations/model/translatedlanguage.py
index f86d944..028d6ee 100644
--- a/lib/lp/translations/model/translatedlanguage.py
+++ b/lib/lp/translations/model/translatedlanguage.py
@@ -31,10 +31,10 @@ class POFilesByPOTemplates:
self.templates_collection = templates_collection
self.language = language
- def _getDummyOrPOFile(self, potemplate, pofile):
+ def _getPlaceholderOrPOFile(self, potemplate, pofile):
if pofile is None:
- return potemplate.getDummyPOFile(self.language,
- check_for_existing=False)
+ return potemplate.getPlaceholderPOFile(
+ self.language, check_for_existing=False)
else:
return pofile
@@ -52,7 +52,8 @@ class POFilesByPOTemplates:
else:
results = resultset[selector]
for potemplate, pofile in results:
- pofiles_list.append(self._getDummyOrPOFile(potemplate, pofile))
+ pofiles_list.append(
+ self._getPlaceholderOrPOFile(potemplate, pofile))
return pofiles_list
def __getitem__(self, selector):
@@ -61,7 +62,7 @@ class POFilesByPOTemplates:
return self._getPOFilesForResultSet(resultset, selector)
else:
potemplate, pofile = resultset[selector]
- return self._getDummyOrPOFile(potemplate, pofile)
+ return self._getPlaceholderOrPOFile(potemplate, pofile)
def __iter__(self):
resultset = self._getPOTemplatesAndPOFilesResultSet()
diff --git a/lib/lp/translations/stories/translations/xx-translations.rst b/lib/lp/translations/stories/translations/xx-translations.rst
index ee8309a..4af04e8 100644
--- a/lib/lp/translations/stories/translations/xx-translations.rst
+++ b/lib/lp/translations/stories/translations/xx-translations.rst
@@ -124,7 +124,7 @@ put Afrihili into the list of "preferred languages".
If we select Croatian, we would expect to see the list of source package
templates, and in the sample data we should have a croatian pofile for
-pmount. Note that we should also have an empty pofile (really a dummy
+pmount. Note that we should also have an empty pofile (really a placeholder
pofile) for evolution-2.2
>>> browser.open(
@@ -192,8 +192,8 @@ last translator is displayed.
... find_tag_by_id(browser.contents, "pkgconf-mozilla-person")))
Helge Kreutzmann
-DummyPOFile
------------
+PlaceholderPOFile
+-----------------
There are no translations yet for pmount into Portuguese. Carlos has
decided to start contributing translations to that package.
@@ -216,7 +216,7 @@ file):
>>> '10.' in browser.contents
True
-If everything works out ok, that means that DummyPOFile has actually
+If everything works out ok, that means that PlaceholderPOFile has actually
returned all untranslated entries.
Finally, lets also check that translated entries show up as well.
diff --git a/lib/lp/translations/tests/test_potemplate.py b/lib/lp/translations/tests/test_potemplate.py
index 7e8f645..b2a5418 100644
--- a/lib/lp/translations/tests/test_potemplate.py
+++ b/lib/lp/translations/tests/test_potemplate.py
@@ -20,6 +20,7 @@ from lp.testing.layers import (
)
from lp.translations.interfaces.potemplate import IPOTemplateSet
from lp.translations.interfaces.side import TranslationSide
+from lp.translations.model.pofile import PlaceholderPOFile
from lp.translations.model.potemplate import get_pofiles_for
@@ -33,12 +34,9 @@ class TestPOTemplate(TestCaseWithFactory):
self.potemplate = removeSecurityProxy(self.factory.makePOTemplate(
translation_domain="testdomain"))
- def assertIsDummy(self, pofile):
- """Assert that `pofile` is actually a `DummyPOFile`."""
- # Avoid circular imports.
- from lp.translations.model.pofile import DummyPOFile
-
- self.assertEqual(DummyPOFile, type(pofile))
+ def assertIsPlaceholder(self, pofile):
+ """Assert that `pofile` is actually a `PlaceholderPOFile`."""
+ self.assertEqual(PlaceholderPOFile, type(pofile))
def test_composePOFilePath(self):
esperanto = getUtility(ILanguageSet).getLanguageByCode('eo')
@@ -76,30 +74,30 @@ class TestPOTemplate(TestCaseWithFactory):
"missing directory and language code. "
"(Expected: '%s' Got: '%s')" % (expected, result))
- def test_getDummyPOFile_no_existing_pofile(self):
- # Test basic behaviour of getDummyPOFile.
+ def test_getPlaceholderPOFile_no_existing_pofile(self):
+ # Test basic behaviour of getPlaceholderPOFile.
language = self.factory.makeLanguage('sr@test')
- dummy = self.potemplate.getDummyPOFile(language)
- self.assertIsDummy(dummy)
+ placeholder = self.potemplate.getPlaceholderPOFile(language)
+ self.assertIsPlaceholder(placeholder)
- def test_getDummyPOFile_with_existing_pofile(self):
- # Test that getDummyPOFile fails when trying to get a DummyPOFile
- # where a POFile already exists for that language.
+ def test_getPlaceholderPOFile_with_existing_pofile(self):
+ # Test that getPlaceholderPOFile fails when trying to get a
+ # PlaceholderPOFile where a POFile already exists for that language.
language = self.factory.makeLanguage('sr@test')
self.potemplate.newPOFile(language.code)
self.assertRaises(
- AssertionError, self.potemplate.getDummyPOFile, language)
+ AssertionError, self.potemplate.getPlaceholderPOFile, language)
- def test_getDummyPOFile_with_existing_pofile_no_check(self):
- # Test that getDummyPOFile succeeds when trying to get a DummyPOFile
- # where a POFile already exists for that language when
- # check_for_existing=False is passed in.
+ def test_getPlaceholderPOFile_with_existing_pofile_no_check(self):
+ # Test that getPlaceholderPOFile succeeds when trying to get a
+ # PlaceholderPOFile where a POFile already exists for that language
+ # when check_for_existing=False is passed in.
language = self.factory.makeLanguage('sr@test')
self.potemplate.newPOFile(language.code)
# This is just "assertNotRaises".
- dummy = self.potemplate.getDummyPOFile(language,
- check_for_existing=False)
- self.assertIsDummy(dummy)
+ placeholder = self.potemplate.getPlaceholderPOFile(
+ language, check_for_existing=False)
+ self.assertIsPlaceholder(placeholder)
def test_newPOFile_owner(self):
# The intended owner of a new POFile can be passed to newPOFile.
@@ -108,12 +106,13 @@ class TestPOTemplate(TestCaseWithFactory):
pofile = self.potemplate.newPOFile(language.code, owner=person)
self.assertEqual(person, pofile.owner)
- def test_getDummyPOFile_owner(self):
- # The intended owner of a new DummyPOFile can be passed to
- # getDummyPOFile.
+ def test_getPlaceholderPOFile_owner(self):
+ # The intended owner of a new PlaceholderPOFile can be passed to
+ # getPlaceholderPOFile.
language = self.factory.makeLanguage('nl@test')
person = self.factory.makePerson()
- pofile = self.potemplate.getDummyPOFile(language, requester=person)
+ pofile = self.potemplate.getPlaceholderPOFile(
+ language, requester=person)
self.assertEqual(person, pofile.owner)
def test_getTranslationCredits(self):
@@ -611,14 +610,10 @@ class TestGetPOFilesFor(TestCaseWithFactory):
def test_get_pofiles_for_untranslated_template(self):
# If there is no POFile for a template in a language,
- # get_pofiles_for makes up a DummyPOFile.
-
- # Avoid circular imports.
- from lp.translations.model.pofile import DummyPOFile
-
+ # get_pofiles_for makes up a PlaceholderPOFile.
pofiles = get_pofiles_for([self.potemplate], self.greek)
pofile = pofiles[0]
- self.assertIsInstance(pofile, DummyPOFile)
+ self.assertIsInstance(pofile, PlaceholderPOFile)
class TestPOTemplateUbuntuUpstreamSharingMixin:
diff --git a/lib/lp/translations/tests/test_translatedlanguage.py b/lib/lp/translations/tests/test_translatedlanguage.py
index d95f185..08d487e 100644
--- a/lib/lp/translations/tests/test_translatedlanguage.py
+++ b/lib/lp/translations/tests/test_translatedlanguage.py
@@ -16,6 +16,7 @@ from lp.translations.interfaces.productserieslanguage import (
IProductSeriesLanguageSet,
)
from lp.translations.interfaces.translatedlanguage import ITranslatedLanguage
+from lp.translations.model.pofile import PlaceholderPOFile
class TestTranslatedLanguageMixin(TestCaseWithFactory):
@@ -56,12 +57,9 @@ class TestTranslatedLanguageMixin(TestCaseWithFactory):
potemplate = self.addPOTemplate()
return self.factory.makePOFile(self.language.code, potemplate)
- def assertIsDummy(self, pofile):
- """Assert that `pofile` is actually a `DummyPOFile`."""
- # Avoid circular imports.
- from lp.translations.model.pofile import DummyPOFile
-
- self.assertIsInstance(pofile, DummyPOFile)
+ def assertIsPlaceholder(self, pofile):
+ """Assert that `pofile` is actually a `PlaceholderPOFile`."""
+ self.assertIsInstance(pofile, PlaceholderPOFile)
def test_interface(self):
translated_language = self.getTranslatedLanguage(self.language)
@@ -85,17 +83,17 @@ class TestTranslatedLanguageMixin(TestCaseWithFactory):
def test_pofiles_template_no_pofiles(self):
translated_language = self.getTranslatedLanguage(self.language)
potemplate = self.addPOTemplate()
- dummy_pofile = potemplate.getDummyPOFile(self.language)
+ placeholder_pofile = potemplate.getPlaceholderPOFile(self.language)
pofiles = list(translated_language.pofiles)
self.assertEqual(1, len(pofiles))
- # When there are no actual PO files, we get a DummyPOFile object
- # instead.
- dummy_pofile = pofiles[0]
- naked_dummy = removeSecurityProxy(dummy_pofile)
- self.assertIsDummy(naked_dummy)
- self.assertEqual(self.language, dummy_pofile.language)
- self.assertEqual(potemplate, dummy_pofile.potemplate)
+ # When there are no actual PO files, we get a PlaceholderPOFile
+ # object instead.
+ placeholder_pofile = pofiles[0]
+ naked_placeholder = removeSecurityProxy(placeholder_pofile)
+ self.assertIsPlaceholder(naked_placeholder)
+ self.assertEqual(self.language, placeholder_pofile.language)
+ self.assertEqual(potemplate, placeholder_pofile.potemplate)
# Two queries get executed when listifying
# TranslatedLanguageMixin.pofiles: a len() does a count, and
@@ -129,7 +127,7 @@ class TestTranslatedLanguageMixin(TestCaseWithFactory):
# then all POTemplates and POFiles are fetched with the other.
self.assertStatementCount(2, list, translated_language.pofiles)
- def test_pofiles_two_templates_one_dummy(self):
+ def test_pofiles_two_templates_one_placeholder(self):
translated_language = self.getTranslatedLanguage(self.language)
# Two templates with different priorities so they get sorted
# appropriately.
@@ -138,8 +136,8 @@ class TestTranslatedLanguageMixin(TestCaseWithFactory):
self.addPOTemplate(priority=1)
pofiles = translated_language.pofiles
self.assertEqual(pofile1, pofiles[0])
- dummy_pofile = removeSecurityProxy(pofiles[1])
- self.assertIsDummy(dummy_pofile)
+ placeholder_pofile = removeSecurityProxy(pofiles[1])
+ self.assertIsPlaceholder(placeholder_pofile)
# Two queries get executed when listifying
# TranslatedLanguageMixin.pofiles: a len() does a count, and
@@ -170,8 +168,8 @@ class TestTranslatedLanguageMixin(TestCaseWithFactory):
self.assertStatementCount(
1, get_slice, translated_language.pofiles, 1, 3)
- def test_pofiles_slicing_dummies(self):
- # Slicing includes DummyPOFiles.
+ def test_pofiles_slicing_placeholders(self):
+ # Slicing includes PlaceholderPOFiles.
translated_language = self.getTranslatedLanguage(self.language)
# Three templates with different priorities so they get sorted
# appropriately.
@@ -181,8 +179,8 @@ class TestTranslatedLanguageMixin(TestCaseWithFactory):
pofiles = translated_language.pofiles[1:3]
self.assertEqual(pofile2, pofiles[0])
- dummy_pofile = removeSecurityProxy(pofiles[1])
- self.assertIsDummy(dummy_pofile)
+ placeholder_pofile = removeSecurityProxy(pofiles[1])
+ self.assertIsPlaceholder(placeholder_pofile)
def test_statistics_empty(self):
translated_language = self.getTranslatedLanguage(self.language)