Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Case Sensitive Section names configparser

Reply
Thread Tools

Case Sensitive Section names configparser

 
 
RedBaron
Guest
Posts: n/a
 
      12-08-2010
Is there any way by which configParser's get() function can be made
case insensitive?
 
Reply With Quote
 
 
 
 
Francesco Bochicchio
Guest
Posts: n/a
 
      12-08-2010
On 8 Dic, 11:32, RedBaron <(E-Mail Removed)> wrote:
> Is there any way by which configParser's get() function can be made
> case insensitive?


If you don't care about the case of the config parameter values, you
could pre-convert the input to
configParser all in UPPER or lower letter with a file-like object like
this (NOT TESTED):

class AllUpperFile(object):
def __init__(self, fname): self.fp = file(fname)
def readline(self): return self.fp.readline().upper()

and the use configParser.readfp method to feed the file-like object to
the config parser

myConfigparser.readfp( AllUpperFile("myconnfigfile.cfg")

HTH

Ciao
----
FB
 
Reply With Quote
 
 
 
 
Jon Clements
Guest
Posts: n/a
 
      12-08-2010
On Dec 8, 10:32*am, RedBaron <(E-Mail Removed)> wrote:
> Is there any way by which configParser's get() function can be made
> case insensitive?


I would probably subclass dict to create a string specific, case
insensitive version, and supply it as the dict_type. See
http://docs.python.org/library/confi...awConfigParser

That way your values would remain cased correctly, but lookups would
be insensitive.

hth

Jon.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
case sensitive file names Roedy Green Java 14 05-17-2009 06:11 AM
ConfigParser: Can I read(ConfigParser.get()) a configuration file anduse it to call a funciton? jamitwidme@gmail.com Python 3 06-26-2008 08:01 PM
RE: Case sensitive file names Delaney, Timothy C (Timothy) Python 2 02-23-2004 07:46 PM
RE: Case sensitive file names Tim Peters Python 2 02-23-2004 03:10 AM
Case sensitive file names Thomas Philips Python 1 02-22-2004 05:10 PM



Advertisments