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: Cornell W. <co...@la...> - 2012-09-07 14:05:34
|
I've been starting to use ConfigObj4 and validate, it's a nice package.
I think there is an error in the get_extra_values example in configobj.html.
# this code gets the extra values themselves
the_section = cfg
for section in sections:
the_section = cfg[section]
The last line should be:
the_section=the_section[section]
Without that change, I get a key error on an extra value in a section
nested two deep.
--
Cornell Wright
HPC-5 - High Performance System Integration
Los Alamos National Laboratory
505-665-3109 - Office
505-664-4084 - Pager (during work hours)
505-695-4904 - Mobile (outside of work hours)
co...@la... - eMail
|
|
From: Michael F. <fuz...@vo...> - 2012-08-19 19:16:04
|
On 19 Aug 2012, at 12:37, Patrick Totzke <pat...@gm...> wrote: > Hi! > > I'm not sure if it makes much sense to report this here as the list seems more or less dead.. Pretty much. :-) I'm not using ConfigObj myself these days, so development has stalled. The *best* place to report an issue is on the bug tracker, so that it doesn't get lost: http://code.google.com/p/configobj/issues/list > Anyhow, I ran into something nasty with configobj/validate. I think the subject says it all: > > If your configspec says > > foo = string(default=None) > > and your config reads > > foo = bar, baz > > validation using cfg.validate(Validator()) does not fail and afterwards cfg.foo > foes not contain "bar, baz" but ["bar", "baz"]. > Apparently one can force lists using > > foo = force_list > > in the spec, bot one cannot force *not* list, which from my perspective would be > the logical behaviour of spec "string". So parsing into lists is done by ConfigObj before a value is sent for validating. The "right" thing to do is to escape the comma with quotes: > > and your config reads > foo = "bar, bar" Having said that, if your spec specifies a string then a list should *fail validation*. You could write a custom validator yourself that will force non-list values. All the best, Michael Foord > cheers, > /p > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html |
|
From: Patrick T. <pat...@gm...> - 2012-08-19 11:37:56
|
Hi! I'm not sure if it makes much sense to report this here as the list seems more or less dead.. Anyhow, I ran into something nasty with configobj/validate. I think the subject says it all: If your configspec says foo = string(default=None) and your config reads foo = bar, baz validation using cfg.validate(Validator()) does not fail and afterwards cfg.foo foes not contain "bar, baz" but ["bar", "baz"]. Apparently one can force lists using foo = force_list in the spec, bot one cannot force *not* list, which from my perspective would be the logical behaviour of spec "string". cheers, /p |
|
From: Steven W. O. <st...@sy...> - 2012-07-31 17:31:00
|
On 7/31/2012 7:04 AM, Roman Schroeder wrote: > Hi, > > I found this topic "http://code.google.com/p/configobj/issues/detail?id=18" > very interesting! > > Any ideas how I can let the interpolation engine know about the whole > configObj object? I don't know if this will help you, but I have a .conf file that has this snippet in it: [SlaveSystems] bl_lab = '.lab.ma.emulex.com' [[ShortMachNames]] cortes = 'cortes%(bl_lab)s' boone = 'boone%(bl_lab)s' dizzy = 'dizzy%(bl_lab)s' henry = 'henry%(bl_lab)s' Does this help? -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net |
|
From: Roman S. <sch...@go...> - 2012-07-31 11:05:09
|
Hi, I found this topic "http://code.google.com/p/configobj/issues/detail?id=18" very interesting! Any ideas how I can let the interpolation engine know about the whole configObj object? -- best regards, - Roman Schroeder - |
|
From: Jacob B. <jak...@gm...> - 2012-07-03 15:38:40
|
Hi! I've just opened up a StackOverflow question about ConfigObj. http://stackoverflow.com/questions/11314068/why-doesnt-kwargs-interpolate-with-python-configobj I'm using ConfigObj <http://www.voidspace.org.uk/python/configobj.html> in python with Template-style interpolation. Unwrapping my config dictionary via ** doesn't seem to do interpolation. Is this a feature or a bug? Any nice workarounds? $ cat my.conf foo = /test bar = $foo/directory >>> import configobj >>> config = configobj.ConfigObj('my.conf', interpolation='Template') >>> config['bar'] '/test/directory' >>> '{bar}'.format(**config) '$foo/directory' I'd expect the second line to be /test/directory. Why doesn't interpolation work with **kwargs? Thanks for any help you can offer! -- Jake Biesinger |
|
From: Lars L. <la...@mo...> - 2012-04-27 00:13:11
|
Does ConfigObj support C style includes in an ini file? I can't see documentation for such a feature, but I thought I'd ask anyway. Here's more about what I'm looking for: Consider this sample ini: [source] dbhostname=myserver dbname=some-database dbuser=dwight dbpassword=secrets [destination] dbhostname=myserver dbname=some-database dbuser=dwight dbpassword=secrets I'd like a syntax that allows me to not repeat myself if I don't need to: [source] +include /some/path/database-credentials.ini [destination] +include /some/path/database-credentials.ini other users that may want different database/user credentials can write their ini file like my first example. On the other hand, my version can look like the latter because I don't need separate credentials. Or, perhaps there's another way to accomplish the same thing using a different technique? Any help would be appreciated. -K Lars Lohn Mozilla WebTools |
|
From: Michael F. <fuz...@vo...> - 2012-04-01 22:43:38
|
On 31 Mar 2012, at 19:00, Faheem Mitha wrote:
>
> Hi
>
> I'm trying to use configobj's validate module to validate and convert
> a list of lists of integers.
>
> However, it is not working. The value is
>
> model = [[5, 6], [7, 13, 18], [9, 22], [10, 12], [15, 16, 17], [20, 21]]
>
> I call the validation like
>
> model = check_list_of_list_of_integers
>
> Here is the check function and the error below.
>
> #####################################################################
>
> def list_of_list_of_integers(value):
> print "value", value
> print "type(value)", type(value)
> l = eval(value)
> try:
> list(l)
> except:
> raise "error"
> return l
>
> fdict = {'check_list_of_list_of_integers': list_of_list_of_integers}
> validator = validate.Validator(fdict)
>
> ######################################################################
>
> I'm calling 'eval' on the value, which might not be the best idea, but
> should work if the value is a string. However, the value is converted
> to a list of strings on entrance to the "list_of_list_of_integers"
> function, even though I have not asked for it to be so converted.
>
> Any idea what is going on and how I can fix this?
>
> Please CC me on any reply. Thanks.
>
> Regards, Faheem Mitha
>
>
> value ['[[5', '6]', '[7', '13', '18]', '[9', '22]', '[10', '12]', '[15',
> '16', '17]', '[20', '21]]']
> type(value) <type 'list'>
> Traceback (most recent call last):
> File "load_crossval.py", line 29, in <module>
> conf = get_conf()
> File "/home/faheem/corrmodel/utils.py", line 70, in get_conf
> results = config.validate(validator, preserve_errors=True)
> File "/usr/lib/pymodules/python2.6/configobj.py", line 2295, in validate
> check = self.validate(validator, preserve_errors=preserve_errors,
> copy=copy, section=section[entry])
> File "/usr/lib/pymodules/python2.6/configobj.py", line 2251, in validate
> missing, ret_true, ret_false)
> File "/usr/lib/pymodules/python2.6/configobj.py", line 2190, in
> validate_entry
> missing=missing
> File "/usr/lib/pymodules/python2.6/validate.py", line 597, in check
> return self._check_value(value, fun_name, fun_args, fun_kwargs)
> File "/usr/lib/pymodules/python2.6/validate.py", line 629, in
> _check_value
> return fun(value, *fun_args, **fun_kwargs)
> File "/home/faheem/corrmodel/utils.py", line 46, in
> list_of_list_of_integers
> l = eval(value)
> TypeError: eval() arg 1 must be a string or code object
>
Yep, validate gets passed lists already separated. For lists of lists you need to effectively eval each list. However there are risks with eval that have already been explained. One solution, possible on Python 2.6 and more recent I believe, is use ast.literal_eval which works the same as eval for the basic types without code injection risks.
All the best,
Michael Foord
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.voidspace.org.uk/
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing
http://www.sqlite.org/different.html
|
|
From: Patrick T. <pat...@go...> - 2012-04-01 10:43:21
|
Quoting Faheem Mitha (2012-03-31 22:04:45)
>> Typically you'd grep for file removals and so on, or run it in a chroot or something
>> similar but I don't thing you should go that road and try to replace eval.
>
>Not sure what you are saying here. Do you think I should replace eval, or
>should not replace eval?
Sorry, ambiguous use of natural language :)
I think you should not use eval.
>> You could try using a different separator, say a semicolon for inner lists and a dot for
>> outer lists. If you don't have a problem to compromise your syntax like this you can use:
>>
>> value = 1.2;3.4.5
>> [inner.split('.') for inner in value.split(';')]
>
>Interesting suggestion, thanks.
It's ugly, I know. Let's hope the validate interface gets refined here.
best,
/p
|
|
From: Faheem M. <fa...@fa...> - 2012-03-31 21:04:56
|
On Sat, 31 Mar 2012, Patrick Totzke wrote:
> Typically you'd grep for file removals and so on, or run it in a chroot or something
> similar but I don't thing you should go that road and try to replace eval.
Not sure what you are saying here. Do you think I should replace eval, or
should not replace eval?
> You could try using a different separator, say a semicolon for inner lists and a dot for
> outer lists. If you don't have a problem to compromise your syntax like this you can use:
>
> value = 1.2;3.4.5
> [inner.split('.') for inner in value.split(';')]
Interesting suggestion, thanks.
Regards, Faheem
|
|
From: Patrick T. <pat...@go...> - 2012-03-31 20:40:16
|
Quoting Faheem Mitha (2012-03-31 20:42:06)
>I'm trying to convert the value to a list of integer lists, as it appears
>to be in the config file. I don't think "eval" is a good way to go either,
>but can you suggest an alternative?
>> Also note that using eval like this makes your app vulnerable to code
>> injection because you don't sanitize the string you hand over.
>
>Yes, I see. Since 'eval' can execute arbitary code. I'm open to
>alternative methods to convert this string into a list of lists. Also, how
>could one sanitize the call to 'eval'?
Typically you'd grep for file removals and so on, or run it in a chroot or something
similar but I don't thing you should go that road and try to replace eval.
>> Quoting Faheem Mitha (2012-03-31 19:00:42)
>Yes, I would have expected it to just pass the value as a string, but it
>seems to be altering it to a list first. Since I give it my check
>function, I would expect it to use that instead of whatever default
>internal conversion it does.
I would also expect this and hope configobj will be changed in that respect.
At least the current behaviour should either be documented better as the relevant part
of the doc is rather confusing:
All parameters and keyword arguments are always passed as strings. (Parsed from the check string).
The value might be a string (or list of strings) and need converting to the right type - alternatively it might
already be a list of integers. Our function needs to be able to handle either.
You could try using a different separator, say a semicolon for inner lists and a dot for
outer lists. If you don't have a problem to compromise your syntax like this you can use:
value = 1.2;3.4.5
[inner.split('.') for inner in value.split(';')]
best,
/p
|
|
From: Faheem M. <fa...@fa...> - 2012-03-31 19:42:17
|
Hi Patrick,
Thanks for the helpful reply.
On Sat, 31 Mar 2012, Patrick Totzke wrote:
> Hi Faheem,
>
> Not sure to what you are trying to convert these values but eval
> is not what you want I believe.
I'm trying to convert the value to a list of integer lists, as it appears
to be in the config file. I don't think "eval" is a good way to go either,
but can you suggest an alternative?
> Also note that using eval like this makes your app vulnerable to code
> injection because you don't sanitize the string you hand over.
Yes, I see. Since 'eval' can execute arbitary code. I'm open to
alternative methods to convert this string into a list of lists. Also, how
could one sanitize the call to 'eval'?
> Quoting Faheem Mitha (2012-03-31 19:00:42)
>> value ['[[5', '6]', '[7', '13', '18]', '[9', '22]', '[10', '12]', '[15',
>> '16', '17]', '[20', '21]]']
>> type(value) <type 'list'>
> ...
>
>> l = eval(value)
>> TypeError: eval() arg 1 must be a string or code object
>
>
> Here is your problem: You hand an object of type "list" to a function that
> doesn't arguments of that kind.
Right. Clearly eval can't operate after the value
model = [[5, 6], [7, 13, 18], [9, 22], [10, 12], [15, 16, 17], [20, 21]]
has been altered from what one would expect it to be, namely a string.
> eval's docstring sais:
>
> eval(source[, globals[, locals]]) -> value
>
> Evaluate the source in the context of globals and locals.
> The source may be a string representing a Python expression
> or a code object as returned by compile().
> The globals must be a dictionary and locals can be any mapping,
> defaulting to the current globals and locals.
> If only globals is given, locals defaults to it.
>
> I think one option would be to quote your values in the config,
> so you'd explicitly get a string and not a stringlist.
> I'm not so firm with the configobj internals but it seems that
> it is interpreting this stringlist before alling your test.
Yes, I would have expected it to just pass the value as a string, but it
seems to be altering it to a list first. Since I give it my check
function, I would expect it to use that instead of whatever default
internal conversion it does.
Regards, Faheem
|
|
From: Patrick T. <pat...@go...> - 2012-03-31 19:11:01
|
Hi Faheem,
Not sure to what you are trying to convert these values but eval
is not what you want I believe. Also note that
using eval like this makes your app vulnerable to code injection
because you don't sanitize the string you hand over.
Quoting Faheem Mitha (2012-03-31 19:00:42)
>value ['[[5', '6]', '[7', '13', '18]', '[9', '22]', '[10', '12]', '[15',
>'16', '17]', '[20', '21]]']
>type(value) <type 'list'>
...
> l = eval(value)
>TypeError: eval() arg 1 must be a string or code object
Here is your problem: You hand an object of type "list" to a function that
doesn't arguments of that kind.
eval's docstring sais:
eval(source[, globals[, locals]]) -> value
Evaluate the source in the context of globals and locals.
The source may be a string representing a Python expression
or a code object as returned by compile().
The globals must be a dictionary and locals can be any mapping,
defaulting to the current globals and locals.
If only globals is given, locals defaults to it.
I think one option would be to quote your values in the config,
so you'd explicitly get a string and not a stringlist.
I'm not so firm with the configobj internals but it seems that
it is interpreting this stringlist before alling your test.
HTH,
/p
|
|
From: Faheem M. <fa...@fa...> - 2012-03-31 18:18:51
|
Hi
I'm trying to use configobj's validate module to validate and convert
a list of lists of integers.
However, it is not working. The value is
model = [[5, 6], [7, 13, 18], [9, 22], [10, 12], [15, 16, 17], [20, 21]]
I call the validation like
model = check_list_of_list_of_integers
Here is the check function and the error below.
#####################################################################
def list_of_list_of_integers(value):
print "value", value
print "type(value)", type(value)
l = eval(value)
try:
list(l)
except:
raise "error"
return l
fdict = {'check_list_of_list_of_integers': list_of_list_of_integers}
validator = validate.Validator(fdict)
######################################################################
I'm calling 'eval' on the value, which might not be the best idea, but
should work if the value is a string. However, the value is converted
to a list of strings on entrance to the "list_of_list_of_integers"
function, even though I have not asked for it to be so converted.
Any idea what is going on and how I can fix this?
Please CC me on any reply. Thanks.
Regards, Faheem Mitha
value ['[[5', '6]', '[7', '13', '18]', '[9', '22]', '[10', '12]', '[15',
'16', '17]', '[20', '21]]']
type(value) <type 'list'>
Traceback (most recent call last):
File "load_crossval.py", line 29, in <module>
conf = get_conf()
File "/home/faheem/corrmodel/utils.py", line 70, in get_conf
results = config.validate(validator, preserve_errors=True)
File "/usr/lib/pymodules/python2.6/configobj.py", line 2295, in validate
check = self.validate(validator, preserve_errors=preserve_errors,
copy=copy, section=section[entry])
File "/usr/lib/pymodules/python2.6/configobj.py", line 2251, in validate
missing, ret_true, ret_false)
File "/usr/lib/pymodules/python2.6/configobj.py", line 2190, in
validate_entry
missing=missing
File "/usr/lib/pymodules/python2.6/validate.py", line 597, in check
return self._check_value(value, fun_name, fun_args, fun_kwargs)
File "/usr/lib/pymodules/python2.6/validate.py", line 629, in
_check_value
return fun(value, *fun_args, **fun_kwargs)
File "/home/faheem/corrmodel/utils.py", line 46, in
list_of_list_of_integers
l = eval(value)
TypeError: eval() arg 1 must be a string or code object
|
|
From: Michael F. <fuz...@vo...> - 2011-11-22 22:50:04
|
On 22/11/2011 21:02, Arash Azarmi wrote: > Thanks for clarification.It could be nice if it had that feature. Do > you have any suggestions ? > Not really, sorry. Because of the ConfigObj syntax it's not possible for the order *between* sections and scalars to be preserved. You'll have to wrap ConfigObj and store the information yourself as an extra entry I think. All the best, Michael > Best , > Arash. > > On Tue, Nov 22, 2011 at 3:08 AM, Michael Foord > <fuz...@vo... <mailto:fuz...@vo...>> wrote: > > On 22/11/2011 06:26, Arash Azarmi wrote: >> Yes but it only preserves the order for scalars(or sections) >> .Cant keep both at same. >> >> If you insert scalar *a* within section *A* ,then insert section >> *B *in section A , and then insert scalar *b , *and then >> section*C *the order I like to see is*: a , B , b ,C* >> But with scalars you get*a,b , * >> and with sections you get*B,C .* >> * >> * >> Is there away you get both ? >> > > That can't work with configobj. Think about this example: > > c = ConfigObj() > c['one'] = 'one' > c['section'] = {} > c['two'] = 'two' > > When ConfigObj writes out the file it does this: > > >>> for line in c.write(): > ... print line > ... > one = one > two = two > [section] > > You seem to want it to do this: > one = one > [section] > two = two > > The problem is that the key 'two' is now *inside* 'section' - it's > in the wrong place and when reading the file back in it would do > the wrong thing. Scalars *have* to be written out before sections. > > All the best, > > Michael > >> Thanks , >> Arash. >> >> On Mon, Nov 21, 2011 at 8:40 PM, L. Canessa <l.c...@gm... >> <mailto:l.c...@gm...>> wrote: >> >> Did you read the documentation? >> >> It's supposed to be: >> >> *for i in config['procedure'].scalars* >> * >> * >> If I recall correctly. >> >> -Leonardo >> >> >> >> On Mon, Nov 21, 2011 at 8:56 PM, Arash Azarmi >> <aza...@gm... <mailto:aza...@gm...>> wrote: >> >> As far as I try , it does not preserve , here is a sample >> code : >> >> *config = configobj.ConfigObj()* >> *config.filename = "file.name <http://file.name>"* >> *procedure={}* >> *loop={'sweep':[],'contents':OrderedDict()}* >> *config['procedure']=procedure* >> *config['procedure']['var_1']=1* >> *config['procedure']['var_2']=1* >> *config['procedure']['loop.1']=loop* >> *config['procedure']['var_3']=1* >> *config.write()* >> * >> * >> *for i in config['procedure'] :* >> * print i,'=',str(config['procedure'][i])* >> * if i.find('loop')==0:* >> * for j in config['procedure'][i]:* >> * print j,'=',str(config['procedure'][i])* >> * >> * >> Output is : >> * >> * >> * >> var_1 = 1 >> var_2 = 1 >> _var_3 = 1 <--------- This is out of order.It should be >> printed last of all._ >> loop.1 = {'sweep': [], 'contents': {}} >> sweep = {'sweep': [], 'contents': {}} >> contents = {'sweep': [], 'contents': {}} >> * >> >> On Mon, Nov 21, 2011 at 1:29 PM, Michael Foord >> <fuz...@vo... >> <mailto:fuz...@vo...>> wrote: >> >> On 21/11/2011 21:09, Arash Azarmi wrote: >>> Hi all , >>> I am using configObj to store inputs from user.In my >>> case, the sequence matters so I can't let the >>> configObj don't store sequence order.Both Section >>> and ConfigObj are implemented as ordinary dictionary >>> {} . I tried to change that to OrderedDict (from >>> collections) but apparently it's not working >>> again.Has anybody a solution for this ? >>> >> >> ConfigObj does store (and preserve when reading / >> writing) order. >> >> See the documentation on the "sections" and "scalars" >> attributes of sections: >> >> http://www.voidspace.org.uk/python/configobj.html#section-attributes >> >> These attributes are normal lists, representing the >> order that members, single values and subsections >> appear in the section. The order will either be the >> order of the original config file, or the order that >> you added members. >> >> The order of members in this lists is the order that >> write creates in the config file. The scalars list is >> output before the sections list. >> >> Adding or removing members also alters these lists. >> You can manipulate the lists directly to alter the >> order of members. >> >> All the best, >> >> Michael Foord >> >> >>> Thanks , >>> Arash. >>> >>> >>> ------------------------------------------------------------------------------ >>> All the data continuously generated in your IT infrastructure >>> contains a definitive record of customers, application performance, >>> security threats, fraudulent activity, and more. Splunk takes this >>> data and makes sense of it. IT sense. And common sense. >>> http://p.sf.net/sfu/splunk-novd2d >>> >>> >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... <mailto:Con...@li...> >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> >> -- >> http://www.voidspace.org.uk/ >> >> May you do good and not evil >> May you find forgiveness for yourself and forgive others >> May you share freely, never taking more than you give. >> -- the sqlite blessinghttp://www.sqlite.org/different.html >> >> >> >> ------------------------------------------------------------------------------ >> All the data continuously generated in your IT infrastructure >> contains a definitive record of customers, application >> performance, >> security threats, fraudulent activity, and more. Splunk >> takes this >> data and makes sense of it. IT sense. And common sense. >> http://p.sf.net/sfu/splunk-novd2d >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> <mailto:Con...@li...> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> >> ------------------------------------------------------------------------------ >> All the data continuously generated in your IT infrastructure >> contains a definitive record of customers, application >> performance, >> security threats, fraudulent activity, and more. Splunk takes >> this >> data and makes sense of it. IT sense. And common sense. >> http://p.sf.net/sfu/splunk-novd2d >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> <mailto:Con...@li...> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> >> >> >> ------------------------------------------------------------------------------ >> All the data continuously generated in your IT infrastructure >> contains a definitive record of customers, application performance, >> security threats, fraudulent activity, and more. Splunk takes this >> data and makes sense of it. IT sense. And common sense. >> http://p.sf.net/sfu/splunk-novd2d >> >> >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... <mailto:Con...@li...> >> https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > -- > http://www.voidspace.org.uk/ > > May you do good and not evil > May you find forgiveness for yourself and forgive others > May you share freely, never taking more than you give. > -- the sqlite blessinghttp://www.sqlite.org/different.html > > > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html |
|
From: Arash A. <aza...@gm...> - 2011-11-22 21:02:39
|
Thanks for clarification.It could be nice if it had that feature. Do you have any suggestions ? Best , Arash. On Tue, Nov 22, 2011 at 3:08 AM, Michael Foord <fuz...@vo...>wrote: > On 22/11/2011 06:26, Arash Azarmi wrote: > > Yes but it only preserves the order for scalars(or sections) .Cant keep > both at same. > > If you insert scalar *a* within section *A* ,then insert section *B *in > section A , and then insert scalar *b , *and then section* C *the order I > like to see is* : a , B , b ,C* > But with scalars you get* a,b , * > and with sections you get* B,C .* > * > * > Is there away you get both ? > > > That can't work with configobj. Think about this example: > > c = ConfigObj() > c['one'] = 'one' > c['section'] = {} > c['two'] = 'two' > > When ConfigObj writes out the file it does this: > > >>> for line in c.write(): > ... print line > ... > one = one > two = two > [section] > > You seem to want it to do this: > one = one > [section] > two = two > > The problem is that the key 'two' is now *inside* 'section' - it's in the > wrong place and when reading the file back in it would do the wrong thing. > Scalars *have* to be written out before sections. > > All the best, > > Michael > > Thanks , > Arash. > > On Mon, Nov 21, 2011 at 8:40 PM, L. Canessa <l.c...@gm...> wrote: > >> Did you read the documentation? >> >> It's supposed to be: >> >> *for i in config['procedure'].scalars* >> * >> * >> If I recall correctly. >> >> -Leonardo >> >> >> >> On Mon, Nov 21, 2011 at 8:56 PM, Arash Azarmi <aza...@gm...>wrote: >> >>> As far as I try , it does not preserve , here is a sample code : >>> >>> *config = configobj.ConfigObj()* >>> *config.filename = "file.name"* >>> *procedure={}* >>> *loop={'sweep':[],'contents':OrderedDict()}* >>> *config['procedure']=procedure* >>> *config['procedure']['var_1']=1* >>> *config['procedure']['var_2']=1* >>> *config['procedure']['loop.1']=loop* >>> *config['procedure']['var_3']=1* >>> *config.write()* >>> * >>> * >>> *for i in config['procedure'] :* >>> * print i,'=',str(config['procedure'][i])* >>> * if i.find('loop')==0:* >>> * for j in config['procedure'][i]:* >>> * print j,'=',str(config['procedure'][i])* >>> * >>> * >>> Output is : >>> * >>> * >>> * >>> var_1 = 1 >>> var_2 = 1 >>> var_3 = 1 <--------- This is out of order.It should be printed last of >>> all. >>> loop.1 = {'sweep': [], 'contents': {}} >>> sweep = {'sweep': [], 'contents': {}} >>> contents = {'sweep': [], 'contents': {}} >>> * >>> >>> On Mon, Nov 21, 2011 at 1:29 PM, Michael Foord < >>> fuz...@vo...> wrote: >>> >>>> On 21/11/2011 21:09, Arash Azarmi wrote: >>>> >>>> Hi all , >>>> I am using configObj to store inputs from user.In my case, the sequence >>>> matters so I can't let the configObj don't store sequence order.Both >>>> Section and ConfigObj are implemented as ordinary dictionary {} . I tried >>>> to change that to OrderedDict (from collections) but apparently it's not >>>> working again.Has anybody a solution for this ? >>>> >>>> >>>> ConfigObj does store (and preserve when reading / writing) order. >>>> >>>> See the documentation on the "sections" and "scalars" attributes of >>>> sections: >>>> >>>> >>>> http://www.voidspace.org.uk/python/configobj.html#section-attributes >>>> >>>> These attributes are normal lists, representing the order that members, >>>> single values and subsections appear in the section. The order will either >>>> be the order of the original config file, or the order that you added >>>> members. >>>> >>>> The order of members in this lists is the order that write creates in >>>> the config file. The scalars list is output before the sections list. >>>> >>>> Adding or removing members also alters these lists. You can manipulate >>>> the lists directly to alter the order of members. >>>> >>>> All the best, >>>> >>>> Michael Foord >>>> >>>> >>>> Thanks , >>>> Arash. >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> All the data continuously generated in your IT infrastructure >>>> contains a definitive record of customers, application performance, >>>> security threats, fraudulent activity, and more. Splunk takes this >>>> data and makes sense of it. IT sense. And common sense.http://p.sf.net/sfu/splunk-novd2d >>>> >>>> >>>> >>>> _______________________________________________ >>>> Configobj-develop mailing lis...@li...://lists.sourceforge.net/lists/listinfo/configobj-develop >>>> >>>> >>>> >>>> -- http://www.voidspace.org.uk/ >>>> >>>> May you do good and not evil >>>> May you find forgiveness for yourself and forgive others >>>> May you share freely, never taking more than you give. >>>> -- the sqlite blessing http://www.sqlite.org/different.html >>>> >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> All the data continuously generated in your IT infrastructure >>> contains a definitive record of customers, application performance, >>> security threats, fraudulent activity, and more. Splunk takes this >>> data and makes sense of it. IT sense. And common sense. >>> http://p.sf.net/sfu/splunk-novd2d >>> _______________________________________________ >>> Configobj-develop mailing list >>> Con...@li... >>> https://lists.sourceforge.net/lists/listinfo/configobj-develop >>> >>> >> >> ------------------------------------------------------------------------------ >> All the data continuously generated in your IT infrastructure >> contains a definitive record of customers, application performance, >> security threats, fraudulent activity, and more. Splunk takes this >> data and makes sense of it. IT sense. And common sense. >> http://p.sf.net/sfu/splunk-novd2d >> _______________________________________________ >> Configobj-develop mailing list >> Con...@li... >> https://lists.sourceforge.net/lists/listinfo/configobj-develop >> >> > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense.http://p.sf.net/sfu/splunk-novd2d > > > > _______________________________________________ > Configobj-develop mailing lis...@li...://lists.sourceforge.net/lists/listinfo/configobj-develop > > > > -- http://www.voidspace.org.uk/ > > May you do good and not evil > May you find forgiveness for yourself and forgive others > May you share freely, never taking more than you give. > -- the sqlite blessing http://www.sqlite.org/different.html > > |
|
From: Michael F. <fuz...@vo...> - 2011-11-22 11:08:21
|
On 22/11/2011 06:26, Arash Azarmi wrote:
> Yes but it only preserves the order for scalars(or sections) .Cant
> keep both at same.
>
> If you insert scalar *a* within section *A* ,then insert section *B
> *in section A , and then insert scalar *b , *and then section*C *the
> order I like to see is*: a , B , b ,C*
> But with scalars you get*a,b , *
> and with sections you get*B,C .*
> *
> *
> Is there away you get both ?
>
That can't work with configobj. Think about this example:
c = ConfigObj()
c['one'] = 'one'
c['section'] = {}
c['two'] = 'two'
When ConfigObj writes out the file it does this:
>>> for line in c.write():
... print line
...
one = one
two = two
[section]
You seem to want it to do this:
one = one
[section]
two = two
The problem is that the key 'two' is now *inside* 'section' - it's in
the wrong place and when reading the file back in it would do the wrong
thing. Scalars *have* to be written out before sections.
All the best,
Michael
> Thanks ,
> Arash.
>
> On Mon, Nov 21, 2011 at 8:40 PM, L. Canessa <l.c...@gm...
> <mailto:l.c...@gm...>> wrote:
>
> Did you read the documentation?
>
> It's supposed to be:
>
> *for i in config['procedure'].scalars*
> *
> *
> If I recall correctly.
>
> -Leonardo
>
>
>
> On Mon, Nov 21, 2011 at 8:56 PM, Arash Azarmi <aza...@gm...
> <mailto:aza...@gm...>> wrote:
>
> As far as I try , it does not preserve , here is a sample code :
>
> *config = configobj.ConfigObj()*
> *config.filename = "file.name <http://file.name>"*
> *procedure={}*
> *loop={'sweep':[],'contents':OrderedDict()}*
> *config['procedure']=procedure*
> *config['procedure']['var_1']=1*
> *config['procedure']['var_2']=1*
> *config['procedure']['loop.1']=loop*
> *config['procedure']['var_3']=1*
> *config.write()*
> *
> *
> *for i in config['procedure'] :*
> * print i,'=',str(config['procedure'][i])*
> * if i.find('loop')==0:*
> * for j in config['procedure'][i]:*
> * print j,'=',str(config['procedure'][i])*
> *
> *
> Output is :
> *
> *
> *
> var_1 = 1
> var_2 = 1
> _var_3 = 1 <--------- This is out of order.It should be
> printed last of all._
> loop.1 = {'sweep': [], 'contents': {}}
> sweep = {'sweep': [], 'contents': {}}
> contents = {'sweep': [], 'contents': {}}
> *
>
> On Mon, Nov 21, 2011 at 1:29 PM, Michael Foord
> <fuz...@vo... <mailto:fuz...@vo...>>
> wrote:
>
> On 21/11/2011 21:09, Arash Azarmi wrote:
>> Hi all ,
>> I am using configObj to store inputs from user.In my
>> case, the sequence matters so I can't let the configObj
>> don't store sequence order.Both Section and ConfigObj are
>> implemented as ordinary dictionary {} . I tried to change
>> that to OrderedDict (from collections) but apparently
>> it's not working again.Has anybody a solution for this ?
>>
>
> ConfigObj does store (and preserve when reading / writing)
> order.
>
> See the documentation on the "sections" and "scalars"
> attributes of sections:
>
> http://www.voidspace.org.uk/python/configobj.html#section-attributes
>
> These attributes are normal lists, representing the order
> that members, single values and subsections appear in the
> section. The order will either be the order of the
> original config file, or the order that you added members.
>
> The order of members in this lists is the order that write
> creates in the config file. The scalars list is output
> before the sections list.
>
> Adding or removing members also alters these lists. You
> can manipulate the lists directly to alter the order of
> members.
>
> All the best,
>
> Michael Foord
>
>
>> Thanks ,
>> Arash.
>>
>>
>> ------------------------------------------------------------------------------
>> All the data continuously generated in your IT infrastructure
>> contains a definitive record of customers, application performance,
>> security threats, fraudulent activity, and more. Splunk takes this
>> data and makes sense of it. IT sense. And common sense.
>> http://p.sf.net/sfu/splunk-novd2d
>>
>>
>> _______________________________________________
>> Configobj-develop mailing list
>> Con...@li... <mailto:Con...@li...>
>> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
> --
> http://www.voidspace.org.uk/
>
> May you do good and not evil
> May you find forgiveness for yourself and forgive others
> May you share freely, never taking more than you give.
> -- the sqlite blessinghttp://www.sqlite.org/different.html
>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application
> performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> <mailto:Con...@li...>
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> <mailto:Con...@li...>
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
>
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
--
http://www.voidspace.org.uk/
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
|
|
From: Arash A. <aza...@gm...> - 2011-11-22 06:26:42
|
Yes but it only preserves the order for scalars(or sections) .Cant keep
both at same.
If you insert scalar *a* within section *A* ,then insert section *B *in
section A , and then insert scalar *b , *and then section* C *the order I
like to see is* : a , B , b ,C*
But with scalars you get* a,b , *
and with sections you get* B,C .*
*
*
Is there away you get both ?
Thanks ,
Arash.
On Mon, Nov 21, 2011 at 8:40 PM, L. Canessa <l.c...@gm...> wrote:
> Did you read the documentation?
>
> It's supposed to be:
>
> *for i in config['procedure'].scalars*
> *
> *
> If I recall correctly.
>
> -Leonardo
>
>
>
> On Mon, Nov 21, 2011 at 8:56 PM, Arash Azarmi <aza...@gm...> wrote:
>
>> As far as I try , it does not preserve , here is a sample code :
>>
>> *config = configobj.ConfigObj()*
>> *config.filename = "file.name"*
>> *procedure={}*
>> *loop={'sweep':[],'contents':OrderedDict()}*
>> *config['procedure']=procedure*
>> *config['procedure']['var_1']=1*
>> *config['procedure']['var_2']=1*
>> *config['procedure']['loop.1']=loop*
>> *config['procedure']['var_3']=1*
>> *config.write()*
>> *
>> *
>> *for i in config['procedure'] :*
>> * print i,'=',str(config['procedure'][i])*
>> * if i.find('loop')==0:*
>> * for j in config['procedure'][i]:*
>> * print j,'=',str(config['procedure'][i])*
>> *
>> *
>> Output is :
>> *
>> *
>> *
>> var_1 = 1
>> var_2 = 1
>> var_3 = 1 <--------- This is out of order.It should be printed last of
>> all.
>> loop.1 = {'sweep': [], 'contents': {}}
>> sweep = {'sweep': [], 'contents': {}}
>> contents = {'sweep': [], 'contents': {}}
>> *
>>
>> On Mon, Nov 21, 2011 at 1:29 PM, Michael Foord <fuz...@vo...
>> > wrote:
>>
>>> On 21/11/2011 21:09, Arash Azarmi wrote:
>>>
>>> Hi all ,
>>> I am using configObj to store inputs from user.In my case, the sequence
>>> matters so I can't let the configObj don't store sequence order.Both
>>> Section and ConfigObj are implemented as ordinary dictionary {} . I tried
>>> to change that to OrderedDict (from collections) but apparently it's not
>>> working again.Has anybody a solution for this ?
>>>
>>>
>>> ConfigObj does store (and preserve when reading / writing) order.
>>>
>>> See the documentation on the "sections" and "scalars" attributes of
>>> sections:
>>>
>>> http://www.voidspace.org.uk/python/configobj.html#section-attributes
>>>
>>> These attributes are normal lists, representing the order that members,
>>> single values and subsections appear in the section. The order will either
>>> be the order of the original config file, or the order that you added
>>> members.
>>>
>>> The order of members in this lists is the order that write creates in
>>> the config file. The scalars list is output before the sections list.
>>>
>>> Adding or removing members also alters these lists. You can manipulate
>>> the lists directly to alter the order of members.
>>>
>>> All the best,
>>>
>>> Michael Foord
>>>
>>>
>>> Thanks ,
>>> Arash.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> All the data continuously generated in your IT infrastructure
>>> contains a definitive record of customers, application performance,
>>> security threats, fraudulent activity, and more. Splunk takes this
>>> data and makes sense of it. IT sense. And common sense.http://p.sf.net/sfu/splunk-novd2d
>>>
>>>
>>>
>>> _______________________________________________
>>> Configobj-develop mailing lis...@li...://lists.sourceforge.net/lists/listinfo/configobj-develop
>>>
>>>
>>>
>>> -- http://www.voidspace.org.uk/
>>>
>>> May you do good and not evil
>>> May you find forgiveness for yourself and forgive others
>>> May you share freely, never taking more than you give.
>>> -- the sqlite blessing http://www.sqlite.org/different.html
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> All the data continuously generated in your IT infrastructure
>> contains a definitive record of customers, application performance,
>> security threats, fraudulent activity, and more. Splunk takes this
>> data and makes sense of it. IT sense. And common sense.
>> http://p.sf.net/sfu/splunk-novd2d
>> _______________________________________________
>> Configobj-develop mailing list
>> Con...@li...
>> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>>
>>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
|
|
From: L. C. <l.c...@gm...> - 2011-11-22 04:40:14
|
Did you read the documentation?
It's supposed to be:
*for i in config['procedure'].scalars*
*
*
If I recall correctly.
-Leonardo
On Mon, Nov 21, 2011 at 8:56 PM, Arash Azarmi <aza...@gm...> wrote:
> As far as I try , it does not preserve , here is a sample code :
>
> *config = configobj.ConfigObj()*
> *config.filename = "file.name"*
> *procedure={}*
> *loop={'sweep':[],'contents':OrderedDict()}*
> *config['procedure']=procedure*
> *config['procedure']['var_1']=1*
> *config['procedure']['var_2']=1*
> *config['procedure']['loop.1']=loop*
> *config['procedure']['var_3']=1*
> *config.write()*
> *
> *
> *for i in config['procedure'] :*
> * print i,'=',str(config['procedure'][i])*
> * if i.find('loop')==0:*
> * for j in config['procedure'][i]:*
> * print j,'=',str(config['procedure'][i])*
> *
> *
> Output is :
> *
> *
> *
> var_1 = 1
> var_2 = 1
> var_3 = 1 <--------- This is out of order.It should be printed last of
> all.
> loop.1 = {'sweep': [], 'contents': {}}
> sweep = {'sweep': [], 'contents': {}}
> contents = {'sweep': [], 'contents': {}}
> *
>
> On Mon, Nov 21, 2011 at 1:29 PM, Michael Foord <fuz...@vo...>wrote:
>
>> On 21/11/2011 21:09, Arash Azarmi wrote:
>>
>> Hi all ,
>> I am using configObj to store inputs from user.In my case, the sequence
>> matters so I can't let the configObj don't store sequence order.Both
>> Section and ConfigObj are implemented as ordinary dictionary {} . I tried
>> to change that to OrderedDict (from collections) but apparently it's not
>> working again.Has anybody a solution for this ?
>>
>>
>> ConfigObj does store (and preserve when reading / writing) order.
>>
>> See the documentation on the "sections" and "scalars" attributes of
>> sections:
>>
>> http://www.voidspace.org.uk/python/configobj.html#section-attributes
>>
>> These attributes are normal lists, representing the order that members,
>> single values and subsections appear in the section. The order will either
>> be the order of the original config file, or the order that you added
>> members.
>>
>> The order of members in this lists is the order that write creates in the
>> config file. The scalars list is output before the sections list.
>>
>> Adding or removing members also alters these lists. You can manipulate
>> the lists directly to alter the order of members.
>>
>> All the best,
>>
>> Michael Foord
>>
>>
>> Thanks ,
>> Arash.
>>
>>
>> ------------------------------------------------------------------------------
>> All the data continuously generated in your IT infrastructure
>> contains a definitive record of customers, application performance,
>> security threats, fraudulent activity, and more. Splunk takes this
>> data and makes sense of it. IT sense. And common sense.http://p.sf.net/sfu/splunk-novd2d
>>
>>
>>
>> _______________________________________________
>> Configobj-develop mailing lis...@li...://lists.sourceforge.net/lists/listinfo/configobj-develop
>>
>>
>>
>> -- http://www.voidspace.org.uk/
>>
>> May you do good and not evil
>> May you find forgiveness for yourself and forgive others
>> May you share freely, never taking more than you give.
>> -- the sqlite blessing http://www.sqlite.org/different.html
>>
>>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
|
|
From: Arash A. <aza...@gm...> - 2011-11-22 01:57:10
|
As far as I try , it does not preserve , here is a sample code :
*config = configobj.ConfigObj()*
*config.filename = "file.name"*
*procedure={}*
*loop={'sweep':[],'contents':OrderedDict()}*
*config['procedure']=procedure*
*config['procedure']['var_1']=1*
*config['procedure']['var_2']=1*
*config['procedure']['loop.1']=loop*
*config['procedure']['var_3']=1*
*config.write()*
*
*
*for i in config['procedure'] :*
* print i,'=',str(config['procedure'][i])*
* if i.find('loop')==0:*
* for j in config['procedure'][i]:*
* print j,'=',str(config['procedure'][i])*
*
*
Output is :
*
*
*
var_1 = 1
var_2 = 1
var_3 = 1 <--------- This is out of order.It should be printed last of all.
loop.1 = {'sweep': [], 'contents': {}}
sweep = {'sweep': [], 'contents': {}}
contents = {'sweep': [], 'contents': {}}
*
On Mon, Nov 21, 2011 at 1:29 PM, Michael Foord <fuz...@vo...>wrote:
> On 21/11/2011 21:09, Arash Azarmi wrote:
>
> Hi all ,
> I am using configObj to store inputs from user.In my case, the sequence
> matters so I can't let the configObj don't store sequence order.Both
> Section and ConfigObj are implemented as ordinary dictionary {} . I tried
> to change that to OrderedDict (from collections) but apparently it's not
> working again.Has anybody a solution for this ?
>
>
> ConfigObj does store (and preserve when reading / writing) order.
>
> See the documentation on the "sections" and "scalars" attributes of
> sections:
>
> http://www.voidspace.org.uk/python/configobj.html#section-attributes
>
> These attributes are normal lists, representing the order that members,
> single values and subsections appear in the section. The order will either
> be the order of the original config file, or the order that you added
> members.
>
> The order of members in this lists is the order that write creates in the
> config file. The scalars list is output before the sections list.
>
> Adding or removing members also alters these lists. You can manipulate the
> lists directly to alter the order of members.
>
> All the best,
>
> Michael Foord
>
>
> Thanks ,
> Arash.
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.http://p.sf.net/sfu/splunk-novd2d
>
>
>
> _______________________________________________
> Configobj-develop mailing lis...@li...://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
>
> -- http://www.voidspace.org.uk/
>
> May you do good and not evil
> May you find forgiveness for yourself and forgive others
> May you share freely, never taking more than you give.
> -- the sqlite blessing http://www.sqlite.org/different.html
>
>
|
|
From: Michael F. <fuz...@vo...> - 2011-11-21 22:36:45
|
On 21/11/2011 21:49, Entity Reborn wrote:
> Say I want to modify how Sections work, is there a way to specify a
> replacement class to use instead of Section?
> If not, can this be implemented? (I would assume a class level variable
> would store Section as a default)
That's a nice idea, although a constructor argument might be more
flexible than a class attribute. ConfigObj isn't seeing much active
development at the moment I'm afraid - but feel free to post a patch on
the issue tracker:
http://code.google.com/p/configobj/issues/list
All the best,
Michael Foord
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.voidspace.org.uk/
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
|
|
From: Entity R. <ent...@gm...> - 2011-11-21 21:49:46
|
Say I want to modify how Sections work, is there a way to specify a replacement class to use instead of Section? If not, can this be implemented? (I would assume a class level variable would store Section as a default) |
|
From: Michael F. <fuz...@vo...> - 2011-11-21 21:29:34
|
On 21/11/2011 21:09, Arash Azarmi wrote:
> Hi all ,
> I am using configObj to store inputs from user.In my case, the
> sequence matters so I can't let the configObj don't store sequence
> order.Both Section and ConfigObj are implemented as ordinary
> dictionary {} . I tried to change that to OrderedDict (from
> collections) but apparently it's not working again.Has anybody a
> solution for this ?
>
ConfigObj does store (and preserve when reading / writing) order.
See the documentation on the "sections" and "scalars" attributes of
sections:
http://www.voidspace.org.uk/python/configobj.html#section-attributes
These attributes are normal lists, representing the order that members,
single values and subsections appear in the section. The order will
either be the order of the original config file, or the order that you
added members.
The order of members in this lists is the order that write creates in
the config file. The scalars list is output before the sections list.
Adding or removing members also alters these lists. You can manipulate
the lists directly to alter the order of members.
All the best,
Michael Foord
> Thanks ,
> Arash.
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
>
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
--
http://www.voidspace.org.uk/
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
|
|
From: L. C. <l.c...@gm...> - 2011-11-21 21:23:19
|
On Mon, Nov 21, 2011 at 4:09 PM, Arash Azarmi <aza...@gm...> wrote:
> Hi all ,
> I am using configObj to store inputs from user.In my case, the sequence
> matters so I can't let the configObj don't store sequence order.Both
> Section and ConfigObj are implemented as ordinary dictionary {} . I tried
> to change that to OrderedDict (from collections) but apparently it's not
> working again.Has anybody a solution for this ?
>
> Thanks ,
> Arash.
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
>
Hello,
If I recall correctly, .scalars is an ordered list of the items in the
ConfigObj. See: http://www.voidspace.org.uk/python/configobj.html#sections
This exists for both Sections and ConfigObj, again if I recall correctly.
-Leonardo
|
|
From: Arash A. <aza...@gm...> - 2011-11-21 21:09:27
|
Hi all ,
I am using configObj to store inputs from user.In my case, the sequence
matters so I can't let the configObj don't store sequence order.Both
Section and ConfigObj are implemented as ordinary dictionary {} . I tried
to change that to OrderedDict (from collections) but apparently it's not
working again.Has anybody a solution for this ?
Thanks ,
Arash.
|