Merge lp:~jtv/launchpad/validate-translations-file into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Brad Crittenden on 2010-01-05 |
| Approved revision: | not available |
| Merged at revision: | not available |
| Proposed branch: | lp:~jtv/launchpad/validate-translations-file |
| Merge into: | lp:launchpad |
| Diff against target: |
461 lines (+317/-10) 7 files modified
lib/lp/translations/scripts/tests/test-data/minimal.pot (+8/-0) lib/lp/translations/scripts/tests/test_validate_translations_file.py (+131/-0) lib/lp/translations/scripts/validate_translations_file.py (+130/-0) lib/lp/translations/utilities/mozilla_xpi_importer.py (+2/-0) lib/lp/translations/utilities/tests/test_xpi_manifest.py (+21/-10) lib/lp/translations/utilities/xpi_manifest.py (+7/-0) scripts/rosetta/validate-translations-file.py (+18/-0) |
| To merge this branch: | bzr merge lp:~jtv/launchpad/validate-translations-file |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Brad Crittenden (community) | code | 2010-01-05 | Approve on 2010-01-05 |
|
Review via email:
|
|||
Commit Message
Validator script for translations files. Also, a leading newline in an XPI manifest is now recognized as an error.
| Jeroen T. Vermeulen (jtv) wrote : | # |
| Brad Crittenden (bac) wrote : | # |
Hi Jeroen,
Thanks for this branch and new tool. It looks good except for a few minor things. r=bac, merge-conditional
> === added file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -0,0 +1,133 @@
> +#! /usr/bin/python2.5
> +#
> +# Copyright 2010 Canonical Ltd. This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
You win brownie points for getting the year right!
> +"""Test the validate-
> +
> +import logging
> +import os.path
> +from textwrap import dedent
> +from unittest import TestCase, TestLoader
> +
> +from canonical.
> +
> +import lp.translations
> +
> +from lp.translations
> + UnknownFileType, ValidateTransla
> +from lp.translations
> + get_en_
> +
> +
> +class TestValidateTra
> +
> + def _makeValidator(
> + """Produce a ValidateTransla
> + if test_args is None:
> + test_args = []
> + validator = ValidateTransla
> + validator.
> + return validator
> +
> + def _strip(self, file_contents):
> + """Remove leading newlines & indentation from file_contents."""
> + return dedent(
> +
> + def _findTestData(
> + """Return base path to this test's test data."""
> + return os.path.join(
> + os.path.
> + 'scripts/
> +
> + def test_validate_
> + # Unknown filename extensions result in UnknownFileType.
> + validator = self._makeValid
The argument list here is confusing. Does it serve any purpose? If
not please remove it.
> === added file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -0,0 +1,131 @@
> +# Copyright 2010 Canonical Ltd. This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +__metaclass__ = type
> +
> +__all__ = [
> + 'UnknownFileType',
> + 'ValidateTransl
> + ]
> +
> +from cStringIO import StringIO
> +import logging
> +from optparse import OptionParser
> +import os.path
> +
> +from canonical.launchpad import scripts
> +from lp.translations
> +from lp.translations
> + DtdFile, MozillaZipImpor
> +from lp.translations
> +
> +
> +class UnknownFileType
> + """File's type is not recognized."""...
| Jeroen T. Vermeulen (jtv) wrote : | # |
Thank you. You were absolutely right about the confusing test_args; they were mostly meant to be illustrative here but I thought I'd need them at some point. Turns out I don't, and I just removed the entire mechanism. Simple is beautiful.

= Bug 503382 =
For Firefox in particular, in order to detect problems with broken translation files early and stay tightly coupled to upstream, the Ubuntu folks need to test translation files for syntax errors and such that would prevent them from importing into Launchpad.
In the case of Firefox (which uses XPI archives for translation, not gettext), a complication is that the upstream files are available as raw files that, on build, would go into an XPI archive. The main type of file to check is DTD files. We need to check these without building full XPI files, but the organization of files within XPI archives can be different from the directory hierarchies in the revision-controlled source tree.
This branch adds a script that parses translations files in a variety of formats. Only DTD and manifest files were requested, but adding a few formats was easy enough and may come in handy.
Note that this is not a full LaunchpadScript, although I did borrow a few snippets of setup code from there. It does not need locking, activity monitoring, etc. but standard options like -v can be useful.
One of the tests re-uses the XPI helpers that currently live in lp.translations .utilities. tests. Maybe those should be moved, though I'm not sure where.
Test with: translations_ file
{{{
./bin/test -vv -t validate_
}}}
No lint. To Q/A, run the new script against a variety of files in these formats.
Jeroen