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
1
vote
1 answer

Need advice for INI parsing and validation

My constraints A mandatory section An optional section A single-level section Only one identical option by section Text values that can look like this: Electric= yes6batteries Electric= yes4battery Electric= yes8solar_panel Electric=…
Mauricio
  • 670
  • 1
  • 8
  • 23
1
vote
2 answers

ConfigObj option validation

I am using ConfigObj and Validator to parse a configuration file in python. While I like this tool a lot, I am having trouble with validation using a configSpec file. I am using the option() configSpec type that forces the value to be chosen from a…
sgt_pats
  • 161
  • 3
  • 8
0
votes
0 answers

Python: Using ConfigObj to create a .py file

I am trying to use ConfigObj to create a python .py file. The issues I'm facing are as follows - How can I append the starting arguments(classname, init statements), import statements etc using configObj? In ConfigObj, we can use section…
Nitin Khanna
  • 53
  • 1
  • 10
0
votes
2 answers

Is this a decent way of sharing dynamic ConfigObj files?

I have several python processes which monitor and act upon physical IO. E.g. shut down a motor if the current is too high. They need to let each other know why they have done something so I thought a shared file might be a simple solution. The…
RyanN
  • 740
  • 8
  • 20
0
votes
0 answers

Detecting IP addresses from MAC addresses in python

I have a Raspberry Pi that communicates with two other devices on the same LAN. Because it's not my network I can't give the devices static IPs. When they roll over I have to find the new IPs and update them in two configobj configuration pages. I'd…
0
votes
1 answer

ConfigObj: prevent writing empty sections

I'm using ConfigObj (5.0.6, both on python 2.7 and python 3.8) to manage my configs, but when I'm writing to file config with some sections only presented in configspec, they're appearing only as empty sections, which is not desired. I would…
artem30801
  • 35
  • 1
  • 6
0
votes
1 answer

Writing to an .ini file using configparser results in an empty file if restarted while program is running

I have a program that runs a method every five seconds. In this method, I require writing to the configuration .ini file and, because this is embedded software, it must be able to handle the system shutting down at unknown times. However, every time…
Tmello225
  • 113
  • 13
0
votes
1 answer

ConfigObj change key=value to key = value which I don't want to

I have conf file with content: key1=value1 key2=value2 font="\"Font\"" and it's used like values in bash script. When I change some value with cgi+python3 and ConfigObj 4.7.0: def set_conf_values(filename, param, value): config =…
Topper
  • 481
  • 3
  • 18
0
votes
1 answer

Issue with Configobj-python and list items

I am trying to read .ini file with keywords having single items or list items. When I try to print single item strings and float values, it prints as h,e,l,l,o and 2, ., 1 respectively, whereas it should have been just hello and 2.1. Also, when I…
pyPN
  • 105
  • 3
  • 9
0
votes
2 answers

How to update properties file using ConfigObj

Is their any way for updating value of a key in properties file using ConfigObj in python. Before updating properties file: hostKey = "value" After updating properties file: hostKey = "updatedValue"
0
votes
1 answer

save all config VS access configObj for each field

I have a config file abc.ini with trivial fields [SET_1] a=1 b=2 c=3 [SET_2] d=4 e=5 Now, in the script(python) I can do 2 things: Access the file abc.ini once and save all config in a data structure Access the each field where I need them as…
anotherCoder
  • 712
  • 3
  • 11
  • 25
0
votes
1 answer

Text file sent to Spark worker looks empty or not found

I want to send a basic config file to every Spark worker. Config file is written for Python's configobj. I specify it while submitting job. $ ./bin/spark-submit --files .../config.cfg .../spark_str_hello.py But when I try to read it, turns out that…
Artem
  • 477
  • 4
  • 9
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

How to define and select groups of values using configobj?

I would like to define several groups of values where the values of a particular group are used if that group is selected. Here's a an example to make that…
cammil
  • 9,499
  • 15
  • 55
  • 89
0
votes
1 answer

Syntax for strings list with unrepr mode

It works with digit list; I tried with single and double quote without success. from configobj import ConfigObj, ConfigObjError from io import StringIO specs= """\ Number= [6, 8] Electric= [`battery`, `solar_panel`] """ car1="""\ Number=…
Mauricio
  • 670
  • 1
  • 8
  • 23