Re: using configobj string interpolation and logging.config.dictConfig

2017-05-30 Thread Tim Williams
On Friday, May 26, 2017 at 12:26:13 PM UTC-4, Peter Otten wrote:
> Tim Williams wrote:
> 
> > I've spent too much time trying to track this down. I'll just hard-code my
> > filename in my INI file. Maybe I'll get back to it, but I need to move on.
> 
> The only alternative I see would be to build your own InterpolationEngine 
> which understands some kind of escaping so that e. g.
> 
> format = '%%(asctime)s: (%%(levelname)s)  %%(message)s'
> 
> would become
> 
> format = '%(asctime)s: (%(levelname)s)  %(message)s'
> 
> when you invoke the dict() method.

It helps to sometimes just let a problem rest for awhile. I found a workaround 
to my problem. In my INI file, don't create a 'filename' key in the 
config['handlers']['file'] section. Set it in my python code after loading the 
INI file. The following works just fine for me. It doesn't address the issue of 
config.dict() string interpolating the format key, but it does what I want it 
to do and that's my bottom line.

Test script:

import logging, logging.config, logging.handlers
import configobj

logconfig = configobj.ConfigObj('loggingtest.ini', unrepr=True, 
raise_errors=True)

config=logconfig['loggng']
config['handlers']['file']['filename'] = logconfig['loggng']['LogFile']
logging.config.dictConfig(config)
formatters = config['formatters']['fmt1']
logger=logging.getLogger('root')
print(config['handlers']['file'])
for h in logger.handlers:
print('handler {}, stream {}'.format(h.name, h.stream))


loggingtest.ini:
###
[loggng]
version = 1
level = 'INFO'
RootDir = 'TestData'
CaptureDrive = 'C:/'
LogFile = '%(CaptureDrive)s%(RootDir)s/test.log'
[[formatters]]
[[[fmt1]]]
format = '%(asctime)s (%(levelname)s)  %(message)s'
datefmt =
[[handlers]]
[[[console]]]
class = 'logging.StreamHandler'
level = 'INFO'
#stream = 'ext://sys.stdout'
formatter = 'fmt1'
[[[file]]]
class = 'logging.FileHandler'
level = 'WARN'
formatter = 'fmt1'  
[[loggers]]
[[[root]]]
level = 'INFO'
handlers = ['file','console']
###
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using configobj string interpolation and logging.config.dictConfig

2017-05-26 Thread Peter Otten
Tim Williams wrote:

> I've spent too much time trying to track this down. I'll just hard-code my
> filename in my INI file. Maybe I'll get back to it, but I need to move on.

The only alternative I see would be to build your own InterpolationEngine 
which understands some kind of escaping so that e. g.

format = '%%(asctime)s: (%%(levelname)s)  %%(message)s'

would become

format = '%(asctime)s: (%(levelname)s)  %(message)s'

when you invoke the dict() method.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using configobj string interpolation and logging.config.dictConfig

2017-05-26 Thread Tim Williams
On Friday, May 26, 2017 at 8:37:38 AM UTC-4, Tim Williams wrote:
> On Friday, May 26, 2017 at 8:32:19 AM UTC-4, Tim Williams wrote:
> > On Thursday, May 25, 2017 at 9:43:40 PM UTC-4, Tim Williams wrote:
> > > On Thursday, May 25, 2017 at 5:16:13 PM UTC-4, Peter Otten wrote:
> > (snip)
> > > > ...
> > > > 
> > > > How do you get
> > > > 
> > > > > LogFile = '%(CaptureDrive)s%(RootDir)s/test.log'
> > > > 
> > > > to be interpolated while leaving
> > > > 
> > > > > format = '%(asctime)s: (%(levelname)s)  %(message)s'
> > > > 
> > > > as is?
> > > > 
> > > > > However, when I try to call logging.config.dictConfig() on it, the 
> > > > > stream
> > > > > that is opened on creating the logging.FileHandler object is
> > > > > "%(LogFile)s", not "C:/TestData/test.log".
> > > > 
> > > > I don't even get this far:
> > > > 
> > > > >>> c = configobj.ConfigObj("second.ini", unrepr=True)
> > > > >>> c.dict()
> > > > Traceback (most recent call last):
> > > > ...
> > > > configobj.MissingInterpolationOption: missing option "asctime" in 
> > > > interpolation.
> > > > 
> > > > I tried to escape % as %%, but that doesn't seem to work. When I 
> > > > provide 
> > > > bogus replacements
> > > > 
> > > > >>> c = configobj.ConfigObj("third.ini", unrepr=True)
> > > > >>> pprint.pprint(c.dict()["loggng"])
> > > > {'CaptureDrive': 'C:/',
> > > >  'LogFile': 'C:/TestData/test.log',
> > > >  'RootDir': 'TestData',
> > > >  'asctime': 'ASCTIME',
> > > >  'formatters': {'fmt1': {'datefmt': '',
> > > >  'format': 'ASCTIME: (LEVELNAME)  MESSAGE'}},
> > > >  'handlers': {'console': {'class': 'logging.StreamHandler',
> > > >   'level': 'INFO',
> > > >   'stream': 'ext://sys.stdout'},
> > > >   'file': {'class': 'logging.FileHandler',
> > > >'filename': 'C:/TestData/test.log',
> > > >    'level': 'WARN'}},
> > > >  'level': 'INFO',
> > > >  'levelname': 'LEVELNAME',
> > > >  'loggers': {'root': {'handlers': ['file', 'console'], 'level': 
> > > > 'INFO'}},
> > > >  'message': 'MESSAGE',
> > > >  'version': 1}
> > > > 
> > > > I get the expected output.
> > > 
> > > I'm at home now, so I don't have my environment, but if I do a c.dict() I 
> > > get the error about asctime also. If I just pass in the dict object or do 
> > > a 'dict(config['loggng'])', I don't get that.
> > 
> > (Back at work.)
> > Looking at the non-interpolation of '%(asctime)s', etc again, I'm wondering 
> > that myself. Maybe this is a bug in configobj? That doesn't make sense 
> > though. I'm wondering if the keyword 'format' has something to do with it.
> 
> Changed key 'foramt' to 'formt'. No change on non-interpolation of 
> '%(asctime)s'

Peter,

I'm starting to think that maybe my problem is somewhere with configobj. 
Calling ConfigObj.dict() (really configobj.Section.dict()) tries to interpolate 
the values in the 'format' key, but not when creating the ConfigObj object, but 
it does interpolate the LogFile key value. 

I've spent too much time trying to track this down. I'll just hard-code my 
filename in my INI file. Maybe I'll get back to it, but I need to move on.

Thanks for your help.
Tim
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using configobj string interpolation and logging.config.dictConfig

2017-05-26 Thread Tim Williams
On Friday, May 26, 2017 at 8:32:19 AM UTC-4, Tim Williams wrote:
> On Thursday, May 25, 2017 at 9:43:40 PM UTC-4, Tim Williams wrote:
> > On Thursday, May 25, 2017 at 5:16:13 PM UTC-4, Peter Otten wrote:
> (snip)
> > > ...
> > > 
> > > How do you get
> > > 
> > > > LogFile = '%(CaptureDrive)s%(RootDir)s/test.log'
> > > 
> > > to be interpolated while leaving
> > > 
> > > > format = '%(asctime)s: (%(levelname)s)  %(message)s'
> > > 
> > > as is?
> > > 
> > > > However, when I try to call logging.config.dictConfig() on it, the 
> > > > stream
> > > > that is opened on creating the logging.FileHandler object is
> > > > "%(LogFile)s", not "C:/TestData/test.log".
> > > 
> > > I don't even get this far:
> > > 
> > > >>> c = configobj.ConfigObj("second.ini", unrepr=True)
> > > >>> c.dict()
> > > Traceback (most recent call last):
> > > ...
> > > configobj.MissingInterpolationOption: missing option "asctime" in 
> > > interpolation.
> > > 
> > > I tried to escape % as %%, but that doesn't seem to work. When I provide 
> > > bogus replacements
> > > 
> > > >>> c = configobj.ConfigObj("third.ini", unrepr=True)
> > > >>> pprint.pprint(c.dict()["loggng"])
> > > {'CaptureDrive': 'C:/',
> > >  'LogFile': 'C:/TestData/test.log',
> > >  'RootDir': 'TestData',
> > >  'asctime': 'ASCTIME',
> > >  'formatters': {'fmt1': {'datefmt': '',
> > >  'format': 'ASCTIME: (LEVELNAME)  MESSAGE'}},
> > >  'handlers': {'console': {'class': 'logging.StreamHandler',
> > >   'level': 'INFO',
> > >   'stream': 'ext://sys.stdout'},
> > >   'file': {'class': 'logging.FileHandler',
> > >'filename': 'C:/TestData/test.log',
> > >'level': 'WARN'}},
> > >  'level': 'INFO',
> > >  'levelname': 'LEVELNAME',
> > >  'loggers': {'root': {'handlers': ['file', 'console'], 'level': 'INFO'}},
> > >  'message': 'MESSAGE',
> > >  'version': 1}
> > > 
> > > I get the expected output.
> > 
> > I'm at home now, so I don't have my environment, but if I do a c.dict() I 
> > get the error about asctime also. If I just pass in the dict object or do a 
> > 'dict(config['loggng'])', I don't get that.
> 
> (Back at work.)
> Looking at the non-interpolation of '%(asctime)s', etc again, I'm wondering 
> that myself. Maybe this is a bug in configobj? That doesn't make sense 
> though. I'm wondering if the keyword 'format' has something to do with it.

Changed key 'foramt' to 'formt'. No change on non-interpolation of 
'%(asctime)s'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using configobj string interpolation and logging.config.dictConfig

