You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
(2) |
Nov
(18) |
Dec
(26) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(14) |
Feb
(28) |
Mar
(21) |
Apr
(17) |
May
(23) |
Jun
(12) |
Jul
(12) |
Aug
(7) |
Sep
(10) |
Oct
|
Nov
(4) |
Dec
(10) |
| 2007 |
Jan
(5) |
Feb
(8) |
Mar
|
Apr
|
May
(7) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
(20) |
Oct
(3) |
Nov
(2) |
Dec
(12) |
| 2008 |
Jan
(40) |
Feb
(15) |
Mar
(1) |
Apr
|
May
(6) |
Jun
(19) |
Jul
(2) |
Aug
(17) |
Sep
(13) |
Oct
(7) |
Nov
(16) |
Dec
(5) |
| 2009 |
Jan
(15) |
Feb
(11) |
Mar
(11) |
Apr
(8) |
May
(6) |
Jun
(15) |
Jul
(19) |
Aug
(2) |
Sep
|
Oct
(19) |
Nov
(1) |
Dec
(3) |
| 2010 |
Jan
(12) |
Feb
(25) |
Mar
(45) |
Apr
(4) |
May
(2) |
Jun
(4) |
Jul
(6) |
Aug
(13) |
Sep
(1) |
Oct
(2) |
Nov
(2) |
Dec
(9) |
| 2011 |
Jan
(24) |
Feb
(7) |
Mar
(1) |
Apr
(6) |
May
(3) |
Jun
(3) |
Jul
|
Aug
(13) |
Sep
(9) |
Oct
(7) |
Nov
(17) |
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
(5) |
Apr
(3) |
May
|
Jun
|
Jul
(3) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(12) |
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
(17) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(3) |
Oct
(3) |
Nov
|
Dec
|
| 2015 |
Jan
(11) |
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(10) |
Dec
|
| 2017 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Alex H. <me...@gm...> - 2010-01-18 11:43:23
|
Thanks for the help! Sorry if it was off-topic, but I thought the problem might have been in how configobj was handling the path I was giving it. I am still pretty new to Python. If I run into more problems, I will be sure to only post if they regard configobj. BTW, configobj is great; easy to figure ouut and use, even to a noobie like me! Have a great day, Alex Email: me...@gm... ----- Original Message ----- From: "Oliver Schweitzer" <oli...@gm...> To: <con...@li...> Cc: <me...@gm...> Sent: Monday, January 18, 2010 2:55 Subject: Re: [Configobj-develop] syntax Hi! the r in front of the string literal designates a raw string (bing that), it tells the python interpreter to handle the characters inside the quotes "as is" and to not interpret the backslash \ as escape. Working alternatives would be to write "c:\\yourpath\\yourfile.ini" or "c:/yourpath/yourfile.ini" or """c:\yourpath\yourfile.ini""" Also for all thing involving paths, better get used to the os.path helper functionalities, i.e. import os iniLoc = os.path.join(sys.argv[1],'arm.ini') will give you a well formed path for your environment. Don't concatenate partial paths yourself. Also check the documentation for sys.argv, the first element (sys.argv[0]) contains the name of the script you are interpreting. All the above is easily found in freely available documentation and literature, e.g. http://diveintopython.org/toc/index.html Your email is kind of off-topic for this mailing list; since you did a smart thing with identifying and using ConfigObj, I'm happy to help you anyway. Have a nice week! Best regards, Oliver On 18.01.2010, at 04:45, Alex Hall wrote: > Hello all, > I am new to this list. I am writing a small application (so small it is > really just a single script and an ini file). I am trying to read my ini > file. This was working earlier today, but I put the initial reading in a > try > statement and now nothing works!! Does anyone see anything wrong with the > below syntax? Note that indents are one space, not four. > > iniLoc=os.path.dirname(sys.argv[0])+"\\arm.ini" > try: > ini=ConfigObj('c:\arm\arm.ini', interpolation=False, fileerror=True) > except: > print("The ARM.ini file was not found or could not be accessed. Please > make > sure no other program is using the file, and that the file "+iniLoc+" > exists, and try running ARM again.") > exitProgram() > #end except > > The program is called ARM, and the ini file is currently at > c:\arm\arm.ini. > However, the file cannot be found whether I use the iniLoc variable or > hard-code the location, as I did in the above code. > > Also, I found a tutorial earlier today that got me started, but the syntax > in that tutorial was > > file=ConfigObj(r"c:\...") > > Note the "r" in front of the path. My program did not work right until I > put > in the "r", but now it seems to make no difference. I cannot imagine what > this "r" is supposed to do, and I cannot find it in the documentation. Any > light shed on this would be great. Thanks! > > Have a great day, > Alex > Email: me...@gm... > > > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for > Conference > attendees to learn about information security's most important issues > through > interactions with peers, luminaries and emerging and established > companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop |
|
From: Oliver S. <oli...@gm...> - 2010-01-18 07:55:57
|
Hi! the r in front of the string literal designates a raw string (bing that), it tells the python interpreter to handle the characters inside the quotes "as is" and to not interpret the backslash \ as escape. Working alternatives would be to write "c:\\yourpath\\yourfile.ini" or "c:/yourpath/yourfile.ini" or """c:\yourpath\yourfile.ini""" Also for all thing involving paths, better get used to the os.path helper functionalities, i.e. import os iniLoc = os.path.join(sys.argv[1],'arm.ini') will give you a well formed path for your environment. Don't concatenate partial paths yourself. Also check the documentation for sys.argv, the first element (sys.argv[0]) contains the name of the script you are interpreting. All the above is easily found in freely available documentation and literature, e.g. http://diveintopython.org/toc/index.html Your email is kind of off-topic for this mailing list; since you did a smart thing with identifying and using ConfigObj, I'm happy to help you anyway. Have a nice week! Best regards, Oliver On 18.01.2010, at 04:45, Alex Hall wrote: > Hello all, > I am new to this list. I am writing a small application (so small it is > really just a single script and an ini file). I am trying to read my ini > file. This was working earlier today, but I put the initial reading in a try > statement and now nothing works!! Does anyone see anything wrong with the > below syntax? Note that indents are one space, not four. > > iniLoc=os.path.dirname(sys.argv[0])+"\\arm.ini" > try: > ini=ConfigObj('c:\arm\arm.ini', interpolation=False, fileerror=True) > except: > print("The ARM.ini file was not found or could not be accessed. Please make > sure no other program is using the file, and that the file "+iniLoc+" > exists, and try running ARM again.") > exitProgram() > #end except > > The program is called ARM, and the ini file is currently at c:\arm\arm.ini. > However, the file cannot be found whether I use the iniLoc variable or > hard-code the location, as I did in the above code. > > Also, I found a tutorial earlier today that got me started, but the syntax > in that tutorial was > > file=ConfigObj(r"c:\...") > > Note the "r" in front of the path. My program did not work right until I put > in the "r", but now it seems to make no difference. I cannot imagine what > this "r" is supposed to do, and I cannot find it in the documentation. Any > light shed on this would be great. Thanks! > > Have a great day, > Alex > Email: me...@gm... > > > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for Conference > attendees to learn about information security's most important issues through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop |
|
From: Alex H. <me...@gm...> - 2010-01-18 03:46:01
|
Hello all,
I am new to this list. I am writing a small application (so small it is
really just a single script and an ini file). I am trying to read my ini
file. This was working earlier today, but I put the initial reading in a try
statement and now nothing works!! Does anyone see anything wrong with the
below syntax? Note that indents are one space, not four.
iniLoc=os.path.dirname(sys.argv[0])+"\\arm.ini"
try:
ini=ConfigObj('c:\arm\arm.ini', interpolation=False, fileerror=True)
except:
print("The ARM.ini file was not found or could not be accessed. Please make
sure no other program is using the file, and that the file "+iniLoc+"
exists, and try running ARM again.")
exitProgram()
#end except
The program is called ARM, and the ini file is currently at c:\arm\arm.ini.
However, the file cannot be found whether I use the iniLoc variable or
hard-code the location, as I did in the above code.
Also, I found a tutorial earlier today that got me started, but the syntax
in that tutorial was
file=ConfigObj(r"c:\...")
Note the "r" in front of the path. My program did not work right until I put
in the "r", but now it seems to make no difference. I cannot imagine what
this "r" is supposed to do, and I cannot find it in the documentation. Any
light shed on this would be great. Thanks!
Have a great day,
Alex
Email: me...@gm...
|
|
From: Michael H. <ma...@ma...> - 2009-12-11 17:51:47
|
Am 11.12.2009 um 15:32 schrieb Michael Foord: ... >> The spec is: >> >> axis3_safe_margin = string(default= "%(ax3_letter)s safety margin >> [mm]:") >> >> The task is: >> - if the default ini file does not exist, generate it from the spec. >> - when reading the default .ini back in, I want the string equivalent >> as generated by: >> >> <foo>.axis3_safe_margin = "%(ax3_letter)s safety margin [mm]:" >> ---------------------------^^^^^^^^^^^^^ note - no mutilation here ... > Have you tried the interpolation attribute? Does that not work? Not for me. See attached example below which shows what I'm referring to. interpolation=False in the ConfigObj constructor, and I didnt find a way to express that extra for the validator. The problem seems to be the validate() function which insists on interpolating even if interpolation=False, and this should be fixed. Version was 4.6.0 . > http://www.voidspace.org.uk/python/configobj.html#interpolation > > Try setting it to False before validation and then back to True > after. It can also be passed as a keyword argument to the ConfigObj > constructor. > > Also you are incorrect that interpolation is only done against the > DEFAULT section. Version 4.4 contained a lot of improvements to the > interpolation engine and I believe this was one of the changes: Technically you are right - interpolation works against several sections - inner to outer. My point is: Insisting exclusively on intra-file interpolation between variables and formats - and copping out if a format cant be interpolated - is very limiting in the sense of what you can interpolate against (e.g. my program's variables, options, path etc ) once you want to actually use these variables. My suggestion is to provide a way to turn interpolation in the validator off completely, even in the validate() function. I would really appreciate a solution for this. thanks in advance Michael > > http://www.voidspace.org.uk/python/configobj.html#version-4-4-0 > http://www.voidspace.org.uk/python/configobj.html#string-interpolation > > """ > Interpolation checks first the current section to see if name is the > key to a value. ('name' is case sensitive). > > If it doesn't find it, next it checks the 'DEFAULT' sub-section of > the current section. > > If it still doesn't find it, it moves on to check the parent section > and the parent section's 'DEFAULT' subsection, and so on all the way > up to the main section. > """ > > > All the best, > > Michael Foord >> my suggestion: an interpolation=(True|False) parameter to validate() >> and please leave my strings untouched... >> >> >> thanks un advance >> >> Michael >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Return on Information: >> Google Enterprise Search pays you back >> Get the facts. >> http://p.sf.net/sfu/google-dev2dev >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > > > -- > http://www.ironpythoninaction.com/ > http://www.voidspace.org.uk/blog > |
|
From: Michael F. <fuz...@vo...> - 2009-12-11 14:33:07
|
On 11/12/2009 14:25, Michael Haberler wrote: > I find the ConfigObj together with validation, type conversion and > default generation extremely useful - in theory. I hope I dont > overlook something obvious, but after putting in a day to coerce > ConfigObj to do what I want I need to post this. > > Here is why: > > I have an application like many others - commandline arguments, > environment, internal variables and all. I *would* like to use > ConfigObj to handle some limited object persistence together with > validate, type conversion and to generate default .ini files. > > Some of the persistent strings will be format strings referring to > internal program variables, and I would like to get them > uninterpolated - that I do myself. > > For some reason there seems to be a built-in assumption in ConfigObj > as follows: > > - Interpolation just has to happen even during validation, > ConfigParser-style and no way to turn that off. > - and it just has to be against other variables in the DEFAULT > section, which is a fairly limiting concept of interpolation. > > Here is an example: > > The spec is: > > axis3_safe_margin = string(default= "%(ax3_letter)s safety margin > [mm]:") > > The task is: > - if the default ini file does not exist, generate it from the spec. > - when reading the default .ini back in, I want the string equivalent > as generated by: > > <foo>.axis3_safe_margin = "%(ax3_letter)s safety margin [mm]:" > ---------------------------^^^^^^^^^^^^^ note - no mutilation here > > Am I missing something here? > > The way this stands means for me: > - validation cant be used, hence no automatic type conversion and > default generation > - this means I have to use ConfigObj without validate() which means I > could pretty much stay with ConfigParser in the first place. > > > pleaaaaaaasse - provide a way to turn of this interpolation !$"!% if > one doesnt want/need it > Have you tried the interpolation attribute? Does that not work? http://www.voidspace.org.uk/python/configobj.html#interpolation Try setting it to False before validation and then back to True after. It can also be passed as a keyword argument to the ConfigObj constructor. Also you are incorrect that interpolation is only done against the DEFAULT section. Version 4.4 contained a lot of improvements to the interpolation engine and I believe this was one of the changes: http://www.voidspace.org.uk/python/configobj.html#version-4-4-0 http://www.voidspace.org.uk/python/configobj.html#string-interpolation """ Interpolation checks first the current section to see if name is the key to a value. ('name' is case sensitive). If it doesn't find it, next it checks the 'DEFAULT' sub-section of the current section. If it still doesn't find it, it moves on to check the parent section and the parent section's 'DEFAULT' subsection, and so on all the way up to the main section. """ All the best, Michael Foord > my suggestion: an interpolation=(True|False) parameter to validate() > and please leave my strings untouched... > > > thanks un advance > > Michael > > > > > > ------------------------------------------------------------------------------ > Return on Information: > Google Enterprise Search pays you back > Get the facts. > http://p.sf.net/sfu/google-dev2dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog |
|
From: Michael H. <ma...@ma...> - 2009-12-11 14:26:00
|
I find the ConfigObj together with validation, type conversion and default generation extremely useful - in theory. I hope I dont overlook something obvious, but after putting in a day to coerce ConfigObj to do what I want I need to post this. Here is why: I have an application like many others - commandline arguments, environment, internal variables and all. I *would* like to use ConfigObj to handle some limited object persistence together with validate, type conversion and to generate default .ini files. Some of the persistent strings will be format strings referring to internal program variables, and I would like to get them uninterpolated - that I do myself. For some reason there seems to be a built-in assumption in ConfigObj as follows: - Interpolation just has to happen even during validation, ConfigParser-style and no way to turn that off. - and it just has to be against other variables in the DEFAULT section, which is a fairly limiting concept of interpolation. Here is an example: The spec is: axis3_safe_margin = string(default= "%(ax3_letter)s safety margin [mm]:") The task is: - if the default ini file does not exist, generate it from the spec. - when reading the default .ini back in, I want the string equivalent as generated by: <foo>.axis3_safe_margin = "%(ax3_letter)s safety margin [mm]:" ---------------------------^^^^^^^^^^^^^ note - no mutilation here Am I missing something here? The way this stands means for me: - validation cant be used, hence no automatic type conversion and default generation - this means I have to use ConfigObj without validate() which means I could pretty much stay with ConfigParser in the first place. pleaaaaaaasse - provide a way to turn of this interpolation !$"!% if one doesnt want/need it my suggestion: an interpolation=(True|False) parameter to validate() and please leave my strings untouched... thanks un advance Michael |
|
From: Michael F. <fuz...@vo...> - 2009-11-22 23:57:15
|
Hello all,
After a long time ConfigObj 4.7.0 is nearly ready for release. All that
is needed are updates to the documentation.
If you'd like to try out the new version it is at:
http://code.google.com/p/configobj/source/browse/trunk/configobj.py
I don't think I'll do a beta unless you clamour for it?
The changelist is:
* Minimum supported version of Python is now 2.3
* ~25% performance improvement thanks to Christian Heimes
* String interpolation now works in list value members
* After validation any additional entries not in the configspec are
listed in
the ``extra_values`` section member
* Addition of the ``get_extra_values`` function for finding all extra values
in a validated ConfigObj instance
* Deprecated the use of the ``options`` dictionary in the ConfigObj
constructor
and added explicit keyword arguments instead. Use **options if you want
to initialise a ConfigObj instance from a dictionary
* BUGFIX: Checks that failed validation would not populate
'default_values' and
'restore_default_value' wouldn't work for those entries
* BUGFIX: clear() clears 'defaults'
* BUGFIX: empty values in list values were accidentally valid syntax.
They now
raise a ``ParseError``. e.g. "value = 1, , 2"
* BUGFIX: Change to the result of a call to ``validate`` when
``preserve_errors``
is True. Previously sections where *all* values failed validation would
return False for the section rather than preserving the errors. False will
now only be returned for a section if it is missing
* Distribution includes version 1.0.1 of validate.py
* Removed __revision__ and __docformat__
All the best,
Michael Foord
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|
|
From: Michael F. <fuz...@vo...> - 2009-10-31 15:17:13
|
Martino Massalini wrote:
> Hi, first of all thanks for your works. I have a stupid question but i
> didn't find an answer in the documentation.
>
> How can i remove an entire section, with all its values and sub section?
>
> With config['section1']={} i can erase all values but it still remain
> the [section1] line in the config file.
>
In the same way you delete an entry from a dictionary:
del config['section']
All the best,
Michael Foord
> Best regard,
> Martino
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> ------------------------------------------------------------------------
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|
|
From: Martino M. <mas...@gm...> - 2009-10-31 15:14:30
|
Hi, first of all thanks for your works. I have a stupid question but i
didn't find an answer in the documentation.
How can i remove an entire section, with all its values and sub section?
With config['section1']={} i can erase all values but it still remain
the [section1] line in the config file.
Best regard,
Martino
|
|
From: Michael F. <fuz...@vo...> - 2009-10-26 21:09:40
|
Pascal Chambon wrote: > Hello > > Here are 3 files that isolate the bug. Just > launch the python file as a script to see. > > * When 2 config sections are present, and one has all its config > values mispelled, we get a "missing section" error instead of "missing > keys" ones. > > * If we remove the valid "[ input ]" section in the INI file (letting > only the 'empty' "[ output ]" one, we get a weirder output : > configobj.validate returns simply "False", not a dictionary, whereas > the doc doesn't mention that behaviour. And so the error message we > want to output is corrupted (we don't even get the name of the missing > section/keys). > > Good luck for with this, if more info/help required just tell me. Ok, so I *finally* got round to looking into this. It turns out that if *every* value in a section is missing (even if the section itself is there) then it also gets marked with a False in the return value from validation. I'm looking now at how easy it is to fix this behaviour. Michael > > Regards, > Pascal Chambon > > ------------------------------------------------------------------------ > *De :* Pascal Chambon [mailto:pyt...@gm...] > *Envoyé :* lundi 29 juin 2009 19:47 > *À :* con...@li... > *Objet :* Re: [Configobj-develop] - confused by an error message > > Sure, I send it in one week (as soon I as get back from holiday to > my work project...) > > Regards, > Pascal > > Michael Foord wrote: >> That does sound like a bug in ConfigObj. Could you post an example ini >> file and code that shows the problem please. >> >> Thanks >> >> Michael >> >> >> -- >> http://www.ironpythoninaction.com >> >> On 29 Jun 2009, at 16:14, Pascal Chambon <pyt...@gm...> wrote: >> >> >>> Hello >>> >>> I just report a little confusion I once faced : I kept having a >>> "missing >>> section" error message when validating my config.ini file, and I >>> didn't >>> understand because the section WAS there. In the end, I realized that >>> there were just typos in the names of the variables inside that >>> section, >>> and it made the validator believe that the section didn't exist at all >>> (actually it existed, but it was empty). >>> So well, if it's not too much trouble for such a minor bug, it might >>> be >>> cool to replace this error message with a more accurate ones ("field >>> mysection.xxx is missing" or smth like that). >>> >>> Cheers for all, >>> regards, >>> Pascal Chambon >>> >>> --- >>> --- >>> --- >>> --------------------------------------------------------------------- >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> > > ********************************* > This message and any attachments (the "message") are confidential and > intended solely for the addressees. > Any unauthorised use or dissemination is prohibited. > Messages are susceptible to alteration. > France Telecom Group shall not be liable for the message if altered, > changed or falsified. > If you are not the intended addressee of this message, please cancel > it immediately and inform the sender. > ******************************** > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog |
|
From: Michael F. <fuz...@vo...> - 2009-10-25 18:04:35
|
Hello all, Currently list values aren't interpolated. There is an issue with patch attached: http://code.google.com/p/configobj/issues/detail?id=2 Other than there being no test the patch is straightforward, and it seems like a reasonable request. Anyone feel strongly that it shouldn't be applied (with reasoning of course)? Michael -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog |
|
From: Michael F. <fuz...@vo...> - 2009-10-19 00:19:51
|
On 19 Oct 2009, at 01:10, Cameron Stone <cam...@cs...> wrote: > On Sun, 18 Oct 2009 12:00:23 pm David Hostetler wrote: >> I have to respectfully disagree with your description of a 'nicer' >> behavior. >> >> What you're proposing would break the clean semantic behavior of cfg >> parsing and validating. >> >> If a user deletes a section name, but leaves the key/value pairs that >> previously belonged to it, then those key/value pairs *ARE* part of >> the >> preceeding section! What you're asking is for validate to >> complain about >> a scenario that is only a problem in your contorted use case. It is >> simultaneously a perfectly valid scenario in other cases. > > I must respectfully agree with you here. > Nice to see people respectfully agreeing with each other. It doesn't happen enough on open source mailing lists. Michael Foord -- http://www.ironpythoninaction.com > I also like the idea of optionally flagging extra key/value pairs > that aren't > in the spec, as a way of detecting typos and other errors. I'm using a > ConfigObj to parse a file that also gets modified manually, so it > happens more > often than I'd like. > > Nice work, > > Cameron. > > --- > --- > --- > --------------------------------------------------------------------- > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop |
|
From: Cameron S. <cam...@cs...> - 2009-10-19 00:10:56
|
On Sun, 18 Oct 2009 12:00:23 pm David Hostetler wrote: > I have to respectfully disagree with your description of a 'nicer' > behavior. > > What you're proposing would break the clean semantic behavior of cfg > parsing and validating. > > If a user deletes a section name, but leaves the key/value pairs that > previously belonged to it, then those key/value pairs *ARE* part of the > preceeding section! What you're asking is for validate to complain about > a scenario that is only a problem in your contorted use case. It is > simultaneously a perfectly valid scenario in other cases. I must respectfully agree with you here. I also like the idea of optionally flagging extra key/value pairs that aren't in the spec, as a way of detecting typos and other errors. I'm using a ConfigObj to parse a file that also gets modified manually, so it happens more often than I'd like. Nice work, Cameron. |
|
From: Jeremy G. <jr...@gm...> - 2009-10-18 13:44:42
|
David, thanks for taking the time to carefully explain this, it helps a lot. I was confused about what validation is intended to do. I was thinking that validation should just fail if there's not an explicit section label in the config file (e.g., Michael's example). > there is nothing semantically wrong with the cfg content that you provided > for validation. I was thinking that there was something wrong--namely no section '[b]'. But it seems that a valid section can be given either a) explicitly (in the config file), or b) implicitly (in the spec file -- but only if there are defaults for the items in the section). I was only expecting "explicitly present" to count as valid, not the implicit part. So as I now understand it, validation is not merely a process to *check* whether the contents of a config file are valid by themselves (explicit), but also a process to try to *make* those contents valid, reconstructing anything necessary (such as missing sections, i.e., making the implicit part explicit again). and it can only do such reconstruction if there are default values. thanks again, --Jeremy On Sat, Oct 17, 2009 at 9:00 PM, David Hostetler <neg...@gm...> wrote: > I have to respectfully disagree with your description of a 'nicer' behavior. > > What you're proposing would break the clean semantic behavior of cfg parsing > and validating. > > If a user deletes a section name, but leaves the key/value pairs that > previously belonged to it, then those key/value pairs *ARE* part of the > preceeding section! What you're asking is for validate to complain about a > scenario that is only a problem in your contorted use case. It is > simultaneously a perfectly valid scenario in other cases. And furthermore, > there is nothing semantically wrong with the cfg content that you provided > for validation. > > The format and interpretation of cfg content is unambiguous and semantically > robust. It's behavior in the scenario you've described is both predictable > and exactly what I would want it to do. If you change a cfg file in the way > you describe, and validate it with the same validation spec, it's adhering > to both the cfg rules and the validation spec perfectly. You omitted a > section whose values all have defaults, so it provides those defaults for > you. You have key/value pairs in another section that are prefectly > legitimate key/value pairs, and if there were validation rules that applied > to those keywords in that particular section, they would get applied > normally. Just because you didn't want those key/value pairs in that > section -- i.e. their presence there is inadvertent and a result of someone > changing cfg content in an unintended/undesirable way -- doesn't mean that > it is the responsibility of configobj or validate to either fix or detect > it, because the changes themselves are perfectly valid, and the modules > can't determine intent. > > What you're asking is like asking the python interpreter to complain about a > comment in the code because maybe someone inadvertently put a '#' in front > of some lines. How is the interpreter supposed to know the difference > between an intended comment and an unintended comment? > > > regards, > > David Hostetler > > > > On Sat, Oct 17, 2009 at 14:41, Jeremy Gray <jr...@gm...> wrote: >> >> at risk of getting academic about this (sorry, that's my day job, >> being an academic :-) ), I have one more thought.... >> >> and I want to emphasize that I'm certainly not asking for a new >> feature, or somehow insisting that there's a bug. not at all! its your >> program, it works, and I'm glad to be using it. >> >> >> then there is at least the >> >> possibility that they have been changed right under the user's nose. >> >> >> > >> > Only if they didn't supply them (i.e. nothing has 'changed'). >> >> this may be true most of the time. in my case, however, I allow users >> to edit the config files (which I recognize is probably a bad idea, >> and I plan to rewrite so they can't do this). currently, my users can >> set specific values to something other than the defaults. if the user >> then deletes only the section name, all values within that section >> revert to defaults when validate is called -- so something has indeed >> changed. (the previously-edited values are retained but now they are >> in a different section, and so no longer accessible reliably.) and >> there's not a handy flag that I can catch to handle this situation. I >> could track which items were non-default, and then after validating >> check if some of the values had become the default (by comparing each >> against using config.defaults). but it would seem more straightforward >> to have validation fail and report a missing section, which could then >> be reset to defaults if so desired. (in my case I would not do that -- >> its not always a desirable action). >> >> anyway, just my .02 -- its a very nice set of tools. >> >> > You can always use 'config.defaults' for a list of all entries filled >> > from default values. >> >> interesting... >> >> looking forward to 4.7, >> >> --Jeremy >> >> >> > All the best, >> > >> > Michael Foord >> >> eventually I'll be structuring things so that my users cannot edit the >> >> config file directly, avoiding this situation. >> >> >> >> >> >>> In order to fill in the default >> >>> ConfigObj *has* to create the section so it is no longer missing. >> >>> >> >> >> >> that makes sense. >> >> >> >> thanks again, >> >> >> >> --Jeremy >> >> >> >> >> >> >> >>> It would also make things harder for error handling code - if you have >> >>> to handle a missing section then you would no longer know if the >> >>> section >> >>> is actually present in the resulting ConfigObj instance or not... >> >>> >> >>> All the best, >> >>> >> >>> Michael Foord >> >>> >> >>>> --Jeremy >> >>>> >> >>>> >> >>>> ------------------------------------------------------------------------------ >> >>>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> >>>> is the only developer event you need to attend this year. Jumpstart >> >>>> your >> >>>> developing skills, take BlackBerry mobile applications to market and >> >>>> stay >> >>>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> >>>> http://p.sf.net/sfu/devconference >> >>>> _______________________________________________ >> >>>> Configobj-develop mailing list >> >>>> Con...@li... >> >>>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >>>> >> >>>> >> >>> -- >> >>> http://www.ironpythoninaction.com/ >> >>> http://www.voidspace.org.uk/blog >> >>> >> >>> >> >>> >> >>> >> >>> ------------------------------------------------------------------------------ >> >>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> >>> is the only developer event you need to attend this year. Jumpstart >> >>> your >> >>> developing skills, take BlackBerry mobile applications to market and >> >>> stay >> >>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> >>> http://p.sf.net/sfu/devconference >> >>> _______________________________________________ >> >>> Configobj-develop mailing list >> >>> Con...@li... >> >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >>> >> >>> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> >> is the only developer event you need to attend this year. Jumpstart >> >> your >> >> developing skills, take BlackBerry mobile applications to market and >> >> stay >> >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> >> http://p.sf.net/sfu/devconference >> >> _______________________________________________ >> >> Configobj-develop mailing list >> >> Con...@li... >> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> >> > >> > >> > -- >> > http://www.ironpythoninaction.com/ >> > http://www.voidspace.org.uk/blog >> > >> > >> > >> > >> > ------------------------------------------------------------------------------ >> > Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> > is the only developer event you need to attend this year. Jumpstart your >> > developing skills, take BlackBerry mobile applications to market and >> > stay >> > ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> > http://p.sf.net/sfu/devconference >> > _______________________________________________ >> > Configobj-develop mailing list >> > Con...@li... >> > https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > >> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > |
|
From: David H. <neg...@gm...> - 2009-10-18 01:00:56
|
I have to respectfully disagree with your description of a 'nicer' behavior. What you're proposing would break the clean semantic behavior of cfg parsing and validating. If a user deletes a section name, but leaves the key/value pairs that previously belonged to it, then those key/value pairs *ARE* part of the preceeding section! What you're asking is for validate to complain about a scenario that is only a problem in your contorted use case. It is simultaneously a perfectly valid scenario in other cases. And furthermore, there is nothing semantically wrong with the cfg content that you provided for validation. The format and interpretation of cfg content is unambiguous and semantically robust. It's behavior in the scenario you've described is both predictable and exactly what I would want it to do. If you change a cfg file in the way you describe, and validate it with the same validation spec, it's adhering to both the cfg rules and the validation spec perfectly. You omitted a section whose values all have defaults, so it provides those defaults for you. You have key/value pairs in another section that are prefectly legitimate key/value pairs, and if there were validation rules that applied to those keywords in that particular section, they would get applied normally. Just because you didn't want those key/value pairs in that section -- i.e. their presence there is inadvertent and a result of someone changing cfg content in an unintended/undesirable way -- doesn't mean that it is the responsibility of configobj or validate to either fix or detect it, because the changes themselves are perfectly valid, and the modules can't determine intent. What you're asking is like asking the python interpreter to complain about a comment in the code because maybe someone inadvertently put a '#' in front of some lines. How is the interpreter supposed to know the difference between an intended comment and an unintended comment? regards, David Hostetler On Sat, Oct 17, 2009 at 14:41, Jeremy Gray <jr...@gm...> wrote: > at risk of getting academic about this (sorry, that's my day job, > being an academic :-) ), I have one more thought.... > > and I want to emphasize that I'm certainly not asking for a new > feature, or somehow insisting that there's a bug. not at all! its your > program, it works, and I'm glad to be using it. > > >> then there is at least the > >> possibility that they have been changed right under the user's nose. > >> > > > > Only if they didn't supply them (i.e. nothing has 'changed'). > > this may be true most of the time. in my case, however, I allow users > to edit the config files (which I recognize is probably a bad idea, > and I plan to rewrite so they can't do this). currently, my users can > set specific values to something other than the defaults. if the user > then deletes only the section name, all values within that section > revert to defaults when validate is called -- so something has indeed > changed. (the previously-edited values are retained but now they are > in a different section, and so no longer accessible reliably.) and > there's not a handy flag that I can catch to handle this situation. I > could track which items were non-default, and then after validating > check if some of the values had become the default (by comparing each > against using config.defaults). but it would seem more straightforward > to have validation fail and report a missing section, which could then > be reset to defaults if so desired. (in my case I would not do that -- > its not always a desirable action). > > anyway, just my .02 -- its a very nice set of tools. > > > You can always use 'config.defaults' for a list of all entries filled > > from default values. > > interesting... > > looking forward to 4.7, > > --Jeremy > > > > All the best, > > > > Michael Foord > >> eventually I'll be structuring things so that my users cannot edit the > >> config file directly, avoiding this situation. > >> > >> > >>> In order to fill in the default > >>> ConfigObj *has* to create the section so it is no longer missing. > >>> > >> > >> that makes sense. > >> > >> thanks again, > >> > >> --Jeremy > >> > >> > >> > >>> It would also make things harder for error handling code - if you have > >>> to handle a missing section then you would no longer know if the > section > >>> is actually present in the resulting ConfigObj instance or not... > >>> > >>> All the best, > >>> > >>> Michael Foord > >>> > >>>> --Jeremy > >>>> > >>>> > ------------------------------------------------------------------------------ > >>>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA > >>>> is the only developer event you need to attend this year. Jumpstart > your > >>>> developing skills, take BlackBerry mobile applications to market and > stay > >>>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! > >>>> http://p.sf.net/sfu/devconference > >>>> _______________________________________________ > >>>> Configobj-develop mailing list > >>>> Con...@li... > >>>> https://lists.sourceforge.net/lists/listinfo/configobj-develop > >>>> > >>>> > >>> -- > >>> http://www.ironpythoninaction.com/ > >>> http://www.voidspace.org.uk/blog > >>> > >>> > >>> > >>> > ------------------------------------------------------------------------------ > >>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA > >>> is the only developer event you need to attend this year. Jumpstart > your > >>> developing skills, take BlackBerry mobile applications to market and > stay > >>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! > >>> http://p.sf.net/sfu/devconference > >>> _______________________________________________ > >>> Configobj-develop mailing list > >>> Con...@li... > >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop > >>> > >>> > >> > >> > ------------------------------------------------------------------------------ > >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA > >> is the only developer event you need to attend this year. Jumpstart your > >> developing skills, take BlackBerry mobile applications to market and > stay > >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! > >> http://p.sf.net/sfu/devconference > >> _______________________________________________ > >> Configobj-develop mailing list > >> Con...@li... > >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > >> > > > > > > -- > > http://www.ironpythoninaction.com/ > > http://www.voidspace.org.uk/blog > > > > > > > > > ------------------------------------------------------------------------------ > > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > > is the only developer event you need to attend this year. Jumpstart your > > developing skills, take BlackBerry mobile applications to market and stay > > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > > http://p.sf.net/sfu/devconference > > _______________________________________________ > > Configobj-develop mailing list > > Con...@li... > > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
|
From: Jeremy G. <jr...@gm...> - 2009-10-17 18:42:10
|
at risk of getting academic about this (sorry, that's my day job, being an academic :-) ), I have one more thought.... and I want to emphasize that I'm certainly not asking for a new feature, or somehow insisting that there's a bug. not at all! its your program, it works, and I'm glad to be using it. >> then there is at least the >> possibility that they have been changed right under the user's nose. >> > > Only if they didn't supply them (i.e. nothing has 'changed'). this may be true most of the time. in my case, however, I allow users to edit the config files (which I recognize is probably a bad idea, and I plan to rewrite so they can't do this). currently, my users can set specific values to something other than the defaults. if the user then deletes only the section name, all values within that section revert to defaults when validate is called -- so something has indeed changed. (the previously-edited values are retained but now they are in a different section, and so no longer accessible reliably.) and there's not a handy flag that I can catch to handle this situation. I could track which items were non-default, and then after validating check if some of the values had become the default (by comparing each against using config.defaults). but it would seem more straightforward to have validation fail and report a missing section, which could then be reset to defaults if so desired. (in my case I would not do that -- its not always a desirable action). anyway, just my .02 -- its a very nice set of tools. > You can always use 'config.defaults' for a list of all entries filled > from default values. interesting... looking forward to 4.7, --Jeremy > All the best, > > Michael Foord >> eventually I'll be structuring things so that my users cannot edit the >> config file directly, avoiding this situation. >> >> >>> In order to fill in the default >>> ConfigObj *has* to create the section so it is no longer missing. >>> >> >> that makes sense. >> >> thanks again, >> >> --Jeremy >> >> >> >>> It would also make things harder for error handling code - if you have >>> to handle a missing section then you would no longer know if the section >>> is actually present in the resulting ConfigObj instance or not... >>> >>> All the best, >>> >>> Michael Foord >>> >>>> --Jeremy >>>> >>>> ------------------------------------------------------------------------------ >>>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>>> is the only developer event you need to attend this year. Jumpstart your >>>> developing skills, take BlackBerry mobile applications to market and stay >>>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>>> http://p.sf.net/sfu/devconference >>>> _______________________________________________ >>>> Configobj-develop mailing list >>>> Con...@li... >>>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>>> >>>> >>> -- >>> http://www.ironpythoninaction.com/ >>> http://www.voidspace.org.uk/blog >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and stay >>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>> http://p.sf.net/sfu/devconference >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> >>> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > > > -- > http://www.ironpythoninaction.com/ > http://www.voidspace.org.uk/blog > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
|
From: Michael F. <fuz...@vo...> - 2009-10-17 17:43:22
|
Jeremy Gray wrote: >> Thanks for tracking this down - however I don't think that it is a bug. >> If the only values in a missing section have defaults then there are no >> missing values >> > > yes, makes sense. but.... > > >> and nothing to report. >> > > it seems to me that there is something that validate could usefully > report (and I guess I was expecting it to): if all values in a section > are being reverted to the defaults, Allowing ConfigObj to provide them when the user doesn't is the only purpose of default values... > then there is at least the > possibility that they have been changed right under the user's nose. > Only if they didn't supply them (i.e. nothing has 'changed'). > so it would be nice for validate to convey this to the outside world > somehow, eg by reporting 'True' 'Default' rather than just True? It > seems like returning 'True' is overly silent about this situation. > You can always use 'config.defaults' for a list of all entries filled from default values. All the best, Michael Foord > eventually I'll be structuring things so that my users cannot edit the > config file directly, avoiding this situation. > > >> In order to fill in the default >> ConfigObj *has* to create the section so it is no longer missing. >> > > that makes sense. > > thanks again, > > --Jeremy > > > >> It would also make things harder for error handling code - if you have >> to handle a missing section then you would no longer know if the section >> is actually present in the resulting ConfigObj instance or not... >> >> All the best, >> >> Michael Foord >> >>> --Jeremy >>> >>> ------------------------------------------------------------------------------ >>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >>> is the only developer event you need to attend this year. Jumpstart your >>> developing skills, take BlackBerry mobile applications to market and stay >>> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >>> http://p.sf.net/sfu/devconference >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> >>> >> -- >> http://www.ironpythoninaction.com/ >> http://www.voidspace.org.uk/blog >> >> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog |
|
From: Jeremy G. <jr...@gm...> - 2009-10-17 17:27:46
|
> Thanks for tracking this down - however I don't think that it is a bug. > If the only values in a missing section have defaults then there are no > missing values yes, makes sense. but.... > and nothing to report. it seems to me that there is something that validate could usefully report (and I guess I was expecting it to): if all values in a section are being reverted to the defaults, then there is at least the possibility that they have been changed right under the user's nose. so it would be nice for validate to convey this to the outside world somehow, eg by reporting 'True' 'Default' rather than just True? It seems like returning 'True' is overly silent about this situation. eventually I'll be structuring things so that my users cannot edit the config file directly, avoiding this situation. > In order to fill in the default > ConfigObj *has* to create the section so it is no longer missing. that makes sense. thanks again, --Jeremy > It would also make things harder for error handling code - if you have > to handle a missing section then you would no longer know if the section > is actually present in the resulting ConfigObj instance or not... > > All the best, > > Michael Foord >> --Jeremy >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > > > -- > http://www.ironpythoninaction.com/ > http://www.voidspace.org.uk/blog > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
|
From: Michael F. <fuz...@vo...> - 2009-10-17 16:49:08
|
Jeremy Gray wrote:
> Hi Michael,
>
> I think I've isolated this to whether the spec contains defaults for
> items in the section that goes missing. if there are defaults
> specified, the section gets recreated using the defaults, and
> validation succeeds (== the section is not reported as missing). its
> very cool to have the option to recreate the section from defaults,
> but it would seem nice to be warned about that situation too. is this
> expected behavior? is there a way to tell configobj what to do? sorry
> if I just missed this on the web page(s).
>
> original example that succeeds (validate reports missing section):
>
>>>> from configobj import ConfigObj, flatten_errors
>>>> from validate import Validator
>>>> a = ['baz = 3']
>>>> b = ['baz = integer', '[foo]', 'bar=integer']
>>>> c = ConfigObj(a, configspec=b)
>>>> v = Validator()
>>>> r = c.validate(v)
>>>> r
>>>>
> {'foo': False, 'baz': True}
>
> adding 'default=2' WITHIN the section in b that is missing from a
> (namely section [foo]): validate does not report the missing section:
>
>>>> a = ['baz = 3']
>>>> b = ['baz = integer', '[foo]', 'bar=integer(default=2)']
>>>> c = ConfigObj(a, configspec=b)
>>>> r = c.validate(v)
>>>> r
>>>>
> True
>
> adding 'default=2', but outside the section that is missing: validate
> does report the missing section:
>
>>>> b = ['baz = integer(default=2)', '[foo]', 'bar=integer']
>>>> c = ConfigObj(a, configspec=b)
>>>> r = c.validate(v)
>>>> r
>>>>
> {'foo': False, 'baz': True}
>
Thanks for tracking this down - however I don't think that it is a bug.
If the only values in a missing section have defaults then there are no
missing values and nothing to report. In order to fill in the default
ConfigObj *has* to create the section so it is no longer missing.
It would also make things harder for error handling code - if you have
to handle a missing section then you would no longer know if the section
is actually present in the resulting ConfigObj instance or not...
All the best,
Michael Foord
> --Jeremy
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|
|
From: Jeremy G. <jr...@gm...> - 2009-10-16 23:21:48
|
Hi Michael,
I think I've isolated this to whether the spec contains defaults for
items in the section that goes missing. if there are defaults
specified, the section gets recreated using the defaults, and
validation succeeds (== the section is not reported as missing). its
very cool to have the option to recreate the section from defaults,
but it would seem nice to be warned about that situation too. is this
expected behavior? is there a way to tell configobj what to do? sorry
if I just missed this on the web page(s).
original example that succeeds (validate reports missing section):
>>> from configobj import ConfigObj, flatten_errors
>>> from validate import Validator
>>> a = ['baz = 3']
>>> b = ['baz = integer', '[foo]', 'bar=integer']
>>> c = ConfigObj(a, configspec=b)
>>> v = Validator()
>>> r = c.validate(v)
>>> r
{'foo': False, 'baz': True}
adding 'default=2' WITHIN the section in b that is missing from a
(namely section [foo]): validate does not report the missing section:
>>> a = ['baz = 3']
>>> b = ['baz = integer', '[foo]', 'bar=integer(default=2)']
>>> c = ConfigObj(a, configspec=b)
>>> r = c.validate(v)
>>> r
True
adding 'default=2', but outside the section that is missing: validate
does report the missing section:
>>> b = ['baz = integer(default=2)', '[foo]', 'bar=integer']
>>> c = ConfigObj(a, configspec=b)
>>> r = c.validate(v)
>>> r
{'foo': False, 'baz': True}
--Jeremy
|
|
From: Jeremy G. <jr...@gm...> - 2009-10-15 16:11:21
|
here's a more streamlined version of my repro:
>>> from configobj import ConfigObj, flatten_errors
>>> from validate import Validator
>>> s = ConfigObj(['[a]','a1=integer(default=1)','[b]','b1=integer(default=2)'])
>>> c = ConfigObj(['[a]','a1=2','b1=dsa'], configspec=s)
>>> v = Validator()
>>> r = cfg.validate(v)
>>> r
True
>>> cfg['b']
{'b1': 2}
On Wed, Oct 14, 2009 at 9:36 PM, Jeremy Gray <jr...@gm...> wrote:
> Michael
>
> thanks for such a quick reply!
>
>> I have a version 4.7 in the works that I am part way through with
>> various improvements / bugfixes so I can make sure this issue is included.
>
> cool
>
>>> 2. how are missing sections reported by a Validator()?
>> I'm not seeing that behavior, can you provide a minimal repro.
>
> I think I have a repro but am not positive I am doing everything
> right. its not ultra-minimal because I used two text files, doing so
> because this is close to my actual arrangement. its the first thing I
> tried and seems to reproduce the lack of error reported for a missing
> section. at the very least, going through this will reveal more
> precisely what I am confused about.
>
> so one file is 'test.cfg' and contains 4 lines (3rd line is blank--its
> where I would have a section named [b] but I deleted it from the text
> file):
> [a]
> a1 = 2
>
> b1 = dsa
> the other file is 'test.spec' and also has 4 lines:
> [a]
> a1 = integer(default=2)
> [b]
> b1 = integer(default=1)
>
> then interactively:
>>>> import configobj
>>>> configobj.__version__
> '4.6.0'
>>>> from configobj import ConfigObj, flatten_errors
>>>> from validate import Validator
>>>> sp = ConfigObj('test.spec')
>>>> sp
> ConfigObj({'a': {'a1': 'integer(default=2)'}, 'b': {'b1':
> 'integer(default=1)'}})
>>>> cfg = ConfigObj('test.cfg', configspec=sp)
>>>> cfg
> ConfigObj({'a': {'a1': '2', 'b1': 'dsa'}})
>>>> v = Validator()
>>>> r = cfg.validate(v)
>>>> r
> True
>>>> flatten_errors(cfg, r)
> []
>>>> cfg['a']
> {'a1': 2, 'b1': 'dsa'}
>>>> cfg['b']
> {'b1': 1}
>
> it seems like:
> - b1 ends up in cfg[a] and is is not getting flagged as invalid
> - [b] is in sp / test.spec but is not flagged as missing in cfg /
> test.cfg--which surprises me
> - after validation there is now a section [b] in cfg but it contains
> stuff from the spec, namely the default value b1 = 1. I'm surprised
> that [b] shows up at all. the fact that is does could explain why I
> get a "duplicate section error" if I add the section back into my cfg
> file (in my code).
>
> I also tried doing the above but with an explicit copy=False in the
> validation step, but still get section [b] showing up in cfg
>>>> r = cfg.validate(v, copy=False)
>>>> r
> True
>>>> cfg['b']
> {'b1': 1}
>
> thanks for any clarification on what should be happening
>
>>> 3. finally, does anyone know of an existing project I could look at
>>> (and borrow from) that uses wxPython for a GUI for letting users
>>> manipulate configobj data?
>>
>> I can't help with this one I'm afraid.
>
> ah well. maybe someone else will know of a wx example?
>
> of course, just having configobj is a huge help! thanks again,
>
> --Jeremy
>
|
|
From: Jeremy G. <jr...@gm...> - 2009-10-15 01:43:50
|
Michael
thanks for such a quick reply!
> I have a version 4.7 in the works that I am part way through with
> various improvements / bugfixes so I can make sure this issue is included.
cool
>> 2. how are missing sections reported by a Validator()?
> I'm not seeing that behavior, can you provide a minimal repro.
I think I have a repro but am not positive I am doing everything
right. its not ultra-minimal because I used two text files, doing so
because this is close to my actual arrangement. its the first thing I
tried and seems to reproduce the lack of error reported for a missing
section. at the very least, going through this will reveal more
precisely what I am confused about.
so one file is 'test.cfg' and contains 4 lines (3rd line is blank--its
where I would have a section named [b] but I deleted it from the text
file):
[a]
a1 = 2
b1 = dsa
the other file is 'test.spec' and also has 4 lines:
[a]
a1 = integer(default=2)
[b]
b1 = integer(default=1)
then interactively:
>>> import configobj
>>> configobj.__version__
'4.6.0'
>>> from configobj import ConfigObj, flatten_errors
>>> from validate import Validator
>>> sp = ConfigObj('test.spec')
>>> sp
ConfigObj({'a': {'a1': 'integer(default=2)'}, 'b': {'b1':
'integer(default=1)'}})
>>> cfg = ConfigObj('test.cfg', configspec=sp)
>>> cfg
ConfigObj({'a': {'a1': '2', 'b1': 'dsa'}})
>>> v = Validator()
>>> r = cfg.validate(v)
>>> r
True
>>> flatten_errors(cfg, r)
[]
>>> cfg['a']
{'a1': 2, 'b1': 'dsa'}
>>> cfg['b']
{'b1': 1}
it seems like:
- b1 ends up in cfg[a] and is is not getting flagged as invalid
- [b] is in sp / test.spec but is not flagged as missing in cfg /
test.cfg--which surprises me
- after validation there is now a section [b] in cfg but it contains
stuff from the spec, namely the default value b1 = 1. I'm surprised
that [b] shows up at all. the fact that is does could explain why I
get a "duplicate section error" if I add the section back into my cfg
file (in my code).
I also tried doing the above but with an explicit copy=False in the
validation step, but still get section [b] showing up in cfg
>>> r = cfg.validate(v, copy=False)
>>> r
True
>>> cfg['b']
{'b1': 1}
thanks for any clarification on what should be happening
>> 3. finally, does anyone know of an existing project I could look at
>> (and borrow from) that uses wxPython for a GUI for letting users
>> manipulate configobj data?
>
> I can't help with this one I'm afraid.
ah well. maybe someone else will know of a wx example?
of course, just having configobj is a huge help! thanks again,
--Jeremy
|
|
From: Michael F. <fuz...@vo...> - 2009-10-14 22:52:45
|
Jeremy Gray wrote:
> Hi Michael and everyone,
>
> I'm new to using configobj, and like it a lot. thanks for your work on this!
>
> I have 3 hopefully simple questions that I could not figure out after
> reading the online manuals / help pages or past postings to the list.
>
> my goal: I want allow users to edit their application preferences, eg,
> key-bindings and other settings for the app. I'm storing the settings
> in text files with syntax as expected by configobj, and have a spec
> file for default values and for validation purposes. the idea is to
> let users edit their config files in a text window, validate their
> entries, and save. Mostly this works fabulously. the eventual goal is
> to do this through a GUI, but its text for now. I'm using python 2.5,
> and need to end up with code that works cross-platform (mac, win,
> linux).
>
> here's what I'm asking about: if a user enters a badly formed value
> (i.e., that fails validation against the spec file), I've been using
> the flatten_errors() function to process it further, like this
> mock-code (hopefully indentation will be preserved when posted...):
> <code>
> for (section_list, key, _) in configobj.flatten_errors(cfg,
> resultOfValidate):
> if key is not None:
> print "Bad value"
> # code here to replace the bad value with the default
> given in the spec file
> else:
> print "Missing section"
> # code here to handle missing sections
> </code>
>
> my questions:
> 1. how to restore a default value?
> I tried using restore_default(), but I kept getting key errors (and
> tried several things as keys).
This is very odd. There is a passing test for restore_default, but when
I call it myself it doesn't work.
I need to investigate, but at least I have a failing test.
restore_default and restore_defaults should just work...
> I also tried get_default_value(), but
> am confused by how to call it, and what to pass to it.
get_default_value takes the configspec check string. You could call it
like this:
>>> from configobj import ConfigObj
>>> from validate import Validator
>>> a = ['foo = fish']
>>> b = ['foo = integer(default=3)']
>>> c = ConfigObj(a, configspec=b)
>>> c
ConfigObj({'foo': 'fish'})
>>> v = Validator()
>>> c.validate(v)
False
>>> v.get_default_value(c.configspec['foo'])
3
It shouldn't be necessary though.
I have a version 4.7 in the works that I am part way through with
various improvements / bugfixes so I can make sure this issue is included.
> I wrote a few
> lines to extract the default value from the spec file as a string and
> then convert the type (which mostly works, I'm just having trouble
> getting default lists to work properly). it would be nice to use the
> existing functions. any ideas?
>
> 2. how are missing sections reported by a Validator()? I was thinking
> that they would be indicated by the key being None, based on the
> example(s) on the web, but my code never hits the "missing section"
> part. if a user deletes a section, the section name appears to be
> deleted in the config file, but there's no missing section flagged as
> a key == None in flatten_errors(). if the user then adds the [section]
> back into the text, I get a duplicate section name error. so I am
> confused -- what should I be looking for?
>
I'm not seeing that behavior, can you provide a minimal repro. Here is a
small example of using flatten_errors where a missing section is
represented with None for the key value:
>>> from configobj import ConfigObj, flatten_errors
>>> from validate import Validator
>>> a = ['baz = 3']
>>> b = ['baz = integer', '[foo]', 'bar=integer']
>>> c = ConfigObj(a, configspec=b)
>>> v = Validator()
>>> r = c.validate(v)
>>> r
{'foo': False, 'baz': True}
>>> flatten_errors(c, r)
[(['foo'], None, False)]
> 3. finally, does anyone know of an existing project I could look at
> (and borrow from) that uses wxPython for a GUI for letting users
> manipulate configobj data? I found a relevant post to this list by
> Sebastian Wiesner on Aug 12, 2008 that linked to examples using PyQt4
> (http://paste.pocoo.org/show/79974/ ) -- is there anything using
> wxPython?
>
>
I can't help with this one I'm afraid.
Michael
> thanks!
>
> --Jeremy
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|
|
From: Jeremy G. <jr...@gm...> - 2009-10-14 15:23:34
|
Hi Michael and everyone,
I'm new to using configobj, and like it a lot. thanks for your work on this!
I have 3 hopefully simple questions that I could not figure out after
reading the online manuals / help pages or past postings to the list.
my goal: I want allow users to edit their application preferences, eg,
key-bindings and other settings for the app. I'm storing the settings
in text files with syntax as expected by configobj, and have a spec
file for default values and for validation purposes. the idea is to
let users edit their config files in a text window, validate their
entries, and save. Mostly this works fabulously. the eventual goal is
to do this through a GUI, but its text for now. I'm using python 2.5,
and need to end up with code that works cross-platform (mac, win,
linux).
here's what I'm asking about: if a user enters a badly formed value
(i.e., that fails validation against the spec file), I've been using
the flatten_errors() function to process it further, like this
mock-code (hopefully indentation will be preserved when posted...):
<code>
for (section_list, key, _) in configobj.flatten_errors(cfg,
resultOfValidate):
if key is not None:
print "Bad value"
# code here to replace the bad value with the default
given in the spec file
else:
print "Missing section"
# code here to handle missing sections
</code>
my questions:
1. how to restore a default value?
I tried using restore_default(), but I kept getting key errors (and
tried several things as keys). I also tried get_default_value(), but
am confused by how to call it, and what to pass to it. I wrote a few
lines to extract the default value from the spec file as a string and
then convert the type (which mostly works, I'm just having trouble
getting default lists to work properly). it would be nice to use the
existing functions. any ideas?
2. how are missing sections reported by a Validator()? I was thinking
that they would be indicated by the key being None, based on the
example(s) on the web, but my code never hits the "missing section"
part. if a user deletes a section, the section name appears to be
deleted in the config file, but there's no missing section flagged as
a key == None in flatten_errors(). if the user then adds the [section]
back into the text, I get a duplicate section name error. so I am
confused -- what should I be looking for?
3. finally, does anyone know of an existing project I could look at
(and borrow from) that uses wxPython for a GUI for letting users
manipulate configobj data? I found a relevant post to this list by
Sebastian Wiesner on Aug 12, 2008 that linked to examples using PyQt4
(http://paste.pocoo.org/show/79974/ ) -- is there anything using
wxPython?
thanks!
--Jeremy
|
|
From: Michael F. <fuz...@vo...> - 2009-08-26 20:09:31
|
Hello Alex,
I'm afraid empty values like that aren't valid syntax in ConfigObj
config files - yes empty quotes ("") can be used to represent empty
values in a config file.
All the best,
Michael
ale...@se... wrote:
> I've been hoping to use configobj to read database field parameters into a
> script using configobj. Preserving the order of keys and in built list
> handling make it a very nice fit.
>
> I've come up against a parsing error, when a list contains an empty value
> represented by 2 adjacent commas (i.e. ,,)
>
> PythonWin 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> (Intel)] on win32.import
> Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for
> further copyright information.
>
>>>> import os
>>>> os.chdir('h:/src/localview')
>>>> import configobj
>>>> configobj.ConfigObj('tmp.ini')
>>>>
> ConfigObj({'Fields': {'Name': ['TEXT', '0', '0', '100', 'NULLABLE',
> 'NON_REQUIRED']}})
>
>>>> configobj.ConfigObj('tmp2.ini')
>>>>
> Traceback (most recent call last):
> File "<interactive input>", line 1, in <module>
> File "configobj.py", line 1219, in __init__
> self._load(infile, configspec)
> File "configobj.py", line 1302, in _load
> raise error
> ParseError: Parse error in value at line 2.
>
>>>> for line in open('tmp.ini'): print repr(line)
>>>>
> ...
> '[Fields]\n'
> 'Name = TEXT,0,0,100,NULLABLE,NON_REQUIRED,\n'
> '\n'
>
>>>> for line in open('tmp2.ini'): print repr(line)
>>>>
> ...
> '[Fields]\n'
> 'Name = TEXT,0,0,100,,NULLABLE,NON_REQUIRED,\n'
> '\n'
>
>
> Should this be submitted as a bug, or should I be putting quotes around all
> empty values?
>
> Regards, Alex
> --
> Alex Willmer <ale...@se...>
> Application Support Analyst, Property & GIS Application Support Team
> Service Birmingham, Units 2 & 3, B1 Building, Summer Hill Rd, Birmingham,
> B1 3RB
> Tel +44 (0)121 3033653 Mob +44 (0)7833 059297
>
>
> ***********************************************************************
> The information contained within this e-mail (and any attachment) sent by Service Birmingham Ltd. is confidential and may be legally privileged. It is intended only for the named recipient or entity to whom it is addressed. If you are not the intended recipient, please notify the sender and delete the e-mail immediately. Unauthorised access, use, disclosure, storage or copying is not permitted and may be unlawful. Any e-mail including its content may be monitored and used by Service Birmingham Ltd. for reasons of security and for monitoring internal compliance with Security Policy. E-mail blocking software will also be used. Any views or opinions expressed are solely those of the originator and do not necessarily represent those of Service Birmingham Ltd.
>
> Although Service Birmingham Ltd. has made every reasonable effort to ensure that this message and any attachments contain no viruses and have not been intercepted or amended, it can not make any assurances to this effect.
>
> Service Birmingham Ltd, Registered in England & Wales under Company No: 05660977
> Registered Office: Units 2&3 B1, 50 Summer Hill Road, Birmingham, B1 3RB.
> ***********************************************************************
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|