2015-03-18 20:47:36 +03:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this,
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2015-06-22 03:39:09 +03:00
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
2015-03-18 20:47:36 +03:00
|
|
|
|
|
|
|
from mach.decorators import (
|
|
|
|
CommandArgument,
|
|
|
|
CommandProvider,
|
|
|
|
Command,
|
|
|
|
)
|
|
|
|
|
bug 1382005, update compare-locales to 2.1, r=glandium
Vendor new dependency for compare-locales, python-fluent.
This is the 0.4.2 release of python-fluent.
Also, make mach command a bare minimum wrapper.
The compare-locales mach command used to own a couple of defaults
and opinions.
Now that those opinions and defaults are in the Makefiles, this
command can be much simpler. As a side effect, this should
make the thunderbird port easier, where none of the mach defaults
worked.
Update l10n.mk for compare-locales 2.x:
The command line interface is different now, with positional arguments.
Also, the l10n config file isn't a default anymore (that never worked
for thunderbird).
And the merge dir is now the parent of the locale dir, much like
we already anticipated in the code.
MozReview-Commit-ID: DxVVKyVSt5y
--HG--
extra : rebase_source : 7c591fea8c7d9ecef615fb56f9359d4f1bd4b340
2017-09-18 19:31:24 +03:00
|
|
|
from mach.base import (
|
|
|
|
FailedCommandError,
|
2015-03-18 20:47:36 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@CommandProvider
|
bug 1382005, update compare-locales to 2.1, r=glandium
Vendor new dependency for compare-locales, python-fluent.
This is the 0.4.2 release of python-fluent.
Also, make mach command a bare minimum wrapper.
The compare-locales mach command used to own a couple of defaults
and opinions.
Now that those opinions and defaults are in the Makefiles, this
command can be much simpler. As a side effect, this should
make the thunderbird port easier, where none of the mach defaults
worked.
Update l10n.mk for compare-locales 2.x:
The command line interface is different now, with positional arguments.
Also, the l10n config file isn't a default anymore (that never worked
for thunderbird).
And the merge dir is now the parent of the locale dir, much like
we already anticipated in the code.
MozReview-Commit-ID: DxVVKyVSt5y
--HG--
extra : rebase_source : 7c591fea8c7d9ecef615fb56f9359d4f1bd4b340
2017-09-18 19:31:24 +03:00
|
|
|
class CompareLocales(object):
|
2015-03-18 20:47:36 +03:00
|
|
|
"""Run compare-locales."""
|
|
|
|
|
|
|
|
@Command('compare-locales', category='testing',
|
|
|
|
description='Run source checks on a localization.')
|
bug 1382005, update compare-locales to 2.1, r=glandium
Vendor new dependency for compare-locales, python-fluent.
This is the 0.4.2 release of python-fluent.
Also, make mach command a bare minimum wrapper.
The compare-locales mach command used to own a couple of defaults
and opinions.
Now that those opinions and defaults are in the Makefiles, this
command can be much simpler. As a side effect, this should
make the thunderbird port easier, where none of the mach defaults
worked.
Update l10n.mk for compare-locales 2.x:
The command line interface is different now, with positional arguments.
Also, the l10n config file isn't a default anymore (that never worked
for thunderbird).
And the merge dir is now the parent of the locale dir, much like
we already anticipated in the code.
MozReview-Commit-ID: DxVVKyVSt5y
--HG--
extra : rebase_source : 7c591fea8c7d9ecef615fb56f9359d4f1bd4b340
2017-09-18 19:31:24 +03:00
|
|
|
@CommandArgument('config_paths', metavar='l10n.toml', nargs='+',
|
|
|
|
help='TOML or INI file for the project')
|
|
|
|
@CommandArgument('l10n_base_dir', metavar='l10n-base-dir',
|
|
|
|
help='Parent directory of localizations')
|
|
|
|
@CommandArgument('locales', nargs='*', metavar='locale-code',
|
|
|
|
help='Locale code and top-level directory of '
|
|
|
|
'each localization')
|
|
|
|
@CommandArgument('-m', '--merge',
|
|
|
|
help='''Use this directory to stage merged files''')
|
|
|
|
@CommandArgument('-D', action='append', metavar='var=value',
|
|
|
|
default=[], dest='defines',
|
|
|
|
help='Overwrite variables in TOML files')
|
|
|
|
@CommandArgument('--unified', action="store_true",
|
|
|
|
help="Show output for all projects unified")
|
|
|
|
@CommandArgument('--full', action="store_true",
|
|
|
|
help="Compare projects that are disabled")
|
|
|
|
def compare(self, **kwargs):
|
|
|
|
from compare_locales.commands import CompareLocales
|
|
|
|
|
|
|
|
class ErrorHelper(object):
|
|
|
|
'''Dummy ArgumentParser to marshall compare-locales
|
|
|
|
commandline errors to mach exceptions.
|
|
|
|
'''
|
|
|
|
def error(self, msg):
|
|
|
|
raise FailedCommandError(msg)
|
|
|
|
|
|
|
|
def exit(self, message=None, status=0):
|
|
|
|
raise FailedCommandError(message, exit_code=status)
|
|
|
|
|
|
|
|
cmd = CompareLocales()
|
|
|
|
cmd.parser = ErrorHelper()
|
|
|
|
return cmd.handle(**kwargs)
|