2017-05-26 Thread Tim Williams
On Thursday, May 25, 2017 at 9:43:40 PM UTC-4, Tim Williams wrote:
> On Thursday, May 25, 2017 at 5:16:13 PM UTC-4, Peter Otten wrote:
(snip)
> > ...
> > 
> > How do you get
> > 
> > > LogFile = '%(CaptureDrive)s%(RootDir)s/test.log'
> > 
> > to be interpolated while leaving
> > 
> > > format = '%(asctime)s: (%(levelname)s)  %(message)s'
> > 
> > as is?
> > 
> > > However, when I try to call logging.config.dictConfig() on it, the stream
> > > that is opened on creating the logging.FileHandler object is
> > > "%(LogFile)s", not "C:/TestData/test.log".
> > 
> > I don't even get this far:
> > 
> > >>> c = configobj.ConfigObj("second.ini", unrepr=True)
> > >>> c.dict()
> > Traceback (most recent call last):
> > ...
> > configobj.MissingInterpolationOption: missing option "asctime" in 
> > interpolation.
> > 
> > I tried to escape % as %%, but that doesn't seem to work. When I provide 
> > bogus replacements
> > 
> > >>> c = configobj.ConfigObj("third.ini", unrepr=True)
> > >>> pprint.pprint(c.dict()["loggng"])
> > {'CaptureDrive': 'C:/',
> >  'LogFile': 'C:/TestData/test.log',
> >  'RootDir': 'TestData',
> >  'asctime': 'ASCTIME',
> >  'formatters': {'fmt1': {'datefmt': '',
> >  'format': 'ASCTIME: (LEVELNAME)  MESSAGE'}},
> >  'handlers': {'console': {'class': 'logging.StreamHandler',
> >   'level': 'INFO',
> >   'stream': 'ext://sys.stdout'},
> >   'file': {'class': 'logging.FileHandler',
> >'filename': 'C:/TestData/test.log',
> >'level': 'WARN'}},
> >  'level': 'INFO',
> >  'levelname': 'LEVELNAME',
> >  'loggers': {'root': {'handlers': ['file', 'console'], 'level': 'INFO'}},
> >  'message': 'MESSAGE',
> >  'version': 1}
> > 
> > I get the expected output.
> 
> I'm at home now, so I don't have my environment, but if I do a c.dict() I get 
> the error about asctime also. If I just pass in the dict object or do a 
> 'dict(config['loggng'])', I don't get that.

(Back at work.)
Looking at the non-interpolation of '%(asctime)s', etc again, I'm wondering 
that myself. Maybe this is a bug in configobj? That doesn't make sense though. 
I'm wondering if the keyword 'format' has something to do with it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using configobj string interpolation and logging.config.dictConfig

2017-05-25 Thread Tim Williams
On Thursday, May 25, 2017 at 5:16:13 PM UTC-4, Peter Otten wrote:
> Tim Williams wrote:
> 
> > On Wednesday, May 24, 2017 at 5:47:37 PM UTC-4, Peter Otten wrote:
> >> Tim Williams wrote:
> >> 
> >> > Just as a followup, if I use 'unrepr=True' in my ConfigObj, I don't
> >> > have to convert the strings.
> >> 
> >> I'd keep it simple and would use JSON...
> > 
> > I looked at JSON at first, but went with configobj because I didn't see
> > where it did string interpolation, which I needed for other parts of my
> > INI file, and I'm trying to use it to specify my log file in my handler.
> > 
> > Which brings me to ...
> 
> > I have this stripped down INI file:
> > 
> ...
> 
> How do you get
> 
> > LogFile = '%(CaptureDrive)s%(RootDir)s/test.log'
> 
> to be interpolated while leaving
> 
> > format = '%(asctime)s: (%(levelname)s)  %(message)s'
> 
> as is?
> 
> > However, when I try to call logging.config.dictConfig() on it, the stream
> > that is opened on creating the logging.FileHandler object is
> > "%(LogFile)s", not "C:/TestData/test.log".
> 
> I don't even get this far:
> 
> >>> c = configobj.ConfigObj("second.ini", unrepr=True)
> >>> c.dict()
> Traceback (most recent call last):
> ...
> configobj.MissingInterpolationOption: missing option "asctime" in 
> interpolation.
> 
> I tried to escape % as %%, but that doesn't seem to work. When I provide 
> bogus replacements
> 
> >>> c = configobj.ConfigObj("third.ini", unrepr=True)
> >>> pprint.pprint(c.dict()["loggng"])
> {'CaptureDrive': 'C:/',
>  'LogFile': 'C:/TestData/test.log',
>  'RootDir': 'TestData',
>  'asctime': 'ASCTIME',
>  'formatters': {'fmt1': {'datefmt': '',
>  'format': 'ASCTIME: (LEVELNAME)  MESSAGE'}},
>  'handlers': {'console': {'class': 'logging.StreamHandler',
>   'level': 'INFO',
>   'stream': 'ext://sys.stdout'},
>   'file': {'class': 'logging.FileHandler',
>'filename': 'C:/TestData/test.log',
>'level': 'WARN'}},
>  'level': 'INFO',
>  'levelname': 'LEVELNAME',
>  'loggers': {'root': {'handlers': ['file', 'console'], 'level': 'INFO'}},
>  'message': 'MESSAGE',
>  'version': 1}
> 
> I get the expected output.

I'm at home now, so I don't have my environment, but if I do a c.dict() I get 
the error about asctime also. If I just pass in the dict object or do a 
'dict(config['loggng'])', I don't get that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using configobj string interpolation and logging.config.dictConfig

2017-05-25 Thread Peter Otten
Tim Williams wrote:

> On Wednesday, May 24, 2017 at 5:47:37 PM UTC-4, Peter Otten wrote:
>> Tim Williams wrote:
>> 
>> > Just as a followup, if I use 'unrepr=True' in my ConfigObj, I don't
>> > have to convert the strings.
>> 
>> I'd keep it simple and would use JSON...
> 
> I looked at JSON at first, but went with configobj because I didn't see
> where it did string interpolation, which I needed for other parts of my
> INI file, and I'm trying to use it to specify my log file in my handler.
> 
> Which brings me to ...

> I have this stripped down INI file:
> 
...

How do you get

> LogFile = '%(CaptureDrive)s%(RootDir)s/test.log'

to be interpolated while leaving

> format = '%(asctime)s: (%(levelname)s)  %(message)s'

as is?

> However, when I try to call logging.config.dictConfig() on it, the stream
> that is opened on creating the logging.FileHandler object is
> "%(LogFile)s", not "C:/TestData/test.log".

I don't even get this far:

>>> c = configobj.ConfigObj("second.ini", unrepr=True)
>>> c.dict()
Traceback (most recent call last):
...
configobj.MissingInterpolationOption: missing option "asctime" in 
interpolation.

I tried to escape % as %%, but that doesn't seem to work. When I provide 
bogus replacements

>>> c = configobj.ConfigObj("third.ini", unrepr=True)
>>> pprint.pprint(c.dict()["loggng"])
{'CaptureDrive': 'C:/',
 'LogFile': 'C:/TestData/test.log',
 'RootDir': 'TestData',
 'asctime': 'ASCTIME',
 'formatters': {'fmt1': {'datefmt': '',
 'format': 'ASCTIME: (LEVELNAME)  MESSAGE'}},
 'handlers': {'console': {'class': 'logging.StreamHandler',
  'level': 'INFO',
  'stream': 'ext://sys.stdout'},
  'file': {'class': 'logging.FileHandler',
   'filename': 'C:/TestData/test.log',
   'level': 'WARN'}},
 'level': 'INFO',
 'levelname': 'LEVELNAME',
 'loggers': {'root': {'handlers': ['file', 'console'], 'level': 'INFO'}},
 'message': 'MESSAGE',
 'version': 1}

I get the expected output.

-- 
https://mail.python.org/mailman/listinfo/python-list


using configobj string interpolation and logging.config.dictConfig (was Re: dictConfig: logging.StreamHandler object is not iterable.)

2017-05-25 Thread Tim Williams
On Wednesday, May 24, 2017 at 5:47:37 PM UTC-4, Peter Otten wrote:
> Tim Williams wrote:
> 
> > Just as a followup, if I use 'unrepr=True' in my ConfigObj, I don't have
> > to convert the strings.
> 
> I'd keep it simple and would use JSON...

I looked at JSON at first, but went with configobj because I didn't see where 
it did string interpolation, which I needed for other parts of my INI file, and 
I'm trying to use it to specify my log file in my handler.

Which brings me to ...

I have this stripped down INI file:

[loggng]
version = 1
level = 'INFO'
RootDir = 'TestData'
CaptureDrive = 'C:/'
LogFile = '%(CaptureDrive)s%(RootDir)s/test.log'
[[formatters]]
[[[fmt1]]]
format = '%(asctime)s: (%(levelname)s)  %(message)s'
datefmt =
[[handlers]]
[[[console]]]
class = 'logging.StreamHandler'
level = 'INFO'
stream = 'ext://sys.stdout'
[[[file]]]
class = 'logging.FileHandler'
level = 'WARN'
filename = '%(LogFile)s'
#filename = 'cfg://loggng.LogFile'
[[loggers]]
[[[root]]]
level = 'INFO'
handlers = ['file','console']

When I parse the INI file with configobj:
config = configobj.ConfigObj('loggingtest.ini', unrepr=True, raise_errors=True)

config['loggng']['handlers']['file']['filename'] evaluates correctly to 
C:/TestData/test.log

However, when I try to call logging.config.dictConfig() on it, the stream that 
is opened on creating the logging.FileHandler object is "%(LogFile)s", not 
"C:/TestData/test.log".

Stepping into the debugger, I see that the dictionary is changed in 
BaseConfigurator.convert()

def convert(self, value):
"""
Convert values to an appropriate type. dicts, lists and tuples are
replaced by their converting alternatives. Strings are checked to
see if they have a conversion format and are converted if they do.
"""
if not isinstance(value, ConvertingDict) and isinstance(value, dict):
value = ConvertingDict(value)
value.configurator = self

BEFORE calling ConvertingDict(value), the value dict has the correct value for 
key filename:

>>> value
{'class': 'logging.FileHandler', 'level': 'WARN', 'filename': 
'C:/TestData/test.log'}

AFTER calling ConvertingDict(value):

>>> value
{'filename': '%(LogFile)s', 'class': 'logging.FileHandler', 'level': 'WARN'}

If I try to use 
filename = 'cfg://loggng.LogFile'
in my INI file, I get a ValueError calling logging.config.dictConfig(config):


pydev debugger: starting (pid: 70744)
Traceback (most recent call last):
  File "C:\Python34\lib\logging\config.py", line 557, in configure
handler = self.configure_handler(handlers[name])
  File "C:\Python34\lib\logging\config.py", line 723, in configure_handler
kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
  File "C:\Python34\lib\logging\config.py", line 723, in 
kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
  File "C:\Python34\lib\logging\config.py", line 318, in __getitem__
return self.convert_with_key(key, value)
  File "C:\Python34\lib\logging\config.py", line 284, in convert_with_key
result = self.configurator.convert(value)
  File "C:\Python34\lib\logging\config.py", line 455, in convert
value = converter(suffix)
  File "C:\Python34\lib\logging\config.py", line 404, in cfg_convert
d = self.config[m.groups()[0]]
  File "C:\Python34\lib\logging\config.py", line 317, in __getitem__
value = dict.__getitem__(self, key)
KeyError: 'loggng'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "L:\timothy.j.williams1\Documents\My 
Programs\eclipse_neon\eclipse\plugins\org.python.pydev_5.3.0.201610121612\pysrc\pydevd.py",
 line 1531, in 
globals = debugger.run(setup['file'], None, None, is_module)
  File "L:\timothy.j.williams1\Documents\My 
Programs\eclipse_neon\eclipse\plugins\org.python.pydev_5.3.0.201610121612\pysrc\pydevd.py",
 line 938, in run
pydev_imports.execfile(file, globals, locals)  # execute the script
  File "L:\timothy.j.williams1\Documents\My 
Programs\eclipse_neon\eclipse\plugins\org.python.pydev_5.3.0.201610121612\pysrc\_pydev_imps\_pydev_execfile.py",
 line 25, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "L:\workspace\MyPython\src\testlog.py", line 8, in 
logging.config.dictConfig(config)
  File "C:\Python34\lib\logging\config.py", line 789, in dictConfig
 

Re: configobj validation

2012-03-21 Thread Diez B. Roggisch
Andrea Crotti andrea.crott...@gmail.com writes:

 On 03/19/2012 12:59 PM, Andrea Crotti wrote:
 I seemed to remember that type validation and type conversion worked
 out of the box, but now
 I can't get it working anymore.

 Shouldn't this simple example actually fail the parsing (instead it
 parses perfectly port to a string)?

 sample.py:
 from configobj import ConfigObj

 conf = ConfigObj('sample.conf', configspec='sample.spec')

 sample.conf:
 port = some_string

 sample.spec:
 port = integer(0, 10)

 PS. using configobj 4.7.2

 I now checked the repo and configobj seems also quite dead (2 years
 ago last version), it's a pity because it's a really nice library.
 Any other alternatives for validation/configuration systems otherwise?

It works - so why do you bother? And I'm not sure about the above code -
AFAIK, validation is a two-step thing:

http://www.voidspace.org.uk/python/articles/configobj.shtml#validation

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: configobj validation

2012-03-21 Thread Andrea Crotti

On 03/21/2012 11:40 AM, Diez B. Roggisch wrote:

Andrea Crottiandrea.crott...@gmail.com  writes:

It works - so why do you bother? And I'm not sure about the above code -
AFAIK, validation is a two-step thing:

http://www.voidspace.org.uk/python/articles/configobj.shtml#validation

Diez


I don't agree, if you write code that is supposed to work with Python3, 
using a library which is not

developed and will probably never support Python3 is quite a stupid idea ;)

Any other validation mechanism that can be plugged in ConfigParser for 
example?


From what I've understood from the doc and what I remembered I thought 
that validation is automatically

done when passing the configspec, but I'll check if the two steps work..
--
http://mail.python.org/mailman/listinfo/python-list


configobj validation

2012-03-19 Thread Andrea Crotti
I seemed to remember that type validation and type conversion worked out 
of the box, but now

I can't get it working anymore.

Shouldn't this simple example actually fail the parsing (instead it 
parses perfectly port to a string)?


sample.py:
from configobj import ConfigObj

conf = ConfigObj('sample.conf', configspec='sample.spec')

sample.conf:
port = some_string

sample.spec:
port = integer(0, 10)

PS. using configobj 4.7.2
--
http://mail.python.org/mailman/listinfo/python-list


Re: configobj validation

2012-03-19 Thread Andrea Crotti

On 03/19/2012 12:59 PM, Andrea Crotti wrote:
I seemed to remember that type validation and type conversion worked 
out of the box, but now

I can't get it working anymore.

Shouldn't this simple example actually fail the parsing (instead it 
parses perfectly port to a string)?


sample.py:
from configobj import ConfigObj

conf = ConfigObj('sample.conf', configspec='sample.spec')

sample.conf:
port = some_string

sample.spec:
port = integer(0, 10)

PS. using configobj 4.7.2


I now checked the repo and configobj seems also quite dead (2 years ago 
last version), it's a pity because it's a really nice library.

Any other alternatives for validation/configuration systems otherwise?

--
http://mail.python.org/mailman/listinfo/python-list


Re: configobj

2012-02-01 Thread Andrea Crotti

On 02/01/2012 12:21 AM, Terry Reedy wrote:

On 1/31/2012 11:06 AM, Andrea Crotti wrote:

I have a couple of questions about configobj, which I'm happily trying
to use for this project.


When asking about 3rd party modules, please include a url, so we can 
be sure of what you mean and even take a look. Is

www.voidspace.org.uk/python/configobj.html
what you mean?


Yes I meant that sorry.




which looked less complete and more cumbersome (to me at least)


Does ConfigParser have the same problems you found with ConfigObj.



Well no, but also because it just gets raw strings, and doesn't do any 
validation.

With ConfigObj I can do simply a spec file

skip_pesky_pyc_paths = string_list
include_extra_paths = string_list
use_real_dependencies = bool(default=False)
compute_dependencies_recursively = bool(default=False)

And the options which are not declared will default automatically to 
that value.

And also I never really liked the ConfigParser API..

Anyway I solved just leaving these long lists somewhere else, but otherwise
I think a better solution would be YAML in general (which doesn't have 
much validation either

apparently).
--
http://mail.python.org/mailman/listinfo/python-list


configobj

2012-01-31 Thread Andrea Crotti

I have a couple of questions about configobj, which I'm happily trying
to use for this project.

The first question is, how do I make a very long list of things?
Suppose I have declared in a spec file.

val = string_list

now I would like to do
val = one,
  two,
  three

but that's not allowed, and also
val = one, \
  two, \
  three

doesn't work, is there a way to avoid to write everything on one line?

The second question is, how do I avoid declaring twice the default
value?

For example supposing I have this spec:
skip_pesky_pyc_paths = string_list

I was giving for granted that (pseudocode ahead)
conf = ConfigObj(spec=myspec)
conf['skip_pesky_pyc_paths'] == []

but it's not the case, if it's not declared in the conf file it just
doesn't find the key?
Is there a magic option to make it create the key when they are not
declared from the spec?

Thanks,
Andrea

PS. and why by the way ConfigObj is not in the standard lib, instead of 
ConfigParser,

which looked less complete and more cumbersome (to me at least)
--
http://mail.python.org/mailman/listinfo/python-list


Re: configobj

2012-01-31 Thread Terry Reedy

On 1/31/2012 11:06 AM, Andrea Crotti wrote:

I have a couple of questions about configobj, which I'm happily trying
to use for this project.


When asking about 3rd party modules, please include a url, so we can be 
sure of what you mean and even take a look. Is

www.voidspace.org.uk/python/configobj.html
what you mean?


PS. and why by the way ConfigObj is not in the standard lib, instead of
ConfigParser,


Perhaps history. Informed suggestions for change are welcome.


which looked less complete and more cumbersome (to me at least)


Does ConfigParser have the same problems you found with ConfigObj.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: A question regd configobj

2009-05-22 Thread Gabriel Genellina
En Thu, 21 May 2009 08:23:36 -0300, Srijayanth Sridhar  
srijaya...@gmail.com escribió:


I am wondering if it is possible to have hexadecimal strings in a ini  
file

and have configobj parse it correctly.

for eg:
moonw...@trantor:~/python/config$ cat foo
foo=\x96\x97
.
.
.

a=ConfigObj(foo)
a

ConfigObj({'foo': '\\x96\\x97'})

a['foo']

'\\x96\\x97'


Use the string-escape codec to decode that:

py x = '\\x96\\x97'
py x.decode(string-escape)
'\x96\x97'

You can decode more-or-less automatically the whole config file, using the  
walk method. See  
http://www.voidspace.org.uk/python/configobj.html#walking-a-section (the  
example covers exactly this use case)


--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


A question regd configobj

2009-05-21 Thread Srijayanth Sridhar
Hello,

I am wondering if it is possible to have hexadecimal strings in a ini file
and have configobj parse it correctly.

for eg:
moonw...@trantor:~/python/config$ cat foo
foo=\x96\x97
.
.
.
 a=ConfigObj(foo)
 a
ConfigObj({'foo': '\\x96\\x97'})
 a['foo']
'\\x96\\x97'

As you can see the string has escaped the '\' and I want to suppress that
behavior. I've looked at the documentation and haven't been able to figure
out if this is an available feature or not.

Any help will be greatly appreciated.

Thank you,

Jayanth
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A question regd configobj

2009-05-21 Thread Dave Angel

Srijayanth Sridhar wrote:

Hello,

I am wondering if it is possible to have hexadecimal strings in a ini file
and have configobj parse it correctly.

for eg:
moonw...@trantor:~/python/config$ cat foo
foo=\x96\x97
.
.
.
  

a=ConfigObj(foo)
a


ConfigObj({'foo': '\\x96\\x97'})
  

a['foo']


'\\x96\\x97'

As you can see the string has escaped the '\' and I want to suppress that
behavior. I've looked at the documentation and haven't been able to figure
out if this is an available feature or not.

Any help will be greatly appreciated.

Thank you,

Jayanth

  
When you are using the Python interpreter, the interpreter will escape 
the strings it displays, if you use your present approach.  Try using 
print() to see what the string really contains.


Both approaches are useful -- the interpreter tries to show you 
approximately what you'd have to type to create that value.  Print just 
displays the character, allowing them to take whatever action is called 
for on the output device.


 st = Line 1\nLine 2
 st
'Line 1\nLine 2'
 print st
Line 1
Line 2


--
http://mail.python.org/mailman/listinfo/python-list


ANN: ConfigObj 4.6.0 and Validate 1.0.0 released

2009-04-18 Thread Fuzzyman
Finally a fresh release ConfigObj and Validate.

* ConfigObj Home page: http://www.voidspace.org.uk/python/configobj.html
* Validate Home page: http://www.voidspace.org.uk/python/validate.html

**ConfigObj** is a simple to use but powerful Python library for the
reading and writing of configuration (ini) files. Through **Validate**
it integrates a config file validation and type conversion system.

Features of ConfigObj include:

* Nested sections (subsections), to any level
* List values
* Multiple line values
* Full Unicode support
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- and allowing default values
- repeated sections

* All comments in the file are preserved
* The order of keys/sections is preserved
* Powerful ``unrepr`` mode for storing/retrieving Python data-types

Release 4.6.0 fixes bugs and adds new features, particularly making
configspec handling more flexible.

Full details on the changes can be found at:
http://www.voidspace.org.uk/python/weblog/arch_d7_2009_04_11.shtml#e1078

The changelog for ConfigObj 4.6.0 is:

* Pickling of ConfigObj instances now supported (thanks to Christian
Heimes)
* Hashes in confgspecs are now allowed (see note below)
* Replaced use of hasattr (which can swallow exceptions) with getattr
* ``__many__`` in configspecs can refer to scalars (ordinary values)
as well as sections
* You can use ``___many___`` (three underscores!) where you want to
use ``__many__`` as well
* You can now have normal sections inside configspec sections that use
``__many__``
* You can now create an empty ConfigObj with a configspec,
programmatically set values and then validate
* A section that was supplied as a value (or vice-versa) in the actual
config file would cause an exception during validation (the config
file is still broken of course, but it is now handled gracefully)
* Added ``as_list`` method
* Removed the deprecated ``istrue``, ``encode`` and ``decode`` methods
* Running test_configobj.py now also runs the doctests in the
configobj module
* Through the use of validate 1.0.0 ConfigObj can now validate multi-
line values

As the public API for Validate is stable, and there are no outstanding
issues or feature requests, I've bumped the version number to 1.0.0.
The full change log is:

* BUGFIX: can now handle multiline strings
* Addition of 'force_list' validation option
--
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: ConfigObj 4.6.0 and Validate 1.0.0 released

2009-04-17 Thread Fuzzyman
Finally a fresh release ConfigObj and Validate.

* ConfigObj Home page: http://www.voidspace.org.uk/python/configobj.html
* Validate Home page: http://www.voidspace.org.uk/python/validate.html

**ConfigObj** is a simple to use but powerful Python library for the
reading and writing of configuration (ini) files. Through **Validate**
it integrates a config file validation and type conversion system.

Features of ConfigObj include:

* Nested sections (subsections), to any level
* List values
* Multiple line values
* Full Unicode support
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- and allowing default values
- repeated sections

* All comments in the file are preserved
* The order of keys/sections is preserved
* Powerful ``unrepr`` mode for storing/retrieving Python data-types

Release 4.6.0 fixes bugs and adds new features, particularly making
configspec handling more flexible.

Full details on the changes can be found at:
http://www.voidspace.org.uk/python/weblog/arch_d7_2009_04_11.shtml#e1078

The changelog for ConfigObj 4.6.0 is:

* Pickling of ConfigObj instances now supported (thanks to Christian
Heimes)
* Hashes in confgspecs are now allowed (see note below)
* Replaced use of hasattr (which can swallow exceptions) with getattr
* ``__many__`` in configspecs can refer to scalars (ordinary values)
as well as sections
* You can use ``___many___`` (three underscores!) where you want to
use ``__many__`` as well
* You can now have normal sections inside configspec sections that use
``__many__``
* You can now create an empty ConfigObj with a configspec,
programmatically set values and then validate
* A section that was supplied as a value (or vice-versa) in the actual
config file would cause an exception during validation (the config
file is still broken of course, but it is now handled gracefully)
* Added ``as_list`` method
* Removed the deprecated ``istrue``, ``encode`` and ``decode`` methods
* Running test_configobj.py now also runs the doctests in the
configobj module
* Through the use of validate 1.0.0 ConfigObj can now validate multi-
line values

As the public API for Validate is stable, and there are no outstanding
issues or feature requests, I've bumped the version number to 1.0.0.
The full change log is:

* BUGFIX: can now handle multiline strings
* Addition of 'force_list' validation option
--
http://mail.python.org/mailman/listinfo/python-list


ANN: ConfigObj 4.5.3 Released

2008-06-28 Thread Fuzzyman
A new version of ConfigObj is now available, version 4.5.3.

This version is a minor bugfix release. It fixes a relatively obscure
bug, where an exception could be raised when validating a config file
with 'copy=True' and '__many__' sections.

* Home Page: http://www.voidspace.org.uk/python/configobj.html
* Download: 
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.5.3.zip

ConfigObj is a Python module for the simple reading and writing of
config files. It has many features, whilst remaining easy to use.

With the assistance of validate it can validate a config file against
a specification, and convert members to the expected type.

Eggs for Python 2.4  2.5 are available from Python Package Index.
--
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ConfigObj quoting issues

2008-06-03 Thread Roopesh
Hi,

I am using ConfigObj to write email addresses, as a list. I am using
email module functions to extract email addresses:

to_address = header.get_all('To', [])
address_list = getaddresses(to_address)
to = map(lambda address: ''+address[0]+'
'+address[1]+''  ,address_list)
conf_obj['to'] = to

But quite often I am getting the error cannot be safely quoted..
This error is because of the presence of \', \, \n etc.

I had to do the following to make it work.
address[i].replace(\','').replace('\','').replace('\n','')

[making list_all=False doesn't work properly(it fails when the first
character is a double quote). ]

I don't want to do the above, as it modifies the email address (name).
In brief, my question is how to save a list of strings which might
have quotes, double quotes to a file using ConfigObj.

Any idea what is to be done.

Thanks
Roopesh
--
http://mail.python.org/mailman/listinfo/python-list


Re: ConfigObj quoting issues

2008-06-03 Thread TheSaint
On 14:25, martedì 03 giugno 2008 Roopesh wrote:

 This error is because of the presence of \', \, \n etc.
 
 I had to do the following to make it work.
 address[i].replace(\','').replace('\','').replace('\n','')
 
it's rather ugly :)
I suggest use re module as follow:

import re
address[i] = re.sub('(`||\n)',re.MULTILINE,address[i])

if you've a big chunck of email it'd be fine to compile the regex.

match = re.compile(`||\n)
address[i] = match.sub(address[i])

I think there would be a problem with unicode email addresses. But I doubt
the existance of unicode addresses nowadays.
Unsure for the syntax, pls check
http://www.python.org/doc/2.4/lib/re-syntax.html
  ^^^ according your version, but they're quite the
same

-- 
Mailsweeper Home : http://it.geocities.com/call_me_not_now/index.html
--
http://mail.python.org/mailman/listinfo/python-list

ANN: ConfigObj 4.5.2 and validate 0.3.2

2008-02-27 Thread Fuzzyman
There was a bug in release 4.5.1 of ConfigObj, so there is now an
updated release:

* `ConfigObj 4.5.2 http://www.voidspace.org.uk/python/
configobj.html`_
* `Validate 0.3.2 http://www.voidspace.org.uk/python/validate.html`_

The bug affected the use of ``None`` as a default value in configspecs
and is now fixed.

What are ConfigObj and Validate?
=

**ConfigObj** is a simple to use but powerful configuration file
management library.
Features include:

* Nested sections to any depth
* Unicode support
* List and multiline values
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in a file are preserved when writing
* The order of keys/sections is preserved
* A powerful unrepr mode for storing basic datatypes

**validate** is the module (optional) used for config file validation
and type marshalling. It
can be used outside of ConfigObj for matching string values against a
text specification which
also does type conversion.


Changes in ConfigObj 4.5.x


Distribution now includes validate 0.3.2 so ``None`` as a default
value in configspecs works again.

BUGFIX: Unicode configspecs now work.

ConfigObj will now guarantee that files will be written terminated
with a newline.

ConfigObj will no longer attempt to import the ``validate`` module,
until/unless you call ``ConfigObj.validate`` with
``preserve_errors=True``. This
makes it faster to import.

New methods ``restore_default`` and ``restore_defaults``.
``restore_default`` resets an entry to its default value (and returns
that value). ``restore_defaults`` resets all entries to their default
value. It doesn't modify entries
without a default value. You must have validated a ConfigObj (which
populates the ``default_values`` dictionary) before calling these
methods.

BUGFIX: Proper quoting of keys, values and list values that contain
hashes (when writing).  When ``list_values=False``, values containing
hashes are triple quoted.

Added the ``reload`` method. This reloads a ConfigObj from file. If
the filename attribute is not set then a ``ReloadError`` (a new
exception inheriting from ``IOError``) is raised.

BUGFIX: Files are read in with 'rb' mode, so that native/non-native
line endings work!

Minor efficiency improvement in ``unrepr`` mode.

Added missing docstrings for some overridden dictionary methods.

Added the ``reset`` method. This restores a ConfigObj to a freshly
created state.

Removed old CHANGELOG file.


Changes in Validate 0.3.x
==

BUGFIX: ``None`` as a default value handled correctly.

BUGFIX: Unicode checks no longer broken.

Improved performance with a parse cache.

New ``get_default_value`` method. Given a check it returns the default
value (converted to the correct type) or raises a ``KeyError`` if the
check doesn't specify a default.

Added 'tuple' check and corresponding 'is_tuple' function (which
always returns a tuple).

BUGFIX: A quoted 'None' as a default value is no longer treated as
None,
but as the string 'None'.

BUGFIX: We weren't unquoting keyword arguments of length two, so an
empty string didn't work as a default.

BUGFIX: Strings no longer pass the 'is_list' check. Additionally, the
list checks always return lists.

A couple of documentation bug fixes.

Removed CHANGELOG from module.

Michael Foord
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: ConfigObj 4.5.1 and validate 0.3.1

2008-02-07 Thread Fuzzyman
After one year and two days since the last release, there is a new
release of ConfigObj.

* ConfigObj 4.5.1 http://www.voidspace.org.uk/python/configobj.html
* Validate 0.3.1 http://www.voidspace.org.uk/python/validate.html

This release adds a few new features, plus has several bugfixes and
minor performance improvements.
Thanks to all those who gave feedback, reported bugs and provided
patches.


What are ConfigObj and Validate?
=

**ConfigObj** is a simple to use but powerful configuration file
management library.
Features include:

* Nested sections to any depth
* Unicode support
* List and multiline values
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in a file are preserved when writing
* The order of keys/sections is preserved
* A powerful unrepr mode for storing basic datatypes

**validate** is the module (optional) used for config file validation
and type marshalling. It
can be used outside of ConfigObj for matching string values against a
text specification which
also does type conversion.


Changes in ConfigObj 4.5.1


Distribution updated to include version 0.3.1 of validate. This means
that
Unicode configspecs now work.

ConfigObj will now guarantee that files will be written terminated
with a
newline.

ConfigObj will no longer attempt to import the ``validate`` module,
until/unless
you call ``ConfigObj.validate`` with ``preserve_errors=True``. This
makes it
faster to import.

New methods ``restore_default`` and ``restore_defaults``.
``restore_default``
resets an entry to its default value (and returns that value).
``restore_defaults``
resets all entries to their default value. It doesn't modify entries
without a
default value. You must have validated a ConfigObj (which populates
the
``default_values`` dictionary) before calling these methods.

BUGFIX: Proper quoting of keys, values and list values that contain
hashes
(when writing).  When ``list_values=False``, values containing hashes
are
triple quoted.

Added the ``reload`` method. This reloads a ConfigObj from file. If
the filename
attribute is not set then a ``ReloadError`` (a new exception
inheriting from
``IOError``) is raised.

BUGFIX: Files are read in with 'rb' mode, so that native/non-native
line endings work!

Minor efficiency improvement in ``unrepr`` mode.

Added missing docstrings for some overridden dictionary methods.

Added the ``reset`` method. This restores a ConfigObj to a freshly
created state.

Removed old CHANGELOG file.


Changes in Validate 0.3.1
==

BUGFIX: Unicode checks no longer broken.

Improved performance with a parse cache.

New ``get_default_value`` method. Given a check it returns the default
value (converted to the correct type) or raises a ``KeyError`` if the
check doesn't specify a default.

Added 'tuple' check and corresponding 'is_tuple' function (which
always returns a tuple).

BUGFIX: A quoted 'None' as a default value is no longer treated as
None,
but as the string 'None'.

BUGFIX: We weren't unquoting keyword arguments of length two, so an
empty string didn't work as a default.

BUGFIX: Strings no longer pass the 'is_list' check. Additionally, the
list checks always return lists.

A couple of documentation bug fixes.

Removed CHANGELOG from module.


Michael Foord
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: ConfigObj 4.5.1 and validate 0.3.1

2008-02-07 Thread Fuzzyman
After one year and two days since the last release, there is a new
release of ConfigObj.

* ConfigObj 4.5.1 http://www.voidspace.org.uk/python/configobj.html
* Validate 0.3.1 http://www.voidspace.org.uk/python/validate.html

This release adds a few new features, plus has several bugfixes and
minor performance improvements.
Thanks to all those who gave feedback, reported bugs and provided
patches.


What are ConfigObj and Validate?
=

**ConfigObj** is a simple to use but powerful configuration file
management library.
Features include:

* Nested sections to any depth
* Unicode support
* List and multiline values
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in a file are preserved when writing
* The order of keys/sections is preserved
* A powerful unrepr mode for storing basic datatypes

**validate** is the module (optional) used for config file validation
and type marshalling. It
can be used outside of ConfigObj for matching string values against a
text specification which
also does type conversion.


Changes in ConfigObj 4.5.1


Distribution updated to include version 0.3.1 of validate. This means
that
Unicode configspecs now work.

ConfigObj will now guarantee that files will be written terminated
with a
newline.

ConfigObj will no longer attempt to import the ``validate`` module,
until/unless
you call ``ConfigObj.validate`` with ``preserve_errors=True``. This
makes it
faster to import.

New methods ``restore_default`` and ``restore_defaults``.
``restore_default``
resets an entry to its default value (and returns that value).
``restore_defaults``
resets all entries to their default value. It doesn't modify entries
without a
default value. You must have validated a ConfigObj (which populates
the
``default_values`` dictionary) before calling these methods.

BUGFIX: Proper quoting of keys, values and list values that contain
hashes
(when writing).  When ``list_values=False``, values containing hashes
are
triple quoted.

Added the ``reload`` method. This reloads a ConfigObj from file. If
the filename
attribute is not set then a ``ReloadError`` (a new exception
inheriting from
``IOError``) is raised.

BUGFIX: Files are read in with 'rb' mode, so that native/non-native
line endings work!

Minor efficiency improvement in ``unrepr`` mode.

Added missing docstrings for some overridden dictionary methods.

Added the ``reset`` method. This restores a ConfigObj to a freshly
created state.

Removed old CHANGELOG file.


Changes in Validate 0.3.1
==

BUGFIX: Unicode checks no longer broken.

Improved performance with a parse cache.

New ``get_default_value`` method. Given a check it returns the default
value (converted to the correct type) or raises a ``KeyError`` if the
check doesn't specify a default.

Added 'tuple' check and corresponding 'is_tuple' function (which
always returns a tuple).

BUGFIX: A quoted 'None' as a default value is no longer treated as
None,
but as the string 'None'.

BUGFIX: We weren't unquoting keyword arguments of length two, so an
empty string didn't work as a default.

BUGFIX: Strings no longer pass the 'is_list' check. Additionally, the
list checks always return lists.

A couple of documentation bug fixes.

Removed CHANGELOG from module.


Michael Foord
-- 
http://mail.python.org/mailman/listinfo/python-list


configobj - use of

2007-05-24 Thread Bruce
I assume that you know the module configobj. I use it like this:
I have a config_file :

[sec1]
[[subsec1]]
a = 1
b = 2
[[subsec2]]
a = 3
b = 1

.. ans so on

Then in the code I have c = configobj.ConfigObj(path_to_config file)

then I go like for instance

for s in c['sec1']:
print c['sec1'][s]['a']

Just think its awkward that its neccessary to use the c['sec1'] again
inside the loop,
guess I`d like it to be like
print s.a

instead

Is this the right way to use configobj?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: configobj - use of

2007-05-24 Thread Steve Holden
Bruce wrote:
 I assume that you know the module configobj. I use it like this:
 I have a config_file :
 
 [sec1]
 [[subsec1]]
 a = 1
 b = 2
 [[subsec2]]
 a = 3
 b = 1
 
 .. ans so on
 
 Then in the code I have c = configobj.ConfigObj(path_to_config file)
 
 then I go like for instance
 
 for s in c['sec1']:
   print c['sec1'][s]['a']
 
 Just think its awkward that its neccessary to use the c['sec1'] again
 inside the loop,
 guess I`d like it to be like
 print s.a
 
 instead
 
 Is this the right way to use configobj?
 
So bind a variable to the section, and write

csec = c['sec1']
for s in csec:
 print csec[s]['a']

I don't think configobj support attribute-based access to the section 
values, in which case

 print csec[s].a

won't work.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.comsquidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] ConfigObj 4.4.0 and Validate 0.2.3

2007-02-04 Thread Fuzzyman
Updated versions of both `ConfigObj http://www.voidspace.org.uk/
python/configobj.html`_ and `Validate http://www.voidspace.org.uk/
python/validate.html`_ are now available.

* `ConfigObj 4.4.0 http://www.voidspace.org.uk/cgi-bin/voidspace/
downman.py?file=configobj-4.4.0.zip`_
* `Validate 0.2.3 http://www.voidspace.org.uk/cgi-bin/voidspace/
downman.py?file=validate.py`_

**ConfigObj** is a Python module for the simple reading and writing of
config files. It has many features, whilst remaining easy to use.

With the assistance of **Validate** it can validate a config file
against a specification, and convert members to the expected type.

Thanks to Nicola Larosa who implemented most of the fixes in this
release.


What is New in ConfigObj 4.4.0?
===

* Made the import of compiler conditional so that ConfigObj can be
used with IronPython.

* Fix for Python 2.5 compatibility.

* String interpolation will now check the current section before
checking DEFAULT sections. Based on a patch by Robin Munn.

* Added Template-style interpolation, with tests, based on a patch by
Robin Munn.

* Allowed arbitrary indentation in the ``indent_type`` parameter.

* Fixed Sourceforge bug #1523975 by adding the missing ``self``


What is New in Validate 0.2.3?
==

Fixed validate doc to talk of boolean instead of bool; changed the
``is_bool`` function to ``is_boolean`` (Sourceforge bug #1531525).

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


[ANN] ConfigObj 4.4.0 and Validate 0.2.3

2007-02-04 Thread Fuzzyman
Updated versions of both `ConfigObj http://www.voidspace.org.uk/
python/configobj.html`_ and `Validate http://www.voidspace.org.uk/
python/validate.html`_ are now available.

* `ConfigObj 4.4.0 http://www.voidspace.org.uk/cgi-bin/voidspace/
downman.py?file=configobj-4.4.0.zip`_
* `Validate 0.2.3 http://www.voidspace.org.uk/cgi-bin/voidspace/
downman.py?file=validate.py`_

**ConfigObj** is a Python module for the simple reading and writing of
config files. It has many features, whilst remaining easy to use.

With the assistance of **Validate** it can validate a config file
against a specification, and convert members to the expected type.

Thanks to Nicola Larosa who implemented most of the fixes in this
release.


What is New in ConfigObj 4.4.0?
===

* Made the import of compiler conditional so that ConfigObj can be
used with IronPython.

* Fix for Python 2.5 compatibilities.

* String interpolation will now check the current section before
checking DEFAULT sections. Based on a patch by Robin Munn.

* Added Template-style interpolation, with tests, based on a patch by
Robin Munn.

* Allowed arbitrary indentation in the ``indent_type`` parameter.

* Fixed Sourceforge bug #1523975 by adding the missing ``self``


What is New in Validate 0.2.3?
==

Fixed validate doc to talk of boolean instead of bool; changed the
``is_bool`` function to ``is_boolean`` (Sourceforge bug #1531525).

-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] ConfigObj 4.3.2 Released

2006-06-04 Thread Fuzzyman
`ConfigObj 4.3.2 http://www.voidspace.org.uk/python/configobj.html`_
has just been released.

You can download it from `configobj-4.3.2.zip
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.3.2.zip`_.

ConfigObj is a config file reader and writer. It has *many* features,
but the main one is that it is simple to use. Its features include :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies
* Full Unicode support
* A powerful ``unrepr`` mode for storing basic datatypes

This is a bugfix and minor feature enhancement release. There is a
bugfix in `unrepr mode
http://www.voidspace.org.uk/python/configobj.html#unrepr-mode`_, and
exception handling has been improved.

The full changelog is :

Changed error handling, if parsing finds a single error then that
error will be re-raised. That error will still have an ``errors`` and a
``config`` attribute. That means the error will be more comprehensible.

Fixed bug where '\n' terminated files could be truncated.

Bugfix in ``unrepr`` mode, it couldn't handle '#' in values.
(Thanks to Philippe Normand for the report.)

As a consequence of this fix, ConfigObj doesn't now keep inline
comments in ``unrepr`` mode. This is because the parser in the
`compiler package http://docs.python.org/lib/compiler.html`_ doesn't
keep comments. {sm;:-)}

Error messages are now more useful. They tell you the number of
parsing errors and the line number of the first error. (In the case of
multiple errors.)

Line numbers in exceptions now start at 1, not 0.

Errors in ``unrepr`` mode are now handled the same way as in the
normal mode. The errors stored will be an ``UnreprError``.

There is also a proposal to support `PEP 292
http://www.python.org/dev/peps/pep-0292/`_ string substitution (which
is much better). This will be the target of the next release of
**ConfigObj**.

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


[ANN] ConfigObj 4.3.2 Released

2006-06-04 Thread Fuzzyman
`ConfigObj 4.3.2 http://www.voidspace.org.uk/python/configobj.html`_
has just been released.

You can download it from `configobj-4.3.2.zip
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.3.2.zip`_.

This is a bugfix and minor feature enhancement release. There is a
bugfix in `unrepr mode
http://www.voidspace.org.uk/python/configobj.html#unrepr-mode`_, and
exception handling has been improved.

The full changelog is :

Changed error handling, if parsing finds a single error then that
error will be re-raised. That error will still have an ``errors`` and a
``config`` attribute. That means the error will be more comprehensible.

Fixed bug where '\n' terminated files could be truncated.

Bugfix in ``unrepr`` mode, it couldn't handle '#' in values.
(Thanks to Philippe Normand for the report.)

As a consequence of this fix, ConfigObj doesn't now keep inline
comments in ``unrepr`` mode. This is because the parser in the
`compiler package http://docs.python.org/lib/compiler.html`_ doesn't
keep comments. {sm;:-)}

Error messages are now more useful. They tell you the number of
parsing errors and the line number of the first error. (In the case of
multiple errors.)

Line numbers in exceptions now start at 1, not 0.

Errors in ``unrepr`` mode are now handled the same way as in the
normal mode. The errors stored will be an ``UnreprError``.

There is also a proposal to support `PEP 292
http://www.python.org/dev/peps/pep-0292/`_ string substitution (which
is much better). This will be the target of the next release of
**ConfigObj**.

-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] ConfigObj 4.3.2 Released

2006-06-04 Thread Fuzzyman
`ConfigObj 4.3.2 http://www.voidspace.org.uk/python/configobj.html`_
has just been released.

You can download it from `configobj-4.3.2.zip
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.3.2.zip`_.

ConfigObj is a config file reader and writer. It has *many* features,
but the main one is that it is simple to use. Its features include :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies
* Full Unicode support
* A powerful ``unrepr`` mode for storing basic datatypes

This is a bugfix and minor feature enhancement release. There is a
bugfix in `unrepr mode
http://www.voidspace.org.uk/python/configobj.html#unrepr-mode`_, and
exception handling has been improved.

The full changelog is :

Changed error handling, if parsing finds a single error then that
error will be re-raised. That error will still have an ``errors`` and a
``config`` attribute. That means the error will be more comprehensible.

Fixed bug where '\n' terminated files could be truncated.

Bugfix in ``unrepr`` mode, it couldn't handle '#' in values.
(Thanks to Philippe Normand for the report.)

As a consequence of this fix, ConfigObj doesn't now keep inline
comments in ``unrepr`` mode. This is because the parser in the
`compiler package http://docs.python.org/lib/compiler.html`_ doesn't
keep comments. {sm;:-)}

Error messages are now more useful. They tell you the number of
parsing errors and the line number of the first error. (In the case of
multiple errors.)

Line numbers in exceptions now start at 1, not 0.

Errors in ``unrepr`` mode are now handled the same way as in the
normal mode. The errors stored will be an ``UnreprError``.

There is also a proposal to support `PEP 292
http://www.python.org/dev/peps/pep-0292/`_ string substitution (which
is much better). This will be the target of the next release of
**ConfigObj**.

-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] ConfigObj 4.3.1 validate 0.2.2

2006-04-29 Thread Fuzzyman
`ConfigObj 4.3.1 http://www.voidspace.org.uk/python/configobj.html`_
and `validate 0.2.2
http://www.voidspace.org.uk/python/validate.html`_ are now available.

These are both minor bugfix/feature enhancement releases.


What is New in ConfigObj ?

Changes since **ConfigObj** 4.3.0 :

* Added ``validate.py`` back into ``configobj.zip``. (Thanks to Stewart
Midwinter)

* Updated to `validate.py`_ 0.2.2.

* Preserve tuples when calling the ``dict`` method. (Thanks to Gustavo
Niemeyer.)

* Changed ``__repr__`` to return a string that contains ``ConfigObj({
... })``.

* Change so that an options dictionary isn't modified by passing it to
ConfigObj. (Thanks to Artarious.)

* Added ability to handle negative integers in ``unrepr``. (Thanks to
Kevin Dangoor.)


What is New in validate ?

Changes since **validate** 0.2.1 :

* Addressed bug where a string would pass the ``is_list`` test. (Thanks
to Konrad Wojas.)


What is ConfigObj ?

**ConfigObj** is a simple but powerful config file reader and writer:
an *ini file round tripper*. Its main feature is that it is very easy
to use, with a straightforward programmer's interface and a simple
syntax for config files. It has lots of other features though :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies
* Full Unicode support
* A powerful ``unrepr`` mode for storing basic datatypes


What is validate ?

`validate.py http://www.voidspace.org.uk/python/validate.html`_ is a
module for validating values against a specification. It can be used
with **ConfigObj**, or as a standalone module.

It is extensible, and as well as doing type conversion from strings,
you can easily implement your own functions for transforming values in
any way you please.

-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: ConfigObj 4.3.0

2006-04-07 Thread Fuzzyman
`ConfigObj 4.3.0 http://www.voidspace.org.uk/python/configobj.html`_
is now released.

This has several bugfixes, as well as *several* major feature
enhancements.

You can download it from :

   `ConfigObj-4.3.0.zip 244Kb
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.3.0.zip`_

.. raw:: html

{title;What is ConfigObj ?}

**ConfigObj** is a simple but powerful config file reader and writer:
an *ini
file round tripper*. Its main feature is that it is very easy to use,
with a
straightforward programmer's interface and a simple syntax for config
files.
It has lots of other features though :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies
* Full Unicode support
* A powerful ``unrepr`` mode for storing basic datatypes

.. raw:: html

{title;What's New ?}

Moved the tests and the CHANGELOG (etc) into a separate file. This has
reduced the size of ``configobj.py`` by about 40%.

Added the ``unrepr`` mode to reading and writing config files. Thanks
to Kevin Dangoor for this suggestion.

Empty values are now valid syntax. They are read as an empty string
``''``.
(``key =``, or ``key = # comment``.)

``validate`` now honours the order of the configspec.

Added the ``copy`` mode to validate. Thanks to Louis Cordier for this
suggestion.

Fixed bug where files written on windows could be given ``'\r\r\n'``
line
terminators.

Fixed bug where last occurring comment line could be interpreted as the
final comment if the last line isn't terminated.

Fixed bug where nested list values would be flattened when ``write`` is
called. Now sub-lists have a string representation written instead.

Deprecated ``encode`` and ``decode`` methods instead.

You can now pass in a ConfigObj instance as a configspec (remember to
read
the configspec file using ``list_values=False``).

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: ConfigObj 4.3.0

2006-04-07 Thread Fuzzyman
`ConfigObj 4.3.0 http://www.voidspace.org.uk/python/configobj.html`_
is now released.

This has several bugfixes, as well as *several* major feature
enhancements.

You can download it from :

   `ConfigObj-4.3.0.zip 244Kb
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.3.0.zip`_

.. raw:: html

{title;What is ConfigObj ?}

**ConfigObj** is a simple but powerful config file reader and writer:
an *ini
file round tripper*. Its main feature is that it is very easy to use,
with a
straightforward programmer's interface and a simple syntax for config
files.
It has lots of other features though :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies
* Full Unicode support
* A powerful ``unrepr`` mode for storing basic datatypes

.. raw:: html

{title;What's New ?}

Moved the tests and the CHANGELOG (etc) into a separate file. This has
reduced the size of ``configobj.py`` by about 40%.

Added the ``unrepr`` mode to reading and writing config files. Thanks
to Kevin Dangoor for this suggestion.

Empty values are now valid syntax. They are read as an empty string
``''``.
(``key =``, or ``key = # comment``.)

``validate`` now honours the order of the configspec.

Added the ``copy`` mode to validate. Thanks to Louis Cordier for this
suggestion.

Fixed bug where files written on windows could be given ``'\r\r\n'``
line
terminators.

Fixed bug where last occurring comment line could be interpreted as the
final comment if the last line isn't terminated.

Fixed bug where nested list values would be flattened when ``write`` is
called. Now sub-lists have a string representation written instead.

Deprecated ``encode`` and ``decode`` methods instead.

You can now pass in a ConfigObj instance as a configspec (remember to
read
the configspec file using ``list_values=False``).

-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] ConfigObj 4.2.0

2006-02-19 Thread Fuzzyman
`ConfigObj 4.2.0 http://www.voidspace.org.uk/python/configobj.html`_
is now available.

The main improvements are *full* Unicode support,a s well as the
addition of the 'convenience' `Section Methods
http://www.voidspace.org.uk/python/configobj.html#section-methods`_

* *as_bool*
* *as_int*
* *as_float*

More compelling reasons to choose **ConfigObj** for reading and writing
config files in Python. :-)

What's New ?
==

The full changelog is :

Removed ``BOM_UTF8`` from ``__all__``.

The ``BOM`` attribute has become a boolean. (Defaults to ``False``.) It
is *only* ``True`` for the ``UTF16`` and UTF8 encodings.

File like objects no longer need a ``seek`` attribute.

Full unicode support added. New options/attributes ``encoding``,
``default_encoding``.

ConfigObj no longer keeps a reference to file like objects. Instead the
``write`` method takes a file like object as an optional argument.
(Which will be used in preference of the ``filename`` attribute if that
exists as well.)

utf16 files decoded to unicode.

If ``BOM`` is ``True``, but no encoding specified, then the utf8 BOM is
written out at the start of the file. (It will normally only be
``True`` if the utf8 BOM was found when the file was read.)

File paths are *not* converted to absolute paths, relative paths will
remain relative as the ``filename`` attribute.

Fixed bug where ``final_comment`` wasn't returned if ``write`` is
returning a list of lines.

Deprecated ``istrue``, replaced it with ``as_bool``.

Added ``as_int`` and ``as_float``.

What is ConfigObj ?
===

**ConfigObj** is a simple but powerful config file reader and writer:
an *ini file round tripper*.

It's main feature is that it is very easy to use, with a
straightforward programmer's interface and a simple syntax for config
files. It has lots of other features though. It is intended as a more
powerful (but simpler to use) replacement for `ConfigParser
http://docs.python.org/lib/module-ConfigParser.html`_.

It's features include :

* Nested sections (subsections), to any level
* List Values
* Multiple Line Values
* Full Unicode support
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies

-- 
http://mail.python.org/mailman/listinfo/python-list


Unicode Support for ConfigObj (config file reader) Now in SVN

2006-01-31 Thread Fuzzyman
Hello All,

I've added (optional) unicode support for ConfigObj. This is now
available from SVN.

You can specify an encoding to decode the config file on reading. This
maps to an encoding attribute on the ConfigObj instance that is also
used for writing (and can be changed).

You can find it in the SVN repository at :


https://svn.rest2web.python-hosting.com/branches/configobj4/pythonutils/

For details of the unicode support, read my blog entry at :


http://www.voidspace.org.uk/python/weblog/arch_d7_2006_01_28.shtml#e204

This seems to work fine on the files I've tested it with, but unicode
support is hard to get completely right. I'd appreciate it if anyone
coul;d check it out and try to break it. :-)

There are two remaining questions before I do a beta release. Both
relate to the handling of BOM. Again see the blog.

Comments/opinions sought.

All the best,


Fuzzyman
http://www.voidspace.org.uk/python/configobj.html

-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: ConfigObj 4.1.0 and Validate 0.2.1

2005-12-18 Thread Fuzzyman
 **ConfigObj 4.1.0** and **Validate 0.2.1** are now  available.
{sm;:-)}

ConfigObj and validate have both had moderately big updates.

**What are they ?**

`ConfigObj http://www.voidspace.org.uk/python/configobj.html`_ is a
simple but powerful config file reader and writer: an *ini file round
tripper*. Its main feature is that it is very easy to use, with a
straightforward programmer's interface and a simple syntax for config
files.

It supportes nested sections, preserves the order of keys and sections,
list values, multiple line values, etc.

`validate http://www.voidspace.org.uk/python/validate.html`_
integrates with ConfigObj (but can also be used standalone) to check
that values meet a certain specification. This can be used to validate
a config file, *and* convert values to the expected type.

**What Has Changed?**

Configobj:

Added a ``merge`` method. This allows easy merging together of several
config files (e.g. merging user values on top of a default one).

A new ``flatten_errors`` function to turn the resutls dictionary from
``validate`` into a flat list of errors.

 Added merge, a recursive update.

 Added preserve_errors to validate and the flatten_errors example
function.

 Thanks to Matthew Brett for suggestions and helping me iron out
bugs.

 Fixed bug where a config file is all comment, the comment will now
be initial_comment rather than final_comment.

 Validation no longer done on the 'DEFAULT' section (only in the
root level). This allows interpolation in configspecs.

 Also use the new list syntax in validate 0.2.1. (For configspecs).


Validate:

A new list syntax for checks.


Fixed bug so we can handle keyword argument values with commas.

We now use a list constructor for passing list values to keyword
arguments (including default) : ::

default=list(val, val, val)

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN : ConfigObj 4.0.1 Config File Reader/Writer

2005-11-07 Thread Fuzzyman
Version 4.0.1 of ConfigObj is now available. This includes one bugfix
and two new features.

http://www.voidspace.org.uk/python/configobj.html

What's New ?
==

Fixed bug in ``Section.walk`` when transforming names as well as
values.

Added the ``istrue`` section method. (Fetches the boolean equivalent of
a string value).

Fixed ``list_values=False`` - single line values are not quoted or
unquoted.

See
http://www.voidspace.org.uk/python/weblog/arch_d7_2005_11_05.shtml#e129
for a description of these changes.

List values are written as ``item, item`` rather than ``item,item``.

What is ConfigObj ?
===

ConfigObj is a simple but powerful config file reader and writer: an
ini file round tripper. It's main feature is that it is very easy to
use, with a straightforward programmer's interface and a simple syntax
for config files. It has lots of other features though. This module is
used in most Voidspace projects. See the ConfigObj Home Page for full
documentation.

It's features include :

* Nested sections (subsections), to any level
* List Values
* Multiple Line Values
* String interpolation (substitution)
* Integrated with a powerful validation system

  o including automatic type checking/conversion
  o repeated sections
  o and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: ConfigObj 4.0.0 Final and Pythonutils 0.2.3

2005-10-18 Thread Fuzzyman
ConfigObj 4.0.0 final and Pythonutils 0.2.3 have just hit the streets.

http://www.voidspace.org.uk/python/configobj.html
http://www.voidspace.org.uk/python/pythonutils.html

They are both pure Python modules - the source distributions include
full documentation, which is also online.

What's New ?


ConfigObj 4.0.0 final has two bugfixes.
Using ``setdefault`` to create a new section would return a reference
to the dictionary you passed in - not the new section.
Also fixed a trivial bug in ``write`` (wouldn't have affected anyone).

Pythonutils 0.2.3 is updated to include the ConfigObj 4.0.0 final and
cgiutils 0.3.3

ConfigObj is now marked stable. (But caveat emptor :-)

What is ConfigObj ?
===

ConfigObj is a simple but powerful config file reader and writer: an
*ini file round tripper*. Its main feature is that it is very easy to
use, with a straightforward programmer's interface and a simple syntax
for config files. It has lots of other features though :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies

What is Pythonutils ?
=

The Voidspace Pythonutils package is a simple way of installing the
Voidspace collection of modules. Several of the Voidspace Projects
depend on these modules. They are also useful in their own right of
course. They are primarily general utility modules that simplify common
programming tasks in Python.

These are currently :

* ConfigObj - simple config file handling
* validate - validation and type conversion system
* listquote - string to list conversion
* StandOut - simple logging and output control object
* pathutils - for working with paths and files
* cgiutils - cgi helpers (and functions for sending emails etc)
* urlpath - functions for handling URLs
* odict - Ordered Dictionary Class

All the best,

Fuzzyman
http://www.voidspace.org.uk/python

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: ConfigObj 4.0.0 Final and Pythonutils 0.2.3

2005-10-18 Thread Fuzzyman
ConfigObj 4.0.0 final and Pythonutils 0.2.3 have just hit the streets.

http://www.voidspace.org.uk/python/configobj.html
http://www.voidspace.org.uk/python/pythonutils.html

They are both pure Python modules - the source distributions include
full documentation, which is also online.

What's New ?


ConfigObj 4.0.0 final has two bugfixes.
Using ``setdefault`` to create a new section would return a reference
to the dictionary you passed in - not the new section.
Also fixed a trivial bug in ``write`` (wouldn't have affected anyone).

Pythonutils 0.2.3 is updated to include the ConfigObj 4.0.0 final and
cgiutils 0.3.3

ConfigObj is now marked stable. (But caveat emptor :-)

What is ConfigObj ?
===

ConfigObj is a simple but powerful config file reader and writer: an
*ini file round tripper*. Its main feature is that it is very easy to
use, with a straightforward programmer's interface and a simple syntax
for config files. It has lots of other features though :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

- including automatic type checking/conversion
- repeated sections
- and allowing default values

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies

What is Pythonutils ?
=

The Voidspace Pythonutils package is a simple way of installing the
Voidspace collection of modules. Several of the Voidspace Projects
depend on these modules. They are also useful in their own right of
course. They are primarily general utility modules that simplify common
programming tasks in Python.

These are currently :

* ConfigObj - simple config file handling
* validate - validation and type conversion system
* listquote - string to list conversion
* StandOut - simple logging and output control object
* pathutils - for working with paths and files
* cgiutils - cgi helpers (and functions for sending emails etc)
* urlpath - functions for handling URLs
* odict - Ordered Dictionary Class

All the best,

Fuzzyman
http://www.voidspace.org.uk/python

-- 
http://mail.python.org/mailman/listinfo/python-list


Pythonutils 0.2.2 , ConfigObj 4.0.0 Beta 5, odict 0.1.1

2005-09-15 Thread Fuzzyman
The response to pythonutils__ was very good. Especially the odict__
module (ordered dictionary) - it's had over one hundred and fifty
downloads already. Thanks to some useful user feedback, Nicola Larosa
has updated and improved it.

More embarassingly we've done a bugfix release of ConfigObj__ - now up
to beta 5. This fixes another couple of bugs - we aim to get out of
beta someday..

All this is my way of saying that *odict 0.1.2*, *pythonutils 0.2.2*,
and *ConfigObj beta 5*, are all available from the `Voidspace
Modules`__ page.

__ http://www.voidspace.org.uk/python/pythonutils.html
__ http://www.voidspace.org.uk/python/odict.html
__ http://www.voidspace.org.uk/python/configobj.html
__ http://www.voidspace.org.uk/python/modules.shtml

(The pythonutils update contains odict 0.1.1 *and* ConfigObj Beta 5)

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/

-- 
http://mail.python.org/mailman/listinfo/python-list


Pythonutils 0.2.2 , ConfigObj 4.0.0 Beta 5, odict 0.1.1

2005-09-14 Thread Fuzzyman
The response to pythonutils__ was very good. Especially the odict__
module (ordered dictionary) - it's had over one hundred and fifty
downloads already. Thanks to some useful user feedback, Nicola Larosa
has updated and improved it.

More embarassingly we've done a bugfix release of ConfigObj__ - now up
to beta 5. This fixes another couple of bugs - we aim to get out of
beta someday..

All this is my way of saying that *odict 0.1.2*, *pythonutils 0.2.2*,
and *ConfigObj beta 5*, are all available from the `Voidspace
Modules`__ page.

__ http://www.voidspace.org.uk/python/pythonutils.html
__ http://www.voidspace.org.uk/python/odict.html
__ http://www.voidspace.org.uk/python/configobj.html
__ http://www.voidspace.org.uk/python/modules.shtml

(The pythonutils update contains odict 0.1.1 *and* ConfigObj Beta 5)

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: ConfigObj 4.0.0 Beta 4

2005-09-08 Thread Fuzzyman
Hello Pythoneers,

ConfigObj 4.0.0 has a beta 4 release. This fixes a couple of moderately
serious bugs - so it's worth switching to.

http://cheeseshop.python.org/pypi/ConfigObj
http://www.voidspace.org.uk/python/configobj.html
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.0.0b4.zip
http://sf.net/projects/configobj

What's New ?


(Since Beta 2 the last announced version)

2005/09/07
--

Fixed bug in initialising ConfigObj from a ConfigObj.

Changed the mailing list address.

2005/09/03
--

Fixed bug in ``Section__delitem__`` oops.

2005/08/28
--

Interpolation is switched off before writing out files.

Fixed bug in handling ``StringIO`` instances. (Thanks to report
from
Gustavo Niemeyer [EMAIL PROTECTED])

Moved the doctests from the ``__init__`` method to a separate
function.
(For the sake of IDE calltips).

Beta 3

2005/08/26
--

String values unchanged by validation *aren't* reset. This
preserves
interpolation in string values.


What is ConfigObj ?
===

ConfigObj is a simple but powerful config file reader and writer: an
ini file round tripper. Its main feature is that it is very easy to
use, with a straightforward programmer's interface and a simple syntax
for config files. It has lots of other features though :

* Nested sections (subsections), to any level
* List values
* Multiple line values
* String interpolation (substitution)
* Integrated with a powerful validation system

  o including automatic type checking/conversion
  o allowing default values
  o repeated sections

* All comments in the file are preserved
* The order of keys/sections is preserved
* No external dependencies

ConfigObj is available under the very liberal BSD License.

It addresses *most* of the limitations of ConfigParser as discussed at
: http://wiki.python.org/moin/ConfigParserShootout

Anything Else ?
===

ConfigObj stores nested sections which map names to members
(effectively dictionaries) with values as lists *or* single items. In
association with the validate module it can transparently translate
values back into booleans, floats, integers, and of course strings.

This makes it ideal for *certain* types of human readable (and
writable) data persistence.

There is a discussion of this (with accompanying code) at :
http://www.voidspace.org.uk/python/articles/configobj_for_data_persistence.shtml

-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] ConfigObj Update and New PythonUtils Package

2005-03-10 Thread Fuzzyman
ConfigObj has had another update - now version 3.3.0
Several of the Voidspace PythonUtils modules have been packaged
together as the 'Voidspace Pythonutils Package'. This makes it easier
to release packages that depend on ConfigObj and the other modules.

This update includes several important new features and bugfixes.
New features include - string interpolation similar to ConfigParser,
unicode support for reading and writing of config files, and a
validation schema for validating config files. The validation schema is
implemented using validate.py, which is co-written by Mark Andrews and
maintained at http://www.la-la.com (although included in all the
distributions). The unicode support will recognise and preserve the
UTF-8 BOM when reading/writing files. Check out the docs for full
details of the changes and how they work.

Homepage : http://www.voidspace.org.uk/py­thon/configobj.html
For downloading, see the download section of the homepage.
NEW ConfigObj API Docs Online :
http://www.voidspace.org.uk/py­thon/configob-api

What is ConfigObj
==
A python module (class) for ultra simple reading and writing of simple
config files, including config files with sections. Designed to allow
the greatest flexibility in the config files it will read (and your
users will create).

Many flexible features - but you don't need to use them !


What's New ?
=
Changes in the new version :

2005/03/01Version 3.3.0b
Requires listquote 1.2.0 - which is improved/optimised
Requires caseless 2.2.0 which has support for unicode
Adding support for validation using the configspec
To be done with  an external validator. (Validator class created
with help of Mark Andrews)
This means added methods/attributes :
parseconfigspec method
stripconfigspec method
validate method
__configspec__ attribute
BOM attribute
Experimental unicode internally. 'encoding' and 'backup_encoding'
keywords added
'lists' keyword added - can turn off list handling (lists are left as
strings)
A ConfigObj can be created by passing in a dictionary
Added a __repr__ method for the ConfigObj
configspec can now be a filename (or StringIO instance...) - including
for the write method
Now raises a TypeError rather than a KeyError if you pass in invalid
options
writein can now return a config file as a list of lines if no filename
is set
duplicate keys/sections in writein now raise 'duplicate' errors, rather
than 'conspecerror'
String interpolation from the 'default' section - using '%(keyword)s'
format - similar to ConfigParser
Attribute access as well as dictionary syntax
Added a test for lists
Coerce sections created as dictionaries to caselessDict (bug fix)
Escaped 'mjf-lf;' and 'mjf-quot;' in unquoted values are converted
(bug fix)
Bug fixed in configspec with section files (bug fix)
Bug fix in reporting of duplicate sections with configspec. (bug fix)
Fixed bugs in sectionfiles with 'configspec_only' (errors in the empty
last section would be missed) (bug fix)
Bug fix in __buildconfigspec (bug fix)
Improved support for '/*... */' in the writein method (bug fix)
Fixed typo in verify and reset methods (bug fix)
configspec is no longer destroyed for flatfiles (bug fix)
Missing keys and Extra keys errors the wrong way round in write method
(bug fix)
Plus other minor bugfixes, simplifications and optimisations

The next version will have some refactoring to use more reg-exes in
parsing (I've had to succomb and import re for string interpolation so
I might as well make better use of it) and improvements to the error
system.


*NEW* Voidspace PythonUtils Package
Version 0.1.0 1st March 2005
http://www.voidspace.org.uk/python/pythonutils.html

The Voidspace Pythonutils package is a simple way of installing the
Voidspace collection of modules. For programs that use ConfigObj (which
also requires caseless and listquote), it is simpler to install this
package than to use the modules separately. This makes it simpler to
distribute programs that depend on ConfigObj, without you having to
distribute ConfigObj as well. Of course all the modules are useful in
their own right. The modules included are :

* ConfigObj - simple config file handling
* caseless - case insensitive datatypes and sorting
* listquote - list and element handling
* validate - schema validation system
* StandOut - flexible output object (simple logging and verbosity
control)
* pathutils - for working with paths and files
* cgiutils - cgi helpers

Regards,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

--
http://mail.python.org/mailman/listinfo/python-list


[ANN] ConfigObj update - v3.2.5

2005-02-15 Thread fuzzyman
ConfigObj has had another update - now version 3.2.5

This update includes 3 bugfixes and several new features. Because of
the bugfixes it's reccomended for all users. New features include -
lines can now be broken over two or more lines, initial and final
comments in a config file are preserved (or can be set) when using the
write method, we can now read/write config files directly to and from a
StringIO object, and empty values are now valid (like 'value=' as per
ini files).

Homepage : http://www.voidspace.org.uk/python/configobj.html
For downloading, see the download section of the homepage.


What is ConfigObj
==

A python module (class) for ultra simple reading and writing of simple
config files, including config files with sections. Designed to allow
the greatest flexibility in the config files it will read (and your
users will create).

Many flexible features - but you don't need to use them !


What's New ?
=

The last announced release was 3.2.3, changes since then include :

   2005/02/15Version 3.2.5
   Changes so that ConfigObj can work with StringIO instances, by Wayne
Wiitanen
   (for a project that receives a configuration file over a socket
as a string.
   It is used as the source text for a StringIO object)
   Lines can be extended across more than one line, with the '\'
character
   (must be final character on line - it escapes the newline)
   Empty values can be written 'value=' (like the ini file - but read
only currently)
   Errors whilst parsing now report the line they occurred in
   Duplicate keys and sections are now reported as errors (bug fix)
   isflatfile can now handle '[' inside '\*.. *\' comments (bug fix)
   Fixed bug in handling of final line of '\*.. *\' comments
   If the first and last non empty lines of a config file are comments
they will be preserved as config.initial_comment and self.final_comment
  These are written out when the write method is called (but not
the writein method)
  New list attributes self.initial_comment and self.final_comment
   self.sectionfile is always set to the opposite of self.flatfile
 2005/01/07Version 3.2.4
   Use absolute paths for stored filename. Avoids problems when cwd is
changed.


There have also been a few other improvements to voidspace modules.
Hopefully I'll soon be announcing upgrades to approx,
approxClientproxy, and downman.py.

There is now more detailed information on customizing Movable Python
distributions. See http://www.voidspace.org.uk/python/movpy

Regards,


Fuzzy
http://www.voidspace.org.uk/python/index.shtml

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


[ANN] ConfigObj update - v3.2.5

2005-02-15 Thread fuzzyman
ConfigObj has had another update - now version 3.2.5

This update includes 3 bugfixes and several new features. Because of
the bugfixes it's reccomended for all users. New features include -
lines can now be broken over two or more lines, initial and final
comments in a config file are preserved (or can be set) when using the
write method, we can now read/write config files directly to and from a
StringIO object, and empty values are now valid (like 'value=' as per
ini files).

Homepage : http://www.voidspace.org.uk/python/configobj.html
For downloading, see the download section of the homepage.


What is ConfigObj
==

A python module (class) for ultra simple reading and writing of simple
config files, including config files with sections. Designed to allow
the greatest flexibility in the config files it will read (and your
users will create).

Many flexible features - but you don't need to use them !


What's New ?
=

The last announced release was 3.2.3, changes since then include :

   2005/02/15Version 3.2.5
   Changes so that ConfigObj can work with StringIO instances, by Wayne
Wiitanen
   (for a project that receives a configuration file over a socket
as a string.
   It is used as the source text for a StringIO object)
   Lines can be extended across more than one line, with the '\'
character
   (must be final character on line - it escapes the newline)
   Empty values can be written 'value=' (like the ini file - but read
only currently)
   Errors whilst parsing now report the line they occurred in
   Duplicate keys and sections are now reported as errors (bug fix)
   isflatfile can now handle '[' inside '\*.. *\' comments (bug fix)
   Fixed bug in handling of final line of '\*.. *\' comments
   If the first and last non empty lines of a config file are comments
they will be preserved as config.initial_comment and self.final_comment
  These are written out when the write method is called (but not
the writein method)
  New list attributes self.initial_comment and self.final_comment
   self.sectionfile is always set to the opposite of self.flatfile
 2005/01/07Version 3.2.4
   Use absolute paths for stored filename. Avoids problems when cwd is
changed.


There have also been a few other improvements to voidspace modules.
Hopefully I'll soon be announcing upgrades to approx,
approxClientproxy, and downman.py.

There is now more detailed information on customizing Movable Python
distributions. See http://www.voidspace.org.uk/python/movpy

Regards,


Fuzzy
http://www.voidspace.org.uk/python/index.shtml

-- 
http://mail.python.org/mailman/listinfo/python-list