configparser

Using configparser to remove section name only but retain its key and value pairs

Using configparser to remove section name only but retain its key and value pairs Question: I am trying to remove the section from ini file but i want to retain that section’s keys and values. I tried to remove a section like this with open(‘testing.ini’, "r") as configfile: parser.read_file(configfile) print(parser.sections()) parser.remove_section(‘top’) print(parser.sections()) with open(‘testing.ini’, "w") …

Total answers: 1

AttributeError: type object 'ConfigParser' has no attribute 'Error'

AttributeError: type object 'ConfigParser' has no attribute 'Error' Question: from configparser import ConfigParser configfile = ‘config.ini’ cparser = ConfigParser() try: # assigns values from config except ConfigParser.Error as e: print(e) This code was working a day ago, i dont know if i changed something and it messed things up, but it no longer works Traceback …

Total answers: 1

Wrapping a method from outside the class in Python with decorator

Wrapping a method from outside the class in Python with decorator Question: I would like to ask a question, how I can override/extend the existing external python class. I wanted to be able to call the same API, like parent class, but with some modifications. Something like that: [a] b = 1 import configparser # …

Total answers: 1

python: Working with configparser inside a class. How to access my attributes name and values inside my class-methods?

python: Working with configparser inside a class. How to access my attributes name and values inside my class-methods? Question: My first program is getting much bigger than excepted. 🙂 import configparser config = configparser.ConfigParser() configfile = ‘RealGui.ini’ class FolderLeftSettings: def __init__(self): self.name = "SECTION" self.last_directory = "" self.row_size = 6 self.column_size = 9 def write_to_ini(self): …

Total answers: 1

Can't Access configparser environment variables from env.ini file in faust (kafka streaming)

Can't Access configparser environment variables from env.ini file in faust (kafka streaming) Question: My Project is on FastAPI and the structure goes like this. – project – app – kafka_layer – faustworker.py – core – configs.py – env.ini My env.ini file goes like this [DEFAULT] DATABASE_URL=url_to_db I’ve tried adding this code in configs.py import configparser …

Total answers: 1

launch Django project from any folder

launch Django project from any folder Question: In my project I use config file which is one level higher than manage.py. I use ConfigParser to read it, but for Django to run correctly I need to be in the directory where manage.py is Here is the part where the magic should happen import os import …

Total answers: 1

Installed module via pip, still get ModuleNotFoundError

Installed module via pip, still get ModuleNotFoundError Question: I’m trying to use w3af to start doing some routine security testing on a webapp that I’m using. Install instructions recommend cloning a git repo, then running the python code and seeing what dependencies are unmet then installing them. My first run yielded: ModuleNotFoundError: No module named …

Total answers: 2

Having trouble reading AWS config file with python configparser

Having trouble reading AWS config file with python configparser Question: I ran aws configure to set my access key ID and secret access key. Those are now stored in ~/.aws/credentials which looks like: [default] aws_access_key_id = ###### aws_secret_access_key = ####### I’m trying to access those keys for a script I’m writing using configparser. This is …

Total answers: 1

How to read a config file with Python's configparser?

How to read a config file with Python's configparser? Question: I’m working on reading an external config file in Python(3.7) using the module configparser. Here is my sample configuration file config.ini [ABC] ch0 = "C:/Users/utility/ABC-ch0.txt" ch1 = "C:/Users/utility/ABC-ch1.txt" [settings] script = "C:/Users/OneDrive/utility/xxxx.exe" settings = "C:/Users/OneDrive/xxxxxxConfig.xml" Here is the sample code I tried: import configparser config …

Total answers: 2

Don't understand this ConfigParser.InterpolationSyntaxError

Don't understand this ConfigParser.InterpolationSyntaxError Question: So I have tried to write a small config file for my script, which should specify an IP address, a port and a URL which should be created via interpolation using the former two variables. My config.ini looks like this: [Client] recv_url : http://%(recv_host):%(recv_port)/rpm_list/api/ recv_host = 172.28.128.5 recv_port = 5000 …

Total answers: 2