Questions tagged [configobj]

ConfigObj is a python module for configuration file reading, writing and validation, with validation being the primary feature that distinguishes it from the built-in configparser module.

configobj is a Python module to easily write values to a file and read them back later for use. The common imports are from configobj import ConfigObj and import configobj.

51 questions
22
votes
3 answers

What's better, ConfigObj or ConfigParser?

Which is better for creating a settings file for Python programs, the built-in module (ConfigParser), or the independent project (ConfigObj)?
Apocryphon
  • 221
  • 1
  • 2
  • 3
7
votes
2 answers

Why doesn't **kwargs interpolate with python ConfigObj?

I'm using ConfigObj in python with Template-style interpolation. Unwrapping my config dictionary via ** doesn't seem to do interpolation. Is this a feature or a bug? Any nice workarounds? $ cat my.conf foo = /test bar = $foo/directory >>> import…
Jake Biesinger
  • 5,538
  • 2
  • 23
  • 25
5
votes
1 answer

Using StringIO for ConfigObj and Unicode

I am trying to use StringIO to feed ConfigObj. I would like to do this in my unit tests, so that I can mock config "files", on the fly, depending on what I want to test in the configuration objects. I have a whole bunch of things that I am taking…
Marc-Olivier Titeux
  • 1,209
  • 3
  • 13
  • 24
3
votes
0 answers

Removing yaml tags from yaml.dump()

Am trying to write a yaml file after reading data from a .cfg file. While dumping, the file get dumped with huge metadata that is not desired. When I wasn't using the cfg file, the yaml was not writing any extra tags but after using the configobj…
3
votes
4 answers

config file with a dictionary using python

So I am trying to use a dictionary inside a config file to store a report name to an API call. So something like this: report = {'/report1': '/https://apicall...', '/report2': '/https://apicall...'} I need to store multiple reports:apicalls to one…
Jesse Dugger
  • 55
  • 1
  • 1
  • 5
3
votes
2 answers

Ascii codec error when writing ConfigObj

I wonna read/write russian text, for example: from configobj import ConfigObj obj = ConfigObj('config.ini') mydata = ['вася', 'петя'] obj['users'] = mydata obj.write() And I get error: obj.write() File…
3
votes
2 answers

Get ConfigObj to quote strings

If I run the following script: from configobj import ConfigObj config = ConfigObj() config.filename = 'test.cfg' config['keyword1'] = "the value" config['keyword2'] = "'{0:s}'".format("the value") config['keyword3'] = '"{0:s}"'.format("the…
astrofrog
  • 32,883
  • 32
  • 90
  • 131
2
votes
1 answer

can python configObj process a line without '='

I use python ConfigObj to load a config file, it works great if config file in pattern "cfgName=cfgvalue". Now I need write config file in this way: basket.ini [favoFruit] Apple Orange can (how) load this as a list favoFruit['Apple','Orange'] by…
brike
  • 313
  • 4
  • 10
2
votes
1 answer

py2exe cannot find a module

I have a Python app that works fine. Now I use py2exe to create a windows executable of this app, however the resulting exe fails with complain that it lacks the configobj module Traceback (most recent call last): File "file1.py", line 1, in…
Boris Gorelik
  • 29,945
  • 39
  • 128
  • 170
2
votes
3 answers

Is there any way to write comments using configobj in python

How do I write comments in ConfigObj? I am using python 2.4.3 and ConfigObj 4.7 I don't see any methods in ConfigObj documentation.
2
votes
1 answer

ConfigObj 'un-nest' sections

I'm using ConfigObj 5.0.6 to hold many user-defined values, some of which are nested. I use a local.ini to supercede typical values. There is no front-end, so users edit the configs as needed. To make that easier and more intuitive, there are some…
Dylan Hettinger
  • 731
  • 1
  • 11
  • 20
2
votes
1 answer

Retrieving values from nested python dicts with dot notation

I'm currently using ConfigObj in a project of mine to have structured text based configuration files, and it's pretty neat. The data structure it returns is a normal dict type, which in my case could contain lots of other dicts as values, which…
CaptainPhlegm
  • 121
  • 1
  • 11
2
votes
2 answers

How to keep the quotes string with configobj in Python

I have a config file and it has an item as: [time_format] iso = "ISO (2015-12-31 13:30:55)" I read the config file with configobj as: config = ConfigObj(file_name); section = config.keys(); After some reading, I write the config without modifying…
skyline_z
  • 97
  • 1
  • 8
2
votes
2 answers

ConfigObj and single element lists

I've been looking at ConfigObj and I've run into a problem with validation and single element lists. Say I have a config specification that looks like the following: config_specification = """[Data] [[__many__]] type = option('sense.xml') …
djsumdog
  • 2,560
  • 1
  • 29
  • 55
2
votes
3 answers

Configobj - reading a value using as_bool

I have a configobj file, which I am able to read from, however I'd like to read a few of the values from the file using the as_bool method. Currently I am using the following code and failing miserably! configFile = 'config.conf' config =…
jason
  • 35
  • 5
1
2 3 4