|
From: Michael F. <fuz...@vo...> - 2010-12-13 16:07:23
|
On 13/12/2010 08:56, Stefan Parviainen wrote:
> Hi,
>
> I'm writing a graphical editor for configuration files that work with
> configobj. I would like the GUI to take into account what type an
> option has, e.g. if it's an integer with a minimum and a maximum
> specified a slider should be shown while a standard text box is shown
> if no limits are given.
>
> The problem is getting the parameters, such as "min" and "max". I know
> I can parse the spec using ConfigObj and then do a lookup based on the
> option name, but that only results in a string like
> "integer(default=3, min=0, max=5)" which I would then have to parse
> further. Does validate.py provide any help with this or do I need to
> do the parsing myself. I realize that somewhere deep down inside
> validate the values are parsed, but are they exposed to users in any
> way?
Hmm... the "real" parsing of the configspec (pulling out min and max
values etc) is done, as you guessed, inside validate.py. There is no
public API for this but you could just "steal" some of the code from there.
The checks come in as strings and they are turned into function name,
arguments and keyword arguments by Validator.check which calls
Validator._parse_with_caching.
For example:
validator = Validator()
fun_name, fun_args, fun_kwargs, default =
validator._parse_with_caching('myfunc(min=3, max=5)')
The keyword arguments, which is what you are after, come back as a
dictionary.
All the best,
Michael
> ------------------------------------------------------------------------------
> Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
> new data types, scalar functions, improved concurrency, built-in packages,
> OCI, SQL*Plus, data movement tools, best practices and more.
> http://p.sf.net/sfu/oracle-sfdev2dev
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
--
http://www.voidspace.org.uk/
READ CAREFULLY. By accepting and reading this email you agree,
on behalf of your employer, to release me from all obligations
and waivers arising from any and all NON-NEGOTIATED agreements,
licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap,
confidentiality, non-disclosure, non-compete and acceptable use
policies (”BOGUS AGREEMENTS”) that I have entered into with your
employer, its partners, licensors, agents and assigns, in
perpetuity, without prejudice to my ongoing rights and privileges.
You further represent that you have the authority to release me
from any BOGUS AGREEMENTS on behalf of your employer.
|