Closed Bug 1399819 Opened 7 years ago Closed 7 years ago

[compare-locales] simplify command line handler

Categories

(Localization Infrastructure and Tools :: compare-locales, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Pike, Assigned: Pike)

References

Details

Attachments

(3 files)

Right now, the code in commands.py is a bit entangled.

I'd like to re-use that code in order to make the mach command in m-c compatible with the command in compare-locales proper.

So let's clean that up a bit.
Assignee: nobody → l10n
Comment on attachment 8908138 [details]
bug 1399819, refactor commands, stop using base class,

https://reviewboard.mozilla.org/r/179816/#review185444
Attachment #8908138 - Flags: review?(stas) → review+
Comment on attachment 8908139 [details]
bug 1399819, separate command handler from argument parsing,

https://reviewboard.mozilla.org/r/179818/#review185446
Attachment #8908139 - Flags: review?(stas) → review+
Comment on attachment 8908140 [details]
bug 1399819, pass arguments explicitly to handle(),

https://reviewboard.mozilla.org/r/179820/#review185448

::: compare_locales/commands.py:91
(Diff revision 1)
>          logging.getLogger().setLevel(logging.WARNING -
>                                       (args.v - args.q) * 10)
> -        return self.handle(args)
> -
> -    def handle(self, args):
> +        kwargs = vars(args)
> +        # strip handeld arguments
> +        for arg in ('v', 'q'):
> +            kwargs.pop(arg)

This is a tiny nit, but perhaps simply two `kwargs.pop` calls would be more readable here.

::: compare_locales/commands.py:105
(Diff revision 1)
>          # locales
> -        all_args = args.config + [args.l10n_base_dir] + args.locales
> -        del args.config[:]
> -        del args.locales[:]
> +        all_args = config_paths + [l10n_base_dir] + locales
> +        config_paths = []
> +        locales = []
> +        if defines is None:
> +            defines = []

Nit: since you're not appending to `defines` anywhere here, you could specify `[]` as the default value in the signature.  I'm not sure how Pythonic that would be though.
Attachment #8908140 - Flags: review?(stas) → review+
Thanks.

I fixed the pop, but I'm strict on myself and mutable default params. Even if it wouldn't matter in this case.

https://hg.mozilla.org/l10n/compare-locales/pushloghtml?changeset=336be2d55e99
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: