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."""
|
|
|
|
|
2018-10-10 18:10:55 +03:00
|
|
|
@Command('compare-locales', category='build',
|
2015-03-18 20:47:36 +03:00
|
|
|
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')
|
2018-12-03 15:08:31 +03:00
|
|
|
@CommandArgument('-q', '--quiet', action='count',
|
|
|
|
default=0, help='''Show less data.
|
|
|
|
Specified once, don't show obsolete entities. Specified twice, also hide
|
|
|
|
missing entities. Specify thrice to exclude warnings and four times to
|
|
|
|
just show stats''')
|
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('-m', '--merge',
|
|
|
|
help='''Use this directory to stage merged files''')
|
2018-12-03 15:08:31 +03:00
|
|
|
@CommandArgument('--validate', action='store_true',
|
|
|
|
help='Run compare-locales against reference')
|
|
|
|
@CommandArgument('--json',
|
|
|
|
help='''Serialize to JSON. Value is the name of
|
|
|
|
the output file, pass "-" to serialize to stdout and hide the default output.
|
|
|
|
''')
|
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('-D', action='append', metavar='var=value',
|
|
|
|
default=[], dest='defines',
|
|
|
|
help='Overwrite variables in TOML files')
|
|
|
|
@CommandArgument('--full', action="store_true",
|
|
|
|
help="Compare projects that are disabled")
|
2018-12-03 15:08:31 +03:00
|
|
|
@CommandArgument('--return-zero', action="store_true",
|
|
|
|
help="Return 0 regardless of l10n status")
|
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
|
|
|
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)
|