1 |
On 01 Nov 2015 09:36, Zac Medico wrote: |
2 |
> On 10/31/2015 10:23 PM, Mike Frysinger wrote: |
3 |
> > The current code implements a lot of ad-hoc argument parsing when it |
4 |
> > could simply let the argparse module do it all for it. This makes the |
5 |
> > code easier to understand and extend in the process. |
6 |
> > --- |
7 |
> > bin/xpak-helper.py | 68 ++++++++++++++++++++---------------------------------- |
8 |
> > 1 file changed, 25 insertions(+), 43 deletions(-) |
9 |
> > |
10 |
> > diff --git a/bin/xpak-helper.py b/bin/xpak-helper.py |
11 |
> > index 8c965ec..1b2883d 100755 |
12 |
> > --- a/bin/xpak-helper.py |
13 |
> > +++ b/bin/xpak-helper.py |
14 |
> [snip] |
15 |
> > -def main(argv): |
16 |
> > |
17 |
> > - if argv and isinstance(argv[0], bytes): |
18 |
> > - for i, x in enumerate(argv): |
19 |
> > - argv[i] = portage._unicode_decode(x, errors='strict') |
20 |
> |
21 |
> You've dropped the _unicode_decode call. |
22 |
|
23 |
i did on purpose. i should have mentioned that. |
24 |
|
25 |
> In order to handle python3 with arguments containing UTF-8 characters |
26 |
> (in ${PKGDIR}) and a mis-matched sys.getfilesystemencoding() value, it's |
27 |
> safest to decode the arguments like chmod-lite.py does. |
28 |
|
29 |
it seems wrong that we have incomplete coverage here. |
30 |
some tools do it and some do not. |
31 |
|
32 |
> We should create |
33 |
> a function for this code which is also duplicated in install.py: |
34 |
|
35 |
you mean portage._decode_argv ? |
36 |
|
37 |
what if we create a new module like "commandline" that provides an |
38 |
ArgumentParser interface that takes care of this for us ? |
39 |
-mike |