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: Michael F. <fuz...@vo...> - 2010-03-19 15:57:21
|
On 17/03/2010 02:13, Chaim Krause wrote:
> *[snip...]*
> *I think it needs to be...*
>
> from configobj import ConfigObj, flatten_errors
> from validate import Validator
>
> config = ConfigObj('config.ini', configspec='configspec.ini')
> validator = Validator()
> results = config.validate(validator, preserve_errors=True)
>
Actually, the code that calls flatten_errors doesn't use the third entry
from each tuple (the error object) - so I don't think it is necessary to
use preserve_errors for that particular example.
> if results != True:
> for (section_list, key, _) in flatten_errors(config, results):
> if key is not None:
> print 'The "%s" key in the section "%s" failed validation' % (key, ',
> '.join(section_list))
> else:
> print 'The following section was missing: "%s"' % ', '.join(section_list)
>
These two are definitely mistakes though.
Thanks
Michael
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
>
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
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.
|
|
From: Jason B. <jb...@ze...> - 2010-03-18 17:47:08
|
On Thu, Mar 18, 2010 at 11:20 AM, David Hostetler <neg...@gm...>wrote: > Or do you mean that you want even the crazy unanticipated stuff to get > automatic fall-through interpolation-style defaulting? In which > case, yeah, the validation approach isn't suitable, because the > interpolation reference has to be represented in the spec. > > -David > > It's this. :-) |
|
From: David H. <neg...@gm...> - 2010-03-18 16:20:57
|
Unless I'm mistaken, validation only validates what is explicitly in the spec. Anything else passes through untouched. So as long as the "crazy stuff you didn't anticipate" doesn't violate the basic configobj syntax, it'd end up in the resulting ConfigObj. Or do you mean that you want even the crazy unanticipated stuff to get automatic fall-through interpolation-style defaulting? In which case, yeah, the validation approach isn't suitable, because the interpolation reference has to be represented in the spec. -David On Thu, Mar 18, 2010 at 12:06, Jason Baker <jb...@ze...> wrote: > On Thu, Mar 18, 2010 at 9:38 AM, David Hostetler <neg...@gm...> > wrote: >> >> Is there some reason you can't use validate to set the default? >> >> Consider the following validation spec: >> >> [project] >> parcels = string_list() >> >> [[DEFAULT]] >> default_branch = string() >> >> [[__many__]] >> branch = string(default=$default_branch) >> >> >> Applied to the following config: >> >> [project] >> parcels = parcel1,parcel2 >> >> [[DEFAULT]] >> default_branch = master >> >> [[parcel1]] >> >> [[parcel2]] >> branch = someotherbranch >> >> >> Now when you parse the config, and validate it against the spec, you >> get the following: >> >> >> cfg['project']['parcel1']['branch'] >> >> 'master' >> >> >> >> cfg['project']['parcel2']['branch'] >> >> 'someotherbranch' >> >> >> No hackery. And you get the usual added benefits of validation. > > TL;DR - I have philosophical issues that prevent me from going that route. > > This actually brings up a good point though. Essentially, my goal in > creating envbuilder is to have a build system that's flexible enough to > adapt to what the user is trying to use it for. The above requires me to > know what options the user is looking for beforehand and code them in the > configspec. This limits the amount of crazy stuff I didn't anticipate that > a user can do. > > In that vein, envbuilder can currently handle any VCS that has a > command-line interface. The above might be sensible for git, but does it > work for hg or bzr or fossil or CVS? :-) > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > |
|
From: Jason B. <jb...@ze...> - 2010-03-18 16:06:29
|
On Thu, Mar 18, 2010 at 9:38 AM, David Hostetler <neg...@gm...>wrote: > Is there some reason you can't use validate to set the default? > > Consider the following validation spec: > > [project] > parcels = string_list() > > [[DEFAULT]] > default_branch = string() > > [[__many__]] > branch = string(default=$default_branch) > > > Applied to the following config: > > [project] > parcels = parcel1,parcel2 > > [[DEFAULT]] > default_branch = master > > [[parcel1]] > > [[parcel2]] > branch = someotherbranch > > > Now when you parse the config, and validate it against the spec, you > get the following: > > >> cfg['project']['parcel1']['branch'] > >> 'master' > >> > >> cfg['project']['parcel2']['branch'] > >> 'someotherbranch' > > > No hackery. And you get the usual added benefits of validation. > TL;DR - I have philosophical issues that prevent me from going that route. This actually brings up a good point though. Essentially, my goal in creating envbuilder is to have a build system that's flexible enough to adapt to what the user is trying to use it for. The above requires me to know what options the user is looking for beforehand and code them in the configspec. This limits the amount of crazy stuff I didn't anticipate that a user can do. In that vein, envbuilder can currently handle any VCS that has a command-line interface. The above might be sensible for git, but does it work for hg or bzr or fossil or CVS? :-) |
|
From: David H. <neg...@gm...> - 2010-03-18 14:38:48
|
Is there some reason you can't use validate to set the default?
Consider the following validation spec:
[project]
parcels = string_list()
[[DEFAULT]]
default_branch = string()
[[__many__]]
branch = string(default=$default_branch)
Applied to the following config:
[project]
parcels = parcel1,parcel2
[[DEFAULT]]
default_branch = master
[[parcel1]]
[[parcel2]]
branch = someotherbranch
Now when you parse the config, and validate it against the spec, you
get the following:
>> cfg['project']['parcel1']['branch']
>> 'master'
>>
>> cfg['project']['parcel2']['branch']
>> 'someotherbranch'
No hackery. And you get the usual added benefits of validation.
cheers,
-David
On Wed, Mar 17, 2010 at 18:23, Entity Reborn <ent...@gm...> wrote:
>
> On Wed, 2010-03-17 at 14:53 -0500, Jason Baker wrote:
> > On Wed, Mar 17, 2010 at 1:52 PM, Michael Foord
> > <fuz...@vo...> wrote:
> >
> >
> > Well - as far as I can tell setdefault is exactly a "magical
> > get_by_interpolation function" - so I guess I'm not
> > understanding you (setdefault is also a standard dictionary
> > method).
> >
> > Michael
> >
> > Consider the following config file:
> >
> > [section]
> > foo = 'bar'
> > [[subsection]]
> > baz = '$foo'
> >
> > Suppose I have a Section object that represents the subsection
> > (configobj['section']['subsection']). Now suppose I do this:
> >
> > a = subsection['baz']
> >
> > Since the option baz contains a string '$foo', what happens is
> > something like the following:
> >
> > 1. The interpolater looks in subsection to see if it has a foo
> > option.
> > 2. When it sees that it doesn't exist, it checks the DEFAULT section.
> > 3. When it sees that *that* doesn't exist, it checks the parent
> > section
> > 4. The parent section has a foo option, so it returns it.
> >
> > Now suppose I do this:
> >
> > b = subsection['foo']
> >
> > What happens is more like the following:
> >
> > 1. Subsection is searched for a foo option.
> > 2. Subsection doesn't have a foo option, so it throws a KeyError.
> >
> > What I would like is some kind of function such that I can do
> > something like this:
> >
> > c = subsection.get_by_interpolation('foo')
> >
> > ...that would look for an option named foo, but would look in the same
> > places as the first operation. Here's the reason why I want to do
> > this. Using envbuilder, I want to write a config file like this:
> >
> > [project]
> > parcel = 'parcel1', 'parcel2'
> >
> > [[DEFAULT]]
> > branch = 'master'
> >
> > [[parcel1]]
> >
> > [[parcel2]]
> > branch = 'someotherbranch'
> >
> > [commands]
> > [[update]]
> > default = 'git pull origin %branch'
> >
> > Essentially, I've written my own interpolation engine for commands
> > such that a variable beginning with % is to be on the parcel. So when
> > I run "envb update", it should essentially run:
> >
> > # Get parcel1 using branch from default
> > $ git pull origin master
> >
> > # Get parcel2 using branch from parcel2
> > $ git pull origin someotherbranch
> >
> > However, parcel1 would throw an exception because it doesn't actually
> > have an option named "branch". Of course, I could do something like
> > this:
> >
> > [project]
> > parcels = 'parcel1', 'parcel2'
> >
> > [[DEFAULT]]
> > default_branch = 'master'
> >
> > [[parcel1]]
> > branch = '$default_branch'
> >
> > [[parcel2]]
> > branch = 'someotherbranch'
> >
> > [commands]
> > [[update]]
> > default = 'git pull origin %branch'
> >
> > ...but that gets tedious when you start dealing with a nontrivial
> > amount of parcels.
> >
> > Does that make things more clear, or did I just confuse you even
> > more? :-)
> >
> > ------------------------------------------------------------------------------
> > Download Intel® Parallel Studio Eval
> > Try the new software tools for yourself. Speed compiling, find bugs
> > proactively, and fine-tune applications for parallel performance.
> > See why Intel Parallel Studio got high marks during beta.
> > http://p.sf.net/sfu/intel-sw-dev
> > _______________________________________________ Configobj-develop mailing list Con...@li... https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
> I as well am interested in this. Auto-interpolation of a tree of
> sections. Or rather, start from a specified branch, and then percolate
> towards the trunk until a valid variable is found.
>
> My Example: (IRC Bot)
> [servers]
> nick = BarBaz
> # ...
> [[Freenode]]
> nick = FooBar
> # ...
> [[EFNet]]
> # ...
>
> config['servers']['EFNet'] (or some similar syntax) would return
> "BarBaz"
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
|
|
From: Entity R. <ent...@gm...> - 2010-03-17 22:24:05
|
On Wed, 2010-03-17 at 14:53 -0500, Jason Baker wrote:
> On Wed, Mar 17, 2010 at 1:52 PM, Michael Foord
> <fuz...@vo...> wrote:
>
>
> Well - as far as I can tell setdefault is exactly a "magical
> get_by_interpolation function" - so I guess I'm not
> understanding you (setdefault is also a standard dictionary
> method).
>
> Michael
>
> Consider the following config file:
>
> [section]
> foo = 'bar'
> [[subsection]]
> baz = '$foo'
>
> Suppose I have a Section object that represents the subsection
> (configobj['section']['subsection']). Now suppose I do this:
>
> a = subsection['baz']
>
> Since the option baz contains a string '$foo', what happens is
> something like the following:
>
> 1. The interpolater looks in subsection to see if it has a foo
> option.
> 2. When it sees that it doesn't exist, it checks the DEFAULT section.
> 3. When it sees that *that* doesn't exist, it checks the parent
> section
> 4. The parent section has a foo option, so it returns it.
>
> Now suppose I do this:
>
> b = subsection['foo']
>
> What happens is more like the following:
>
> 1. Subsection is searched for a foo option.
> 2. Subsection doesn't have a foo option, so it throws a KeyError.
>
> What I would like is some kind of function such that I can do
> something like this:
>
> c = subsection.get_by_interpolation('foo')
>
> ...that would look for an option named foo, but would look in the same
> places as the first operation. Here's the reason why I want to do
> this. Using envbuilder, I want to write a config file like this:
>
> [project]
> parcel = 'parcel1', 'parcel2'
>
> [[DEFAULT]]
> branch = 'master'
>
> [[parcel1]]
>
> [[parcel2]]
> branch = 'someotherbranch'
>
> [commands]
> [[update]]
> default = 'git pull origin %branch'
>
> Essentially, I've written my own interpolation engine for commands
> such that a variable beginning with % is to be on the parcel. So when
> I run "envb update", it should essentially run:
>
> # Get parcel1 using branch from default
> $ git pull origin master
>
> # Get parcel2 using branch from parcel2
> $ git pull origin someotherbranch
>
> However, parcel1 would throw an exception because it doesn't actually
> have an option named "branch". Of course, I could do something like
> this:
>
> [project]
> parcels = 'parcel1', 'parcel2'
>
> [[DEFAULT]]
> default_branch = 'master'
>
> [[parcel1]]
> branch = '$default_branch'
>
> [[parcel2]]
> branch = 'someotherbranch'
>
> [commands]
> [[update]]
> default = 'git pull origin %branch'
>
> ...but that gets tedious when you start dealing with a nontrivial
> amount of parcels.
>
> Does that make things more clear, or did I just confuse you even
> more? :-)
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________ Configobj-develop mailing list Con...@li... https://lists.sourceforge.net/lists/listinfo/configobj-develop
I as well am interested in this. Auto-interpolation of a tree of
sections. Or rather, start from a specified branch, and then percolate
towards the trunk until a valid variable is found.
My Example: (IRC Bot)
[servers]
nick = BarBaz
# ...
[[Freenode]]
nick = FooBar
# ...
[[EFNet]]
# ...
config['servers']['EFNet'] (or some similar syntax) would return
"BarBaz"
|
|
From: Jason B. <jb...@ze...> - 2010-03-17 19:53:12
|
On Wed, Mar 17, 2010 at 1:52 PM, Michael Foord <fuz...@vo...>wrote:
> Well - as far as I can tell setdefault is exactly a "magical
> get_by_interpolation function" - so I guess I'm not understanding you
> (setdefault is also a standard dictionary method).
>
> Michael
>
Consider the following config file:
[section]
foo = 'bar'
[[subsection]]
baz = '$foo'
Suppose I have a Section object that represents the subsection
(configobj['section']['subsection']). Now suppose I do this:
a = subsection['baz']
Since the option baz contains a string '$foo', what happens is something
like the following:
1. The interpolater looks in subsection to see if it has a foo option.
2. When it sees that it doesn't exist, it checks the DEFAULT section.
3. When it sees that *that* doesn't exist, it checks the parent section
4. The parent section has a foo option, so it returns it.
Now suppose I do this:
b = subsection['foo']
What happens is more like the following:
1. Subsection is searched for a foo option.
2. Subsection doesn't have a foo option, so it throws a KeyError.
What I would like is some kind of function such that I can do something like
this:
c = subsection.get_by_interpolation('foo')
...that would look for an option named foo, but would look in the same
places as the first operation. Here's the reason why I want to do this.
Using envbuilder, I want to write a config file like this:
[project]
parcel = 'parcel1', 'parcel2'
[[DEFAULT]]
branch = 'master'
[[parcel1]]
[[parcel2]]
branch = 'someotherbranch'
[commands]
[[update]]
default = 'git pull origin %branch'
Essentially, I've written my own interpolation engine for commands such that
a variable beginning with % is to be on the parcel. So when I run "envb
update", it should essentially run:
# Get parcel1 using branch from default
$ git pull origin master
# Get parcel2 using branch from parcel2
$ git pull origin someotherbranch
However, parcel1 would throw an exception because it doesn't actually have
an option named "branch". Of course, I could do something like this:
[project]
parcels = 'parcel1', 'parcel2'
[[DEFAULT]]
default_branch = 'master'
[[parcel1]]
branch = '$default_branch'
[[parcel2]]
branch = 'someotherbranch'
[commands]
[[update]]
default = 'git pull origin %branch'
...but that gets tedious when you start dealing with a nontrivial amount of
parcels.
Does that make things more clear, or did I just confuse you even more? :-)
|
|
From: Michael F. <fuz...@vo...> - 2010-03-17 18:52:33
|
On 17/03/2010 18:50, Jason Baker wrote:
> On Wed, Mar 17, 2010 at 1:35 PM, Michael Foord
> <fuz...@vo... <mailto:fuz...@vo...>> wrote:
>
> How about setdefault?
>
> >>> c = ConfigObj()
> >>> c['bar'] = 'baz'
> >>> c.setdefault('foo', '%(bar)s')
> 'baz'
>
> Michael
>
>
> I'm assuming you mean using setdefault in lieu of my exception
> handling which is a good idea. However, the exception block isn't
> really my primary concern. It just feels a bit like I'm coupling my
> app a bit too closely to Section's inner workings by going that
> route. I was thinking of something more along the lines of a magical
> "get_by_interpolation" function (or something that would make
> implementing such a function easier). But, if such an animal doesn't
> exist, I suppose I'll just have to deal. :-)
Well - as far as I can tell setdefault is exactly a "magical
get_by_interpolation function" - so I guess I'm not understanding you
(setdefault is also a standard dictionary method).
Michael
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
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.
|
|
From: Jason B. <jb...@ze...> - 2010-03-17 18:50:21
|
On Wed, Mar 17, 2010 at 1:35 PM, Michael Foord <fuz...@vo...>wrote:
> How about setdefault?
>
> >>> c = ConfigObj()
> >>> c['bar'] = 'baz'
> >>> c.setdefault('foo', '%(bar)s')
> 'baz'
>
> Michael
>
I'm assuming you mean using setdefault in lieu of my exception handling
which is a good idea. However, the exception block isn't really my primary
concern. It just feels a bit like I'm coupling my app a bit too closely to
Section's inner workings by going that route. I was thinking of something
more along the lines of a magical "get_by_interpolation" function (or
something that would make implementing such a function easier). But, if
such an animal doesn't exist, I suppose I'll just have to deal. :-)
|
|
From: Michael F. <fuz...@vo...> - 2010-03-17 18:35:18
|
On 17/03/2010 15:42, Jason Baker wrote:
> I'm not really sure how best to phrase my example, so I'll illustrate
> it with code. :-)
>
> Suppose I have the following config file:
>
> [section]
> foo='bar'
> [[subsection]]
>
> Now suppose I do the following:
>
> configobj = <get configobj somehow>
> subsection = configobj['section']['subsection']
> subsection['foo']
>
> This throws a key error, which is most likely the expected behavior as
> foo isn't a key on subsection. However, I would like to have a way to
> get the value of foo as if subsection were like this:
>
> [[subsection]]
> foo = '$foo'
>
> That way I can fetch the value through the interpolation path rather
> than only checking the current section. I suppose I could do
> something like this:
>
> try:
> return subsection['foo']
> except KeyError, ke:
> subsection['foo'] = '$foo'
> return subsection['foo']
>
> But that feels a bit hacky. Are there any better ways to do this that
> I'm not thinking of, or am I just going to have to buck up and put the
> hack in?
How about setdefault?
>>> c = ConfigObj()
>>> c['bar'] = 'baz'
>>> c.setdefault('foo', '%(bar)s')
'baz'
Michael
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
>
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
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.
|
|
From: Jason B. <jb...@ze...> - 2010-03-17 16:07:13
|
I'm not really sure how best to phrase my example, so I'll illustrate it
with code. :-)
Suppose I have the following config file:
[section]
foo='bar'
[[subsection]]
Now suppose I do the following:
configobj = <get configobj somehow>
subsection = configobj['section']['subsection']
subsection['foo']
This throws a key error, which is most likely the expected behavior as foo
isn't a key on subsection. However, I would like to have a way to get the
value of foo as if subsection were like this:
[[subsection]]
foo = '$foo'
That way I can fetch the value through the interpolation path rather than
only checking the current section. I suppose I could do something like
this:
try:
return subsection['foo']
except KeyError, ke:
subsection['foo'] = '$foo'
return subsection['foo']
But that feels a bit hacky. Are there any better ways to do this that I'm
not thinking of, or am I just going to have to buck up and put the hack in?
|
|
From: Michael F. <fuz...@vo...> - 2010-03-17 10:59:29
|
On 17/03/2010 02:13, Chaim Krause wrote: > *I was looking at: > > An Introduction to ConfigObj - > http://www.voidspace.org.uk/python/articles/configobj.shtml > > And noticed some errors in one of the examples. > * From a brief look I think you are right. Thanks! I'll make the corrections. All the best, Michael > * > Example as is...* > > from configobj import ConfigObj, flatten_errors > from validate import Validator > > config = ConfigObj('config.ini', configspec='configspec.ini') > validator = Validator() > results = config.validate(validator) > > if results != True: > for (section_list, key, _) in flatten_errors(config, results): > if key is not None: > print 'The "%s"key in the section "%s" failed validation' % (key, ', > '.join(section_list)) > else: > print 'The following section was missing' % ', '.join(section_list) > > *I think it needs to be...* > > from configobj import ConfigObj, flatten_errors > from validate import Validator > > config = ConfigObj('config.ini', configspec='configspec.ini') > validator = Validator() > results = config.validate(validator, preserve_errors=True) > > if results != True: > for (section_list, key, _) in flatten_errors(config, results): > if key is not None: > print 'The "%s" key in the section "%s" failed validation' % (key, ', > '.join(section_list)) > else: > print 'The following section was missing: "%s"' % ', '.join(section_list) > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog 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. |
|
From: Chaim K. <ch...@ch...> - 2010-03-17 02:14:03
|
*I was looking at: An Introduction to ConfigObj - http://www.voidspace.org.uk/python/articles/configobj.shtml And noticed some errors in one of the examples. Example as is...* from configobj import ConfigObj, flatten_errors from validate import Validator config = ConfigObj('config.ini', configspec='configspec.ini') validator = Validator() results = config.validate(validator) if results != True: for (section_list, key, _) in flatten_errors(config, results): if key is not None: print 'The "%s"key in the section "%s" failed validation' % (key , ', '.join(section_list)) else: print 'The following section was missing' % ', '.join( section_list) *I think it needs to be...* from configobj import ConfigObj, flatten_errors from validate import Validator config = ConfigObj('config.ini', configspec='configspec.ini') validator = Validator() results = config.validate(validator, preserve_errors=True) if results != True: for (section_list, key, _) in flatten_errors(config, results): if key is not None: print 'The "%s" key in the section "%s" failed validation' % ( key, ', '.join(section_list)) else: print 'The following section was missing: "%s"' % ', '.join( section_list) |
|
From: Entity R. <ent...@gm...> - 2010-03-12 23:25:28
|
On Fri, Mar 12, 2010 at 6:05 AM, Michael Foord <fuz...@vo...>wrote: > On 12/03/2010 05:15, Entity Reborn wrote: > > Would like to make a request. > Say I pass a configobj section instance of arbitrary depth to a > function/class, I'd like a way to access the base without checking if > .parent.parent == .parent when I need to do this. Could I suggest a .baseobj > to do this? Possibly something that passes an instance of the base object > upon creation, or just do the above comparison. > > > If you need a reference to the top level ConfigOj instance why not just > pass that in as well? > > Michael > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta.http://p.sf.net/sfu/intel-sw-dev > > > _______________________________________________ > Configobj-develop mailing lis...@li...://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > -- http://www.ironpythoninaction.com/http://www.voidspace.org.uk/blog > > 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. > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > Point enough, but still would be helpful. :) Another item could be what I submitted my bug report with, namely the stringlist based navigation down the heirarchy of Sections. |
|
From: Michael F. <fuz...@vo...> - 2010-03-12 14:05:32
|
On 12/03/2010 05:15, Entity Reborn wrote: > Would like to make a request. > Say I pass a configobj section instance of arbitrary depth to a > function/class, I'd like a way to access the base without checking if > .parent.parent == .parent when I need to do this. Could I suggest a > .baseobj to do this? Possibly something that passes an instance of the > base object upon creation, or just do the above comparison. If you need a reference to the top level ConfigOj instance why not just pass that in as well? Michael > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog 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. |
|
From: Entity R. <ent...@gm...> - 2010-03-12 05:15:30
|
Would like to make a request. Say I pass a configobj section instance of arbitrary depth to a function/class, I'd like a way to access the base without checking if .parent.parent == .parent when I need to do this. Could I suggest a .baseobj to do this? Possibly something that passes an instance of the base object upon creation, or just do the above comparison. |
|
From: Michael F. <fuz...@vo...> - 2010-03-10 15:36:36
|
On 10/03/2010 15:03, Tom Vaughan wrote: > On Wed, Mar 10, 2010 at 03:33, Michael Foord<fuz...@vo...> wrote: > >> On 09/03/2010 14:33, Tom Vaughan wrote: >> >> I mean how do I make sure a hex string is written to the .ini file, not the >> decimal equivalent? >> >> When it is set in the ConfigObj how do you know if it is a hex string rather >> than decimal? >> > Because it starts with "0x". This is my own convention used in just my > own apps. I dictate what goes into the .ini's. > > Right, that is pretty much the standard convention, it is used by Python as well. >> If you want to allow decimal values (integer type) to be set, but write them >> out as hex strings then you will need to 'wrap' the configobj instance in >> something that converts the integers to hex strings when they are set, and >> does the reverse when they are fetched. >> > This is what my "Preferences" object does below. At least the first > part. It converts the hex string to an int. Another way I could have > done this is with "traverse". > > What do you mean by "fetched"? I suppose I could overload the write > method. But how could I tell if a value has been converted using > "conv_hex" (or any other method for that matter) via "validate"? > > What I'm suggesting is that instead of getting and setting values directly with the configobj instance you have a wrapper class or functions that do the translation. The other way would be to use the 'walk' method to do your traversal and transform (for example) all integers to hex strings prior to writing. Another approach would be to use validation and have two validators - one that converts hex strings to integers after you have read the configobj and another to convert back again prior to writing. All the best, Michael Foord > Thanks. > > -Tom > > > >> All the best, >> >> Michael >> >> >> Sent from my iPhone >> On Mar 9, 2010, at 6:23, David Hostetler<neg...@gm...> wrote: >> >> you mean... how do you print a hex value as a string? >> >> '%#x' % (val) >> >> Omit the '#' if you don't want the leading '0x'. >> >> >> http://docs.python.org/library/string.html#format-specification-mini-language >> >> >> -David >> >> >> On Mon, Mar 8, 2010 at 15:36, Tom Vaughan<to...@so...> wrote: >> >>> Hi, >>> >>> I know how to convert a hex string to an int. But how would I write >>> out the hex string? Thanks. >>> >>> -Tom >>> >>> >>> class Preferences(ConfigObj): >>> >>> def conv_hex(value): >>> return int(value, 16) >>> >>> fdict = { >>> 'hex': conv_hex, >>> } >>> >>> def __init__(self, prefsname): >>> specsname = prefsname + '.spec' >>> if os.path.exists(specsname): >>> ConfigObj.__init__(self, prefsname, >>> configspec=specsname) >>> self.validate(Validator(self.fdict)) >>> else: >>> ConfigObj.__init__(self, prefsname) >>> >>> >>> ------------------------------------------------------------------------------ >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> >> -- >> http://www.ironpythoninaction.com/ >> http://www.voidspace.org.uk/blog >> >> 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. >> >> >> > > > -- http://www.ironpythoninaction.com/ |
|
From: Tom V. <to...@so...> - 2010-03-10 15:03:09
|
On Wed, Mar 10, 2010 at 03:33, Michael Foord <fuz...@vo...> wrote: > On 09/03/2010 14:33, Tom Vaughan wrote: > > I mean how do I make sure a hex string is written to the .ini file, not the > decimal equivalent? > > When it is set in the ConfigObj how do you know if it is a hex string rather > than decimal? Because it starts with "0x". This is my own convention used in just my own apps. I dictate what goes into the .ini's. > > If you want to allow decimal values (integer type) to be set, but write them > out as hex strings then you will need to 'wrap' the configobj instance in > something that converts the integers to hex strings when they are set, and > does the reverse when they are fetched. This is what my "Preferences" object does below. At least the first part. It converts the hex string to an int. Another way I could have done this is with "traverse". What do you mean by "fetched"? I suppose I could overload the write method. But how could I tell if a value has been converted using "conv_hex" (or any other method for that matter) via "validate"? Thanks. -Tom > > All the best, > > Michael > > > Sent from my iPhone > On Mar 9, 2010, at 6:23, David Hostetler <neg...@gm...> wrote: > > you mean... how do you print a hex value as a string? > > '%#x' % (val) > > Omit the '#' if you don't want the leading '0x'. > > > http://docs.python.org/library/string.html#format-specification-mini-language > > > -David > > > On Mon, Mar 8, 2010 at 15:36, Tom Vaughan <to...@so...> wrote: >> >> Hi, >> >> I know how to convert a hex string to an int. But how would I write >> out the hex string? Thanks. >> >> -Tom >> >> >> class Preferences(ConfigObj): >> >> def conv_hex(value): >> return int(value, 16) >> >> fdict = { >> 'hex': conv_hex, >> } >> >> def __init__(self, prefsname): >> specsname = prefsname + '.spec' >> if os.path.exists(specsname): >> ConfigObj.__init__(self, prefsname, >> configspec=specsname) >> self.validate(Validator(self.fdict)) >> else: >> ConfigObj.__init__(self, prefsname) >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > -- > http://www.ironpythoninaction.com/ > http://www.voidspace.org.uk/blog > > 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. > > -- Website: www.software6.net E-mail/Google Talk: tom (at) software6 (dot) net Mobile: +1 (310) 751-0187 |
|
From: Michael F. <fuz...@vo...> - 2010-03-10 11:33:15
|
On 09/03/2010 14:33, Tom Vaughan wrote: > I mean how do I make sure a hex string is written to the .ini file, > not the decimal equivalent? When it is set in the ConfigObj how do you know if it is a hex string rather than decimal? If you want to allow decimal values (integer type) to be set, but write them out as hex strings then you will need to 'wrap' the configobj instance in something that converts the integers to hex strings when they are set, and does the reverse when they are fetched. All the best, Michael > > Sent from my iPhone > > On Mar 9, 2010, at 6:23, David Hostetler <neg...@gm... > <mailto:neg...@gm...>> wrote: > >> you mean... how do you print a hex value as a string? >> >> '%#x' % (val) >> >> Omit the '#' if you don't want the leading '0x'. >> >> >> http://docs.python.org/library/string.html#format-specification-mini-language >> >> >> -David >> >> >> On Mon, Mar 8, 2010 at 15:36, Tom Vaughan <to...@so... >> <mailto:to...@so...>> wrote: >> >> Hi, >> >> I know how to convert a hex string to an int. But how would I write >> out the hex string? Thanks. >> >> -Tom >> >> >> class Preferences(ConfigObj): >> >> def conv_hex(value): >> return int(value, 16) >> >> fdict = { >> 'hex': conv_hex, >> } >> >> def __init__(self, prefsname): >> specsname = prefsname + '.spec' >> if os.path.exists(specsname): >> ConfigObj.__init__(self, prefsname, >> configspec=specsname) >> self.validate(Validator(self.fdict)) >> else: >> ConfigObj.__init__(self, prefsname) >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> <mailto:Con...@li...> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> <mailto:Con...@li...> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog 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. |
|
From: Tom V. <to...@so...> - 2010-03-09 17:25:01
|
I mean how do I make sure a hex string is written to the .ini file, not the decimal equivalent? Sent from my iPhone On Mar 9, 2010, at 6:23, David Hostetler <neg...@gm...> wrote: > you mean... how do you print a hex value as a string? > > '%#x' % (val) > > Omit the '#' if you don't want the leading '0x'. > > > http://docs.python.org/library/string.html#format-specification-mini-language > > > -David > > > On Mon, Mar 8, 2010 at 15:36, Tom Vaughan <to...@so...> wrote: > Hi, > > I know how to convert a hex string to an int. But how would I write > out the hex string? Thanks. > > -Tom > > > class Preferences(ConfigObj): > > def conv_hex(value): > return int(value, 16) > > fdict = { > 'hex': conv_hex, > } > > def __init__(self, prefsname): > specsname = prefsname + '.spec' > if os.path.exists(specsname): > ConfigObj.__init__(self, prefsname, > configspec=specsname) > self.validate(Validator(self.fdict)) > else: > ConfigObj.__init__(self, prefsname) > > --- > --- > --- > --------------------------------------------------------------------- > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > --- > --- > --- > --------------------------------------------------------------------- > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop |
|
From: Michael F. <fuz...@vo...> - 2010-03-09 14:42:55
|
On 09/03/2010 14:37, David Hostetler wrote: > Hey Michael, > > Sorry to delay in replying. > > I don't have any great proposal either. I appreciate the dilemma. > > I'll probably mull this over some more in the background and if I come > up with anything clever I'll certainly lob it up here for review > before bothering with patchwork. I think having a 'locate' method (or similar) that fetches the values without interpolation is the right answer (and has been requested by someone else). That way if you want to mutate a list then you fetch it with locate instead of fetching it directly. At least then there is a straightforward rule for solving the problem without adding any more options or removing the list interpolation feature. All the best, Michael > > cheers, > > -David > > > > On Thu, Mar 4, 2010 at 10:35, Michael Foord <fuz...@vo... > <mailto:fuz...@vo...>> wrote: > > On 04/03/2010 15:25, Michael Foord wrote: >> On 04/03/2010 15:17, David Hostetler wrote: >>> >>> >>> On Tue, Mar 2, 2010 at 10:23, Michael Foord >>> <fuz...@vo... <mailto:fuz...@vo...>> >>> wrote: >>> >>> >>> * BUGFIX: Members that were lists were being returned as >>> copies due to >>> interpolation introduced in 4.7. Lists are now only >>> copies if interpolation >>> changes a list member. (See below.) >>> >>> >>> For general information on string interpolation in ConfigObj >>> see: >>> http://www.voidspace.org.uk/python/configobj.html#string-interpolation >>> >>> Since version 4.7 string interpolation is done on string >>> members of list values. If interpolation changes any members >>> of the list then what you get back is a /copy/ of the list >>> rather than the original list. >>> >>> This makes fetching list values slightly slower when >>> interpolation is on, it also means that if you mutate the >>> list changes won't be reflected in the original list: >>> >>> >>> c = ConfigObj() >>> >>> c['foo'] = 'boo' >>> >>> c['bar'] = ['%(foo)s'] >>> >>> c['bar'] >>> ['boo'] >>> >>> c['bar'].append('fish') >>> >>> c['bar'] >>> ['boo'] >>> >>> >>> Instead of mutating the list you must create a new list and >>> reassign it. >>> >>> >>> Hey Michael, >>> >>> I have some concern over this behavior. Namely, the >>> inconsistency bothers me. I don't like that the programmer now >>> needs to know the nature of a string value for a given list >>> option in order to be able to interact with it correctly. >>> Because the string's value *changes* the behavior. >>> >>> It feels sort of like if I were to need to know the value of an >>> integer in order to know how to use it in a mathematical >>> expression. a+b would work for certain integer values of b, but >>> would need to become a+int(str(b)[:]) for other integer values >>> of b. Yuk. >>> >>> One of the most powerful things about ConfigObj is that it >>> insulates program logic from needing a priori knowledge of input >>> data. I feel like this new list interpolation behavior violates >>> that. As programmer, I shouldn't ever care, know, or need to >>> know, whether or not the person who is providing input data >>> elected to have one piece of data substituted via reference with >>> the value of another, before it's ever given to me. >>> Interpolation of input data is something that is done outside of >>> the purview of the program consuming the input data. > > To respond to this specifically - the problem is that > interpolation of list values *requires* a new representation of > the list. The way interpolation is implemented (dynamically) we > have to do the interpolation every time the list is fetched - > values could have changed since the last time the list was > fetched. That makes returning copies when interpolation happens > inevitable. > > One option I considered was keeping an 'underlying' list of the > real values and always do interpolation into the same list > (allowing us to not have to return copies). Unfortunately lists > are mutable, so the programmer could keep a reference to the list > and change it at any point, without ConfigObj being able to detect > it. I can't think of any way of keeping the underlying list in > sync with the 'real' list of values - unless we use a custom list > subclass and tie the lists together. I would certainly be open to > a patch that provided that... :-) > > >>> Value substitution provided by interpolation is a convenience >>> mechanism for the data provider, and using it or not using it >>> shouldn't alter the consumer's interface for ConfigObj. >>> >>> As it stands, the choice to use or not use list interpolation >>> ripples over into the other side. > > It isn't a problem if you are only *consuming* the lists - or > completely replacing the list. It is only for mutation that it is > a problem. Switching off interpolation for lists only makes > interpolation 'safe', whilst losing the convenience of list > interpolation. As I mentioned in the last email, this is one > possible approach. > > In 4.8 there will be a method for fetching items bypassing > interpolation. In fact you can already do this with: > > dict.__getitem__(configobj, key) > > The list returned by this approach can be safely mutated. > > Perhaps this is sufficient? > > Michael > > >>> I think any program consuming list data provided by ConfigObj >>> will have to (or should) treat it as always immutable. In other >>> words -- I'll pretend that all lists are of the interpolated >>> variety (copies) since I can't be sure when they are and when >>> they aren't, and it's much safer to make this assumption than it >>> is to assume the opposite. >>> >>> Thoughts? >>> >> >> Well, it bothers me too - but interpolation in lists was already >> released, so the question was whether or not to pull the feature >> or fix the problem. 4.7.2 was a quick bugfix release and I'm >> certainly willing to consider how we handle this for 4.8. >> >> I can understand that if you have interpolation on and use list >> values you can no longer guarantee that mutating a list will >> work. Reassigning the list will always work, but that may wipe >> out the underlying interoplation values and so is not ideal. In >> this regard 4.7 was backwards incompatible with previous >> releases, but this was an unforseen consequence not a deliberate >> intention. If we change it again in 4.8 it will be another >> backwards incompatible release. *sigh* >> >> One option would be to have list interpolation off by default >> with (yet another) keyword argument to switch it on. That way you >> only have to worry about it if you have enabled the feature. >> >> Thoughts? >> >> Michael >> >>> >>> As always - thanks for your hard work! >>> >>> >>> regards, >>> >>> -David >>> >>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed compiling, find bugs >>> proactively, and fine-tune applications for parallel performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> >>> >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... <mailto:Con...@li...> >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> >> >> >> -- >> http://www.ironpythoninaction.com/ >> http://www.voidspace.org.uk/blog >> >> 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. >> >> >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> >> >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... <mailto:Con...@li...> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> > > > -- > http://www.ironpythoninaction.com/ > http://www.voidspace.org.uk/blog > > 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. > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > <mailto:Con...@li...> > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog 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. |
|
From: David H. <neg...@gm...> - 2010-03-09 14:38:08
|
Hey Michael, Sorry to delay in replying. I don't have any great proposal either. I appreciate the dilemma. I'll probably mull this over some more in the background and if I come up with anything clever I'll certainly lob it up here for review before bothering with patchwork. cheers, -David On Thu, Mar 4, 2010 at 10:35, Michael Foord <fuz...@vo...>wrote: > On 04/03/2010 15:25, Michael Foord wrote: > > On 04/03/2010 15:17, David Hostetler wrote: > > > > On Tue, Mar 2, 2010 at 10:23, Michael Foord <fuz...@vo...>wrote: > >> >> * BUGFIX: Members that were lists were being returned as copies due to >> interpolation introduced in 4.7. Lists are now only copies if >> interpolation >> changes a list member. (See below.) >> > >> For general information on string interpolation in ConfigObj see: >> http://www.voidspace.org.uk/python/configobj.html#string-interpolation >> >> Since version 4.7 string interpolation is done on string members of list >> values. If interpolation changes any members of the list then what you get >> back is a *copy* of the list rather than the original list. >> >> This makes fetching list values slightly slower when interpolation is on, >> it also means that if you mutate the list changes won't be reflected in the >> original list: >> >> >>> c = ConfigObj()>>> c['foo'] = 'boo'>>> c['bar'] = ['%(foo)s']>>> c['bar']['boo']>>> c['bar'].append('fish')>>> c['bar']['boo'] >> >> Instead of mutating the list you must create a new list and reassign it. >> > > Hey Michael, > > I have some concern over this behavior. Namely, the inconsistency bothers > me. I don't like that the programmer now needs to know the nature of a > string value for a given list option in order to be able to interact with it > correctly. Because the string's value *changes* the behavior. > > It feels sort of like if I were to need to know the value of an integer in > order to know how to use it in a mathematical expression. a+b would work > for certain integer values of b, but would need to become a+int(str(b)[:]) > for other integer values of b. Yuk. > > One of the most powerful things about ConfigObj is that it insulates > program logic from needing a priori knowledge of input data. I feel like > this new list interpolation behavior violates that. As programmer, I > shouldn't ever care, know, or need to know, whether or not the person who is > providing input data elected to have one piece of data substituted via > reference with the value of another, before it's ever given to me. > Interpolation of input data is something that is done outside of the purview > of the program consuming the input data. > > > To respond to this specifically - the problem is that interpolation of list > values *requires* a new representation of the list. The way interpolation is > implemented (dynamically) we have to do the interpolation every time the > list is fetched - values could have changed since the last time the list was > fetched. That makes returning copies when interpolation happens inevitable. > > One option I considered was keeping an 'underlying' list of the real values > and always do interpolation into the same list (allowing us to not have to > return copies). Unfortunately lists are mutable, so the programmer could > keep a reference to the list and change it at any point, without ConfigObj > being able to detect it. I can't think of any way of keeping the underlying > list in sync with the 'real' list of values - unless we use a custom list > subclass and tie the lists together. I would certainly be open to a patch > that provided that... :-) > > > Value substitution provided by interpolation is a convenience mechanism > for the data provider, and using it or not using it shouldn't alter the > consumer's interface for ConfigObj. > > As it stands, the choice to use or not use list interpolation ripples over > into the other side. > > > It isn't a problem if you are only *consuming* the lists - or completely > replacing the list. It is only for mutation that it is a problem. Switching > off interpolation for lists only makes interpolation 'safe', whilst losing > the convenience of list interpolation. As I mentioned in the last email, > this is one possible approach. > > In 4.8 there will be a method for fetching items bypassing interpolation. > In fact you can already do this with: > > dict.__getitem__(configobj, key) > > The list returned by this approach can be safely mutated. > > Perhaps this is sufficient? > > Michael > > > I think any program consuming list data provided by ConfigObj will have > to (or should) treat it as always immutable. In other words -- I'll pretend > that all lists are of the interpolated variety (copies) since I can't be > sure when they are and when they aren't, and it's much safer to make this > assumption than it is to assume the opposite. > > Thoughts? > > > Well, it bothers me too - but interpolation in lists was already released, > so the question was whether or not to pull the feature or fix the problem. > 4.7.2 was a quick bugfix release and I'm certainly willing to consider how > we handle this for 4.8. > > I can understand that if you have interpolation on and use list values you > can no longer guarantee that mutating a list will work. Reassigning the list > will always work, but that may wipe out the underlying interoplation values > and so is not ideal. In this regard 4.7 was backwards incompatible with > previous releases, but this was an unforseen consequence not a deliberate > intention. If we change it again in 4.8 it will be another backwards > incompatible release. *sigh* > > One option would be to have list interpolation off by default with (yet > another) keyword argument to switch it on. That way you only have to worry > about it if you have enabled the feature. > > Thoughts? > > Michael > > > As always - thanks for your hard work! > > > regards, > > -David > > > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta.http://p.sf.net/sfu/intel-sw-dev > > > _______________________________________________ > Configobj-develop mailing lis...@li...://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > -- http://www.ironpythoninaction.com/http://www.voidspace.org.uk/blog > > 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. > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta.http://p.sf.net/sfu/intel-sw-dev > > > _______________________________________________ > Configobj-develop mailing lis...@li...://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > -- http://www.ironpythoninaction.com/http://www.voidspace.org.uk/blog > > 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. > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > |
|
From: David H. <neg...@gm...> - 2010-03-09 14:23:34
|
you mean... how do you print a hex value as a string? '%#x' % (val) Omit the '#' if you don't want the leading '0x'. http://docs.python.org/library/string.html#format-specification-mini-language -David On Mon, Mar 8, 2010 at 15:36, Tom Vaughan <to...@so...> wrote: > Hi, > > I know how to convert a hex string to an int. But how would I write > out the hex string? Thanks. > > -Tom > > > class Preferences(ConfigObj): > > def conv_hex(value): > return int(value, 16) > > fdict = { > 'hex': conv_hex, > } > > def __init__(self, prefsname): > specsname = prefsname + '.spec' > if os.path.exists(specsname): > ConfigObj.__init__(self, prefsname, > configspec=specsname) > self.validate(Validator(self.fdict)) > else: > ConfigObj.__init__(self, prefsname) > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > |
|
From: Tom V. <to...@so...> - 2010-03-08 21:36:06
|
Hi,
I know how to convert a hex string to an int. But how would I write
out the hex string? Thanks.
-Tom
class Preferences(ConfigObj):
def conv_hex(value):
return int(value, 16)
fdict = {
'hex': conv_hex,
}
def __init__(self, prefsname):
specsname = prefsname + '.spec'
if os.path.exists(specsname):
ConfigObj.__init__(self, prefsname,
configspec=specsname)
self.validate(Validator(self.fdict))
else:
ConfigObj.__init__(self, prefsname)
|
|
From: Chris J. <cm...@te...> - 2010-03-04 17:00:13
|
Hi On 04/03/10 16:06, Michael Foord wrote: > Well - you can already use Hg to talk to svn, and generating a patch > from a set of diffs is a single command. As can bzr :D > specifically - not as a general statement). It is also useful to have > contributions tracked on the issue tracker as I deal with them > sporadically. Centralised systems also have their advantages. :-) For my personal projects I quite like that people can leave me a patch in a bug or push a branch to launchpad and send me a merge request. I also often rework their efforts, but I can do that on a copy of their branch and then merge it into my trunk and keep all that lovely history :) It's notionally a centralised system because I use launchpad as my development hub and access to trunk is quite limited, but other people are able to fork and collaborate easily in the same environment. (Disclaimer, I'm a sysadmin at Canonical, so I have corporate ties to both bzr and launchpad). Cheers, -- Chris Jones cm...@te... www.tenshu.net |