On 03/ 8/13 03:24 PM, Erik Trauschke wrote:
Hi Ed,
Sorry for the delay, this is the updated version:
- in opts_parse(), you removed the asserts to check for duplicate
options in the input options table:
# make sure each key is unique
assert k not in rv
--8<--
- in opts_parse(), i'm not sure i agree with this comment:
# A dict doesn't work here because some options can be passed multiple
# times. The option processing has to figure out if that's valid, this
# here should be as generic as possible.
we already know if an option can be repeated or not based on it's
"default" value. only options with a default value of an integer or a
list can be repeated. so you can check for that here. (this code
seems to have been moved to client.py right after the call to
opts_parse().
--8<--
src/modules/client.py
- why isn't all the code for building "opt_dict" inside options.py? it
seems like it should be part of opts_assemble().
all the above pretty much relates to each other so I'll respond for all
this together.
As per our discussion before, the code doesn't belong in options.py
because this serves as some sort of interface so the types which go in
there should be set before. We were talking about moving it potentially
to misc.opts_parse().
The issue with this is that if I do all the work in misc.opts_parse I
can't use options.get_pkg_opts_defaults() for getting the default value
since misc should not know about options for being generic (and it would
create a circular import). So to create the opts_dict depending on the
option types I would have to loop through the opts_table, which is a
list of (option, default_value) tuples, for every single option to find
the default value. Even though we parse options only once and this isn't
a huge performance hit it seems kinda wrong to me.
I will do it if you feel strongly about moving it to misc but I would
rather not.
I talked to Ed about this off-line and we agreed to move the code into
misc.py since we'd have to do an inefficient search in the option lists
anyway.
Otherwise he was fine with the changes and I'll put back the code in a bit.
Erik
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss