Closed
Bug 1318268
Opened 9 years ago
Closed 9 years ago
CLI is broken with ArgParse implementation
Categories
(Localization Infrastructure and Tools :: compare-locales, defect)
Localization Infrastructure and Tools
compare-locales
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: flod, Assigned: Pike)
References
Details
Attachments
(1 file, 2 obsolete files)
I'm not sure if it's just something wrong in my setup, but compare-locales from command line is completely broken if installed from the current tip.
This is probably beyond my ability to fix, so feel free to take over and redo it properly. That's also why I'm not using mozreview for it.
If I run compare-locales without arguments, I get this error
Traceback (most recent call last):
File "/usr/local/bin/compare-locales", line 9, in <module>
load_entry_point('compare-locales==1.2', 'console_scripts', 'compare-locales')()
File "build/bdist.macosx-10.11-intel/egg/compare_locales/commands.py", line 58, in call
import os
File "build/bdist.macosx-10.11-intel/egg/compare_locales/commands.py", line 67, in handle_
# Make command argument from directory and pathname (prefix space, add quotes).
NameError: global name 'options' is not defined
Which seems related to remnant of the optparse syntax
http://stackoverflow.com/questions/19076842/the-pythons-argparse-errors
In other places there are other issues, like using args as an array (slice, len).
| Reporter | ||
Comment 1•9 years ago
|
||
Attachment #8811637 -
Flags: feedback?(l10n)
| Reporter | ||
Comment 2•9 years ago
|
||
Even better without a random line in it.
Attachment #8811637 -
Attachment is obsolete: true
Attachment #8811637 -
Flags: feedback?(l10n)
Attachment #8811638 -
Flags: feedback?(l10n)
| Reporter | ||
Comment 3•9 years ago
|
||
Comment on attachment 8811638 [details] [diff] [review]
bug1318268v1.patch
Review of attachment 8811638 [details] [diff] [review]:
-----------------------------------------------------------------
::: compare_locales/commands.py
@@ -130,5 @@
> return parser
>
> - def handle(self, args, options):
> - if len(args) != 2:
> - self.parser.error('Reference and localizatino required')
Since it's easy to miss, there's a typo fixed here.
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8811638 [details] [diff] [review]
bug1318268v1.patch
I've taking this patch as inspiration, but I don't think that there are a lot of codes left of your patch, so I'm flinging things around.
Taking this bug, review request on you ;-)
And sorry for not testing the original landing even remotely :-(
Attachment #8811638 -
Flags: feedback?(l10n) → feedback-
| Assignee | ||
Updated•9 years ago
|
Assignee: nobody → l10n
Status: NEW → ASSIGNED
| Assignee | ||
Updated•9 years ago
|
Attachment #8811638 -
Attachment is obsolete: true
| Reporter | ||
Comment 6•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8811851 [details]
Bug 1318268 - Fix options parsing from command line,
https://reviewboard.mozilla.org/r/93774/#review94132
It looks good, just a nit on a variable name
::: compare_locales/commands.py:89
(Diff revision 1)
>
> def get_parser(self):
> parser = super(CompareLocales, self).get_parser()
> + parser.add_argument('ini_file')
> + parser.add_argument('l10n_base_dir')
> + parser.add_argument('locale', nargs='*')
nit: maybe this should be "locales"?
::: compare_locales/commands.py:143
(Diff revision 1)
> If none are given, test all locales in manifest.webapp or files."""
>
> def get_parser(self):
> parser = super(CompareWebApp, self).get_parser()
> + parser.add_argument('webapp')
> + parser.add_argument('locale', nargs='*')
Same here: locales?
Attachment #8811851 -
Flags: review?(francesco.lodolo) → review+
| Assignee | ||
Comment 7•9 years ago
|
||
That's a deficiency in argparse, as I'm now letting it define usage, and only deliver description. With 'locale' being the argument name, this generates
usage: compare-locales [-h] [--version] [-v] [-q] [-m MERGE] [--clobber-merge]
[-r REFERENCE] [--data {text,exhibit,json}]
ini_file l10n_base_dir [locale [locale ...]]
which looks better than using 'locales'.
I tried using dest='locales', but that's not working good for positional arguments :-/.
Thanks for the r+
| Reporter | ||
Comment 8•9 years ago
|
||
I think you can use metavar for that?
https://docs.python.org/2/library/argparse.html#metavar
parser.add_argument('locales', metavar="locale", nargs='*')
$ compare-locales
usage: compare-locales [-h] [--version] [-v] [-q] [-m MERGE] [--clobber-merge]
[-r REFERENCE] [--data {text,exhibit,json}]
ini_file l10n_base_dir [locale [locale ...]]
compare-locales: error: too few arguments
| Assignee | ||
Comment 9•9 years ago
|
||
Nice, yes.
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 11•9 years ago
|
||
Thanks, interdiff pushed to reviewboard, pushed as https://hg.mozilla.org/l10n/compare-locales/rev/ed711240affa70faf2753e2b1f4363eba13db854.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•