ConfigParser is a Python module for reading and writing configuration files that have a structure similar to those of INI files in Microsoft Windows.
Questions tagged [configparser]
683 questions
0
votes
3 answers
Parsing a Moses config file
Given a config file as such from the Moses Machine Translation Toolkit:
#########################
### MOSES CONFIG FILE ###
#########################
# input factors
[input-factors]
0
# mapping steps
[mapping]
0 T 0
[distortion-limit]
6
#…

alvas
- 115,346
- 109
- 446
- 738
0
votes
0 answers
Why isn't "is not" working with ConfigParser.sections() in a list comprehension?
I have the following code:
#!/usr/bin/python3
import configparser
config = configparser.ConfigParser()
config.read('bindslash.ini')
print([name for name in config.sections() if name is not 'bindslash'])
bindslash.ini looks like…

strugee
- 2,752
- 4
- 19
- 30
0
votes
2 answers
Python ConfigParser won't run from command line
Python script runs successfully within IDE, but has ConfigParser error when attempted to run via command line.
The error:
raise NoOptionError(option, section)
ConfigParser.NoOptionError: No option 'password' in section: 'database'
The…

tim_schaaf
- 249
- 2
- 9
0
votes
3 answers
Modifying python variables based on config file entries
Relative Python newbie, and I'm writing a script that takes as its input a csv file, splits it into its constituent fields line-by-line and spits it out in another format. What I have so far generally works very well.
Each incoming csv line has…

rpb424
- 1
- 1
- 2
0
votes
0 answers
configparser.configparser() reads sections() from multiple files
My example files:
File01
[sectionf1]
Keyf1=Valf1
File02
[sectionf2]
Keyf2=Valf2
File03
[sectionf3]
Keyf3=Valf3
[sectionf31]
Keyf31=Valf31
File04
[sectionf4]
Keyf4=Valf4
Code (Python 3.2, Debian Wheezy 7.9):
import sys, os, shutil, configparser,…

DJR
- 21
- 1
- 4
0
votes
1 answer
Parse a config-file with Python having more then one variable with the same name
Is there a way to parse a config file like this with Python3?
path = .MyAppData
prefer = newer
path = Dokumente
Please don't blame me. ;) I didn't build the software producing config files like this. But they make sense in that special context.
I…

buhtz
- 10,774
- 18
- 76
- 149
0
votes
1 answer
Running syncdb in django after converting to ConfigParser
So I recently converted my django database settings to use a settings.ini file per the guide found here
My issue is that now syncdb has stopped working for new deployments:
Traceback (most recent call last):
File "manage.py", line 10, in
…

fishpen0
- 619
- 1
- 10
- 23
0
votes
1 answer
update /etc/sysctl.conf with Python's ConfigParser
I am able to use Python's ConfigParser library to read /etc/sysctl.conf by adding a [dummy] section and overriding ConfigParser's read() method as follows:
class SysctlConfigParser(ConfigParser.ConfigParser):
def read(self, fn):
text =…

user389238
- 1,656
- 3
- 19
- 40
0
votes
0 answers
Pyinstaller doesn't generate my file config-file
I'm using Pyinstaller to make an .app bundle on Mac OS X, my app generates a config.ini, the script version worked flawlessly, but when it's an .app, it doesn't work.
I'm using ConfigParser to read and write.
I'm using Pyside for GUI.
It doesn't…

voider1
- 1
- 1
- 2
0
votes
1 answer
Reading python ttk Styles from configuration file
Using python ttk and the ConfigParser leads me to the following issue.
I want to use a Configuration File to make Styles adaptable during usage for every user - not only the ones with access to the sources.
Using the ttk-styles inside my python…

R4PH43L
- 2,122
- 3
- 18
- 30
0
votes
1 answer
ConfigParser overwriting the content of config file
I am having a problem when writing to a config file. I have two Python scripts that read and write to the same file. the problem is when I write to it from one script it overwrites the content from the other script.
Here is my code:
authfile =…

virus.cmd
- 335
- 5
- 13
0
votes
2 answers
Subclass of ConfigParser has no attribute _sections
I am trying to subclass ConfigParser. When trying to access _sections it says
'acc' object has no attribute '_sections'
Example Code(python 2.7):
import ConfigParser
class acc(object, ConfigParser.RawConfigParser):
def __init__(self,…

Emilgardis
- 480
- 4
- 11
0
votes
1 answer
Python - How to change the name of a section use configparser?
Here is my ini file
[456789a]
IP=192.168.1.73
AGENTID=1
NEEDSYNCDEFBAK=-1
GROUP=5
[123456]
IP=192.168.1.73
AGENTID=2
NEEDSYNCDEFBAK=-1
GROUP=2
So..Can I just use configparser to change the name of a section(like..456789a)?
if can't, here is another…

0neSe7en
- 37
- 1
- 10
0
votes
1 answer
Reading a string as a config value using ConfigParser
I'm trying to write a utility that will let me set commands to run in a unix shell, based off config files. Essentially, I want to be able to give a [Command List] and an expected [Response List].. Here's an example of one of my config files:
#…

MrDuk
- 16,578
- 18
- 74
- 133
0
votes
1 answer
Using configparser for text read from URL using urllib2
I have to read a txt ini file from my browser. [this is required]
res = urllib2.urlopen(URL)
inifile = res.read()
Then I want to basically use this the same way as I would have read any txt file.
config =…

user2891472
- 31
- 1
- 5