On 12/10/12 15:39, Erik Trauschke wrote:
Hi folks,
so this is the API part of the basic options checking for input parameters.
As per our discussions, it only does very basic checking but generates
proper exceptions for invalid FMRIs, invalid repo URIs and invalid
option combinations (very limited).
It also asserts the type of input parameters.
Please have a look at the nullable column. Not sure if this is something
useful but I figured it might be a good idea. I set it based on default
values in the planning functions, it might be that some need changing.
For the FMRI validation step I'm currently generating a
PlanCreationException to keep things like they were before. However, I
could imagine an FmriError would also be appropriate but would require
changes in the client. I'm fine either way.
https://cr.opensolaris.org/action/browse/pkg/erisch/15981296/webrev/
I filed an additional bug for this cr. For the other bug I will
implement the options checking in a common place, based off of my first
approach. This doesn't move anything into the API but allows 3rd party
clients to use the CLI options including their verification steps.
src/modules/client/api.py:
line 1013: s/x = //
line 1015: Should be:
raise AssertionError("%s is not an iterable") % a
lines 1017-1018: suggest:
assert (args[a] is None or
isinstance(args[a], a_type))
lines 1021-1022: There's no hard rule about this, but parens are
generally preferred over "\" for line-continuation with lists of values.
lines 1021-1022: This should actually aggregate all of the errors
and then raise the error for all of them.
line 1060: s/;//
lines 1062-1065: Just use misc.valid_pub_url() instead.
line 1068: Ideally, this would raise a single exception for all of
the rejected URIs. Unfortunately, such an exception doesn't exist right
now. Not a stopper, but something to consider.
src/modules/client/api_errors.py:
line 2987: s/=[]/=EmptyI/
line 3008: drop the parens
lines 3011-3012, 3015-3016, 3019-3020, 3022:
Missing _(). In this case since the order the options are printed
doesn't matter, you can skip the named format specifiers (as you've
already done). (e.g. '%(option_1)s' vs '%s').
Can you provide some example output for each case?
-Shawn
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss