473,237 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

ConfigParser, mapping one key to multiple values

Hi,

I need a config like this:

[sync files]
ignore=".*/foodir/.*\.pyc"
ignore=".*/foodir/.*~"
....

The ConfigParser of the standard library can't handle this,
because one key maps to multiple values.
Is there a simple and lightweight config parser which can
handle this?

Thomas

PS: Needs to be compatible with Python 2.3

--
Thomas Güttler, http://www.thomas-guettler.de/
Jul 19 '05 #1
2 6882
I accomplish this by using the following construct
with ConfigParser:

[sync files]
ignore_001=.*/foodir/.*\.pyc
ignore_002=.*/foodir/.*~
..
..
..

It may be a workaround, but it works just fine.

It is easy to write code to handle this (not tested):

section='sync files'
ignore_options=[x for x in ini.options(section)
if x.lower().startswith('ignore_')]
ignores_list=[]
for option in ignore_options:
ignores_list.append(ini.get(section, option))

Larry Bates
Thomas Guettler wrote:
Hi,

I need a config like this:

[sync files]
ignore=".*/foodir/.*\.pyc"
ignore=".*/foodir/.*~"
...

The ConfigParser of the standard library can't handle this,
because one key maps to multiple values.
Is there a simple and lightweight config parser which can
handle this?

Thomas

PS: Needs to be compatible with Python 2.3

Jul 19 '05 #2
Am Wed, 01 Jun 2005 17:18:42 -0500 schrieb Larry Bates:
I accomplish this by using the following construct
with ConfigParser:

[sync files]
ignore_001=.*/foodir/.*\.pyc
ignore_002=.*/foodir/.*~


Hi,

I found out, that you can have newlines in the value:

ignore_regex =
.*/CVS(/.*)?$
.*/\.cvsignore$
.*\.pyc$
.*/\.#

If you call split() on the value, you get the list you need.

Thomas

--
Thomas Güttler, http://www.thomas-guettler.de/
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Wilson | last post by:
I'm using ConfigParser to store and retreive some data across multiple runs of my program and it looks like it automatically lower-cases my options: ---this is the program: import...
14
by: Michael Chermside | last post by:
A few weeks ago, the suggestion was made on Python-Dev that it might be time to consider replacing the ConfigParser module and that we should hold a "shootout" (ie ask for implementations and see...
2
by: rzed | last post by:
I am working with PythonCard in one of my apps. For its purposes, it uses an .ini file that is passed to ConfigParser. For my app, I also need configuration information, but for various reasons,...
3
by: mwt | last post by:
I want to set default values for a ConfigParser. So far, its job is very small, so there is only one section heading, . Reading the docs, I see that in order to set default values in a...
1
by: Alexandre CONRAD | last post by:
Hello list ! I'm using the ConfigParser module to use configuration files (what else would it be for ?). But I have a dilema: I'd like to setup multiple "update server" for my application with...
12
by: Florian Lindner | last post by:
Hello, since ConfigParser does not seem to support multiple times the same option name, like: dir="/home/florian" dir="/home/john" dir="/home/whoever" (only the last one is read in)
3
by: derf912 | last post by:
I am working with ConfigParser in python and the ini file that I am reading in has a section titled and under that section I have multiple options. All the options have the same name "customer =" ...
4
by: Phoe6 | last post by:
Hi, I have a configfile, in fact, I am providing a configfile in the format: Name: Foo Author: Bar Testcases: tct123
3
by: Phoe6 | last post by:
Hi, Am starting a new thread as I fear the old thread which more than a week old can go unnoticed. Sorry for the multiple mails. I took the approach of Subclassing ConfigParser to support...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.