Re: [rhinstaller/blivet/pulls/291 master] Translation tests
by dashea
Updated and rearranged. I redid the subtree commit with --squash, so that's now just two commits: one for the squashed translation-canary history and one for the special merge commit that puts it in its own directory.
I squashed all the pieces that integrate translation-canary into blivet into one commit, 996d3e9653b41e3ec0f65ccbc7ca551b1ed68e3c, and changed the commit message to something that I hope explains things better.
There are two commits that change the blivet build process. One switches to using setup.py sdist instead of git archive to create release tarballs, which allows for changes not kept in git to be distributed in the tarball and makes `make release` consistent with `make local`. The other adds an update to blivet.pot in scratch-bumpver so that changes to blivet.pot are included in testing.
The last commit is the comments on the byte prefixes, and I changed the decimal comments to use 10^x as suggested.
--
To view this pull request on github, visit https://github.com/rhinstaller/blivet/pull/291
8 years, 5 months
[master 6/6] Add translator comments to the byte size prefixes.
by dashea
From: David Shea <dshea(a)redhat.com>
---
blivet/size.py | 97 ++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 80 insertions(+), 17 deletions(-)
diff --git a/blivet/size.py b/blivet/size.py
index 383b61c..310bbab 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -42,29 +42,92 @@
_DECIMAL_FACTOR = 10 ** 3
_BINARY_FACTOR = 2 ** 10
+# TRANSLATORS: 'B' for "Bytes"
_BYTES_SYMBOL = N_("B")
_BYTES_WORDS = (N_("bytes"), N_("byte"))
# Symbolic constants for units
B = _Prefix(1, "", "")
-KB = _Prefix(_DECIMAL_FACTOR ** 1, N_("kilo"), N_("k"))
-MB = _Prefix(_DECIMAL_FACTOR ** 2, N_("mega"), N_("M"))
-GB = _Prefix(_DECIMAL_FACTOR ** 3, N_("giga"), N_("G"))
-TB = _Prefix(_DECIMAL_FACTOR ** 4, N_("tera"), N_("T"))
-PB = _Prefix(_DECIMAL_FACTOR ** 5, N_("peta"), N_("P"))
-EB = _Prefix(_DECIMAL_FACTOR ** 6, N_("exa"), N_("E"))
-ZB = _Prefix(_DECIMAL_FACTOR ** 7, N_("zetta"), N_("Z"))
-YB = _Prefix(_DECIMAL_FACTOR ** 8, N_("yotta"), N_("Y"))
-
-KiB = _Prefix(_BINARY_FACTOR ** 1, N_("kibi"), N_("Ki"))
-MiB = _Prefix(_BINARY_FACTOR ** 2, N_("mebi"), N_("Mi"))
-GiB = _Prefix(_BINARY_FACTOR ** 3, N_("gibi"), N_("Gi"))
-TiB = _Prefix(_BINARY_FACTOR ** 4, N_("tebi"), N_("Ti"))
-PiB = _Prefix(_BINARY_FACTOR ** 5, N_("pebi"), N_("Pi"))
-EiB = _Prefix(_BINARY_FACTOR ** 6, N_("exbi"), N_("Ei"))
-ZiB = _Prefix(_BINARY_FACTOR ** 7, N_("zebi"), N_("Zi"))
-YiB = _Prefix(_BINARY_FACTOR ** 8, N_("yobi"), N_("Yi"))
+KB = _Prefix(_DECIMAL_FACTOR ** 1,
+ N_("kilo"),
+ # TRANSLATORS: "k" for "kilo-" (x 10^3)
+ N_("k") )
+
+MB = _Prefix(_DECIMAL_FACTOR ** 2,
+ N_("mega"),
+ # TRANSLATORS: "M" for "mega-" (x 10^6)
+ N_("M") )
+
+GB = _Prefix(_DECIMAL_FACTOR ** 3,
+ N_("giga"),
+ # TRANSLATORS: "G" for "giga-" (x 10^9)
+ N_("G") )
+
+TB = _Prefix(_DECIMAL_FACTOR ** 4,
+ N_("tera"),
+ # TRANSLATORS: "T" for "tera-" (x 10^12)
+ N_("T") )
+
+PB = _Prefix(_DECIMAL_FACTOR ** 5,
+ N_("peta"),
+ # TRANSLATORS: "P" for "peta-" (x 10^15)
+ N_("P") )
+
+EB = _Prefix(_DECIMAL_FACTOR ** 6,
+ N_("exa"),
+ # TRANSLATORS: "E" for "exa-" (x 10^18)
+ N_("E") )
+
+ZB = _Prefix(_DECIMAL_FACTOR ** 7,
+ N_("zetta"),
+ # TRANSLATORS: "Z" for "zetta-" (x 10^21)
+ N_("Z") )
+
+YB = _Prefix(_DECIMAL_FACTOR ** 8,
+ N_("yotta"),
+ # TRANSLATORS: "Y" for "yotta-" (x 10^24)
+ N_("Y") )
+
+KiB = _Prefix(_BINARY_FACTOR ** 1,
+ N_("kibi"),
+ # TRANSLATORS: "Ki" for "kibi-" (x 2^10)
+ N_("Ki") )
+
+MiB = _Prefix(_BINARY_FACTOR ** 2,
+ N_("mebi"),
+ # TRANSLATORS: "Mi" for "mebi-" (x 2^20)
+ N_("Mi") )
+
+GiB = _Prefix(_BINARY_FACTOR ** 3,
+ N_("gibi"),
+ # TRANSLATORS: "Gi" for "gibi-" (x 2^30)
+ N_("Gi") )
+
+TiB = _Prefix(_BINARY_FACTOR ** 4,
+ N_("tebi"),
+ # TRANSLATORS: "Ti" for "tebi-" (x 2^40)
+ N_("Ti") )
+
+PiB = _Prefix(_BINARY_FACTOR ** 5,
+ N_("pebi"),
+ # TRANSLATORS: "Pi" for "pebi-" (x 2^50)
+ N_("Pi") )
+
+EiB = _Prefix(_BINARY_FACTOR ** 6,
+ N_("exbi"),
+ # TRANSLATORS: "Ei" for "exbi-" (x 2^60)
+ N_("Ei") )
+
+ZiB = _Prefix(_BINARY_FACTOR ** 7,
+ N_("zebi"),
+ # TRANSLATORS: "Zi" for "zebi-" (x 2^70)
+ N_("Zi") )
+
+YiB = _Prefix(_BINARY_FACTOR ** 8,
+ N_("yobi"),
+ # TRANSLATORS: "Yi" for "yobi-" (x 2^80)
+ N_("Yi") )
# Categories of symbolic constants
_DECIMAL_PREFIXES = [KB, MB, GB, TB, PB, EB, ZB, YB]
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/b868cdcc81c9bb165dae09a8d326...
8 years, 5 months
[master 5/6] Integrate translation-canary with blivet.
by dashea
From: David Shea <dshea(a)redhat.com>
This affects three areas of developing and distributing blivet:
- During "make check", run the translation canary tests on both
translatable and translated strings. Errors in translatable strings
are issues that need to be fixed by the developer. Errors in
translated strings are issues that need to be fixed, possibly by
removing the translation for a string, on Zanata.
Additionally, ignore the translation-canary files during the pylint
phase of "make check" since translation-canary is already checked
separately and uses a different pocketlint configuration.
- During the creation of blivet.pot (updated when a release is being
prepared), use xgettext_werror from translation-canary. This will
fail if xgettext issues a warning, which is usually about an
untranslatable format string.
This check cannot effectively be run during like the other canary
tests, since creating the POT file requires project-dependent
configuration.
- During the creation of a source distribution, the tests on
translated strings are run again, this time removing any language
that does not pass the tests. This ensures that bad changes made
between the last "make check" and the final zanata pull are not
distributed.
---
Makefile | 11 ++++++++++-
po/Makefile | 4 ++--
setup.py | 9 +++++++++
tests/pylint/runpylint.py | 4 ++++
4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 21c7a11..57c514e 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,10 @@ po-empty:
exit 1 ; \
done
+# Try to fetch the real .po files, but if that fails use the empty ones
+po-fallback:
+ $(MAKE) po-pull || $(MAKE) po-empty
+
check-requires:
@echo "*** Checking if the dependencies required for testing and analysis are available ***"
@status=0 ; \
@@ -76,7 +80,12 @@ pep8: check-requires
@echo "*** Running pep8 compliance check ***"
$(PEP8) --ignore=E501 blivet/ tests/ examples/
-check: pylint pep8
+canary: check-requires po-fallback
+ @echo "*** Running translation-canary tests ***"
+ PYTHONPATH=translation-canary:$(PYTHONPATH) python3 -m translation_canary.translatable po/blivet.pot
+ PYTHONPATH=translation-canary:$(PYTHONPATH) python3 -m translation_canary.translated .
+
+check: pylint pep8 canary
clean:
-rm *.tar.gz blivet/*.pyc blivet/*/*.pyc ChangeLog
diff --git a/po/Makefile b/po/Makefile
index 692d215..b36a329 100644
--- a/po/Makefile
+++ b/po/Makefile
@@ -3,7 +3,7 @@
#
# $Id$
-TOP = ../..
+TOP = ..
# What is this package?
NLSPACKAGE = blivet
@@ -17,7 +17,7 @@ INSTALL_NLS_DIR = $(RPM_BUILD_ROOT)/usr/share/locale
# PO catalog handling
MSGMERGE = msgmerge -v
-XGETTEXT = xgettext --default-domain=$(NLSPACKAGE) \
+XGETTEXT = $(TOP)/translation-canary/xgettext_werror.sh --default-domain=$(NLSPACKAGE) \
--add-comments
MSGFMT = msgfmt --statistics --verbose
diff --git a/setup.py b/setup.py
index 5fcb3aa..6c9342f 100644
--- a/setup.py
+++ b/setup.py
@@ -71,6 +71,15 @@ def run(self):
# Run the parent command
sdist.run(self)
+ def make_release_tree(self, base_dir, files):
+ # Run the parent command first
+ sdist.make_release_tree(self, base_dir, files)
+
+ # Run translation-canary in release mode to remove any bad translations
+ sys.path.append('translation-canary')
+ from translation_canary.translated import testSourceTree
+ testSourceTree(base_dir, releaseMode=True)
+
data_files = []
if os.environ.get("READTHEDOCS", False):
generate_api_docs()
diff --git a/tests/pylint/runpylint.py b/tests/pylint/runpylint.py
index d7bd01c..edabd64 100755
--- a/tests/pylint/runpylint.py
+++ b/tests/pylint/runpylint.py
@@ -35,6 +35,10 @@ def disabledOptions(self):
"I0011", # Locally disabling %s
]
+ @property
+ def ignoreNames(self):
+ return {"translation-canary"}
+
if __name__ == "__main__":
conf = BlivetLintConfig()
linter = PocketLinter(conf)
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/996d3e9653b41e3ec0f65ccbc7ca...
8 years, 5 months
[master 4/6] Update blivet.pot during scratch-bumpver.
by dashea
From: David Shea <dshea(a)redhat.com>
This way an up-to-date blivet.pot is included in scratch source archives
and the latest changes to translatable strings can be tested.
---
Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 5aa52b6..21c7a11 100644
--- a/Makefile
+++ b/Makefile
@@ -155,7 +155,8 @@ scratch-bumpver: po-empty
if [ ! -z "$(BZDEBUG)" ]; then \
opts="$${opts} -d" ; \
fi ; \
- ( scripts/makebumpver $${opts} ) || exit 1 ;
+ ( scripts/makebumpver $${opts} ) || exit 1 ; \
+ make -C po $(PKGNAME).pot
scratch: po-empty
@rm -f ChangeLog
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/09b36687aff22fff07153596bd6b...
8 years, 5 months
[master 3/6] Always use setup.py sdist to generate source tarballs.
by dashea
From: David Shea <dshea(a)redhat.com>
Use sdist for both the "local" and "archive" make targets so that the
only difference between the two is that "archive" is built from a
specific git tag.
Include the .mo files in the sdist, and extend the sdist command from
setup.py to build the .mo files before creating the archive.
Be less weird about making the source tarball in "make local".
---
.gitignore | 1 +
MANIFEST.in | 2 +-
Makefile | 18 +++++-------------
setup.py | 11 +++++++++++
4 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/.gitignore b/.gitignore
index 2e6c97f..40b387b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ doc/blivet
doc/tests
doc/_build
po/*.gmo
+po/*.mo
po/*.po
po/POTFILES
po/en(a)boldquot.insert-header
diff --git a/MANIFEST.in b/MANIFEST.in
index 36972ba..04720c6 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,3 +1,3 @@
include COPYING ChangeLog Makefile python-blivet.spec
-recursive-include po *.po *.pot Makefile
+recursive-include po *.mo *.po *.pot Makefile
recursive-include examples *.py
diff --git a/Makefile b/Makefile
index 1c0d6bc..5aa52b6 100644
--- a/Makefile
+++ b/Makefile
@@ -104,27 +104,19 @@ tag:
release: tag archive
archive: po-pull
- @rm -f ChangeLog
- @make ChangeLog
- git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(VERSION_TAG) > $(PKGNAME)-$(VERSION).tar
+ @make -B ChangeLog
mkdir $(PKGNAME)-$(VERSION)
+ git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(VERSION_TAG) | tar -xf -
cp -r po $(PKGNAME)-$(VERSION)
cp ChangeLog $(PKGNAME)-$(VERSION)/
- tar -rf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION)
- gzip -9 $(PKGNAME)-$(VERSION).tar
+ ( cd $(PKGNAME)-$(VERSION) && $(PYTHON) setup.py -q sdist --dist-dir .. )
rm -rf $(PKGNAME)-$(VERSION)
git checkout -- po/$(PKGNAME).pot
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
local: po-pull
- @rm -f ChangeLog
- @make ChangeLog
- @rm -rf $(PKGNAME)-$(VERSION).tar.gz
- @rm -rf /tmp/$(PKGNAME)-$(VERSION) /tmp/$(PKGNAME)
- @dir=$$PWD; cp -a $$dir /tmp/$(PKGNAME)-$(VERSION)
- @cd /tmp/$(PKGNAME)-$(VERSION) ; $(PYTHON) setup.py -q sdist
- @cp /tmp/$(PKGNAME)-$(VERSION)/dist/$(PKGNAME)-$(VERSION).tar.gz .
- @rm -rf /tmp/$(PKGNAME)-$(VERSION)
+ @make -B ChangeLog
+ $(PYTHON) setup.py -q sdist --dist-dir .
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
rpmlog:
diff --git a/setup.py b/setup.py
index f27ed54..5fcb3aa 100644
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,7 @@
from distutils.core import setup
from distutils import filelist
+from distutils.command.sdist import sdist
import subprocess
import sys
import glob
@@ -61,6 +62,15 @@ def add_member_order_option(files):
flags=re.DOTALL | re.MULTILINE)
open(fn, "w").write(amended)
+# Extend the sdist command
+class blivet_sdist(sdist):
+ def run(self):
+ # Build the .mo files
+ subprocess.check_call(['make', '-C', 'po'])
+
+ # Run the parent command
+ sdist.run(self)
+
data_files = []
if os.environ.get("READTHEDOCS", False):
generate_api_docs()
@@ -70,6 +80,7 @@ def add_member_order_option(files):
data_files.append(("docs/blivet", api_doc_files))
setup(name='blivet', version='2.0',
+ cmdclass={"sdist": blivet_sdist},
description='Python module for system storage configuration',
author='David Lehman', author_email='dlehman(a)redhat.com',
url='http://fedoraproject.org/wiki/blivet',
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/d9a5382e008ae857b8abf9e704f0...
8 years, 5 months