bug 1370213, error on missing configuration files and bad l10n-base-dir, r=flod
authorAxel Hecht <axel@pike.org>
Thu, 08 Jun 2017 13:49:00 +0200
changeset 267 fca288f0e156fb7d2c5b57f08fce69d1b23fc092
parent 260 fd159b984acf395badabb7da0b252c45c6cfcdfe
child 268 d2ac92f7e9f5a50300315177e3bc5b17088141ed
child 269 30240c3976dc110636d180f1d890e6e6c1d69fa3
push id70
push useraxel@mozilla.com
push dateFri, 09 Jun 2017 09:38:02 +0000
reviewersflod
bugs1370213
bug 1370213, error on missing configuration files and bad l10n-base-dir, r=flod Also fix up help text and file names to indicate that we're looking for toml files primarily. MozReview-Commit-ID: 32JfclNRXSx
compare_locales/commands.py
--- a/compare_locales/commands.py
+++ b/compare_locales/commands.py
@@ -72,26 +72,26 @@ data in a json useful for Exhibit
         """Subclasses need to implement this method for the actual
         command handling.
         """
         raise NotImplementedError
 
 
 class CompareLocales(BaseCommand):
     """Check the localization status of gecko applications.
-The first arguments are paths to the l10n.ini files for the applications,
-followed by the base directory of the localization repositories.
+The first arguments are paths to the l10n.ini or toml files for the
+applications, followed by the base directory of the localization repositories.
 Then you pass in the list of locale codes you want to compare. If there are
-not locales given, the list of locales will be taken from the all-locales file
-of the application\'s l10n.ini."""
+not locales given, the list of locales will be taken from the l10n.toml file
+or the all-locales file referenced by the application\'s l10n.ini."""
 
     def get_parser(self):
         parser = super(CompareLocales, self).get_parser()
-        parser.add_argument('config', metavar='l10n.ini', nargs='+',
-                            help='INI file for the project')
+        parser.add_argument('config', metavar='l10n.toml', nargs='+',
+                            help='TOML or INI file for the project')
         parser.add_argument('l10n_base_dir', metavar='l10n-base-dir',
                             help='Parent directory of localizations')
         parser.add_argument('locales', nargs='*', metavar='locale-code',
                             help='Locale code and top-level directory of '
                                  'each localization')
         parser.add_argument('--unified', action="store_true",
                             help="Show output for all projects unified")
         parser.add_argument('--clobber-merge', action="store_true",
@@ -107,18 +107,25 @@ Be careful to specify the right merge di
     def handle(self, args):
         # using nargs multiple times in argparser totally screws things
         # up, repair that.
         # First files are configs, then the base dir, everything else is
         # locales
         all_args = args.config + [args.l10n_base_dir] + args.locales
         del args.config[:]
         del args.locales[:]
-        while all_args and os.path.isfile(all_args[0]):
+        while all_args and not os.path.isdir(all_args[0]):
             args.config.append(all_args.pop(0))
+        if not args.config:
+            self.parser.error('no configuration file given')
+        for cf in args.config:
+            if not os.path.isfile(cf):
+                self.parser.error('config file %s not found' % cf)
+        if not all_args:
+            self.parser.error('l10n-base-dir not found')
         args.l10n_base_dir = all_args.pop(0)
         args.locales.extend(all_args)
         configs = []
         config_env = {}  # Hook up commandline arguments here
         for config_path in args.config:
             if config_path.endswith('.toml'):
                 config = TOMLParser.parse(config_path, env=config_env)
                 config.add_global_environment(l10n_base=args.l10n_base_dir)