[issue11027] Implement sectionxform in configparser

2011-01-28 Thread Kunjesh Kaushik

Kunjesh Kaushik kunjesh.kaus...@gmail.com added the comment:

Very well, then. I would rely on sub-classing for now. The patch would work for 
me as I am only reading configuration. :)

And yes, I wouldn't deny the personal bias anyway. Thanks a lot for all your 
help, folks. Keep up the good work!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11027
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Kunjesh Kaushik

New submission from Kunjesh Kaushik kunjesh.kaus...@gmail.com:

It is often desirable to be able to write a section with spaces around the 
header, as in [ default ] instead of [default] for the sake of readability 
of configuration file. I am not sure if this is the standard format of 
configuration files.

The following (attached) patch will achieve the desired result. It is also 
backward-compatible. Kindly arrange for the patch to be applied to the 
repository or to a future release.

Original Code Location: 
http://svn.python.org/view/*checkout*/python/branches/release27-maint/Lib/ConfigParser.py?revision=84443

Index: Lib/ConfigParser.py
===
--- Lib/ConfigParser.py (revision 84443)
+++ Lib/ConfigParser.py (working copy)
@@ -432,7 +432,7 @@
 #
 SECTCRE = re.compile(
 r'\[' # [
-r'(?Pheader[^]]+)'  # very permissive!
+r'\s*(?Pheader[^]]+)\s*'# very permissive!
 r'\]' # ]
 )
 OPTCRE = re.compile(

--
components: Library (Lib)
files: allow_spaces_around_section_header.diff
keywords: patch
messages: 127193
nosy: Kunjesh.Kaushik
priority: normal
severity: normal
status: open
title: Allow spaces around section header in ConfigParser
type: feature request
versions: Python 2.7
Added file: 
http://bugs.python.org/file20547/allow_spaces_around_section_header.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11027
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Kunjesh Kaushik

Kunjesh Kaushik kunjesh.kaus...@gmail.com added the comment:

Mr. Raymond has raised a valid point. On second thought, I think the submitted 
patch won't resolve the issue.

 import re
 r = re.compile(r'\[\s*(?Pheader[^]]+)\s*\]') # as in the patch
 r.match('[ section header ]').group('header')  # still has issues
'section header '

ISTM, the only solution to this problem is to strip the section headers while 
parsing the file. Subsequent access mechanism should also follow suit. IMHO, 
section headers should be made case-insensitive as well -- similar to option 
keys.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11027
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11027] Allow spaces around section header in ConfigParser

2011-01-27 Thread Kunjesh Kaushik

Kunjesh Kaushik kunjesh.kaus...@gmail.com added the comment:

I think we are dealing with two separate issues: a feature request for 
sectionxform kind of functionality desirable in a future release (3.3 maybe) 
and a behaviour issue in current releases (2.x and 3.x both). I suggest we 
split the two issues and solve them as such. Deferring the latter may be 
undesirable.

Also, I found that a non-greedy pattern will work with the original patch:

 import re
 r = re.compile(r'\[\s*(?Pheader[^]]+?)\s*\]') # note +? instead of +
 r.match('[ section header ]').group('header')   # works as expected
'section header'

Attaching a new patch file as well.

--
keywords: +patch
Added file: 
http://bugs.python.org/file20569/allow_spaces_around_section_header.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11027
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com