| Author |
Message
|
| bobbee |
Posted: Wed May 11, 2022 11:42 am Post subject: reading qm.ini Python |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 542 Location: Huntsville
|
| I have configuration files for my script. I am using configparser. Is there another parser for Python that would read the qm.ini file in the same manner? |
|
| Back to top |
|
 |
| gbaddeley |
Posted: Wed May 11, 2022 3:49 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
qm.ini and other MQ ini files are similar to Windows INI files. Is there any reason why configparser does not work with these? _________________ Glenn |
|
| Back to top |
|
 |
| bobbee |
Posted: Thu May 12, 2022 4:46 am Post subject: |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 542 Location: Huntsville
|
I am using configparser to process a properties file. It looks for sections, by default, in the format of '[section]' The qm.ini is formatted as 'section:'. I have run into a configuration where you can change the section search by using REGEDIT. Trying to find more information on how I can change it to look for 'section:'
I searched again after I wrote this. there is this ConfigParser.SECTCRE in configparser for customizing the section search.
https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.SECTCRE |
|
| Back to top |
|
 |
| bobbee |
Posted: Thu May 12, 2022 5:14 am Post subject: |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 542 Location: Huntsville
|
I will admit my REGEDIT is non-existent. I see the example as
| Code: |
custom.SECTCRE = re.compile(r"\[ *(?P<header>[^]]+?) *\]")
|
Would changing that to:
| Code: |
| custom.SECTCRE = re.compile(r"*(?P<header>[^]]+?) *:") |
solve my problem as instead of looking for '[section]' it would look for 'section:' |
|
| Back to top |
|
 |
| Mo |
Posted: Mon Apr 28, 2025 6:05 pm Post subject: |
|
|
Novice
Joined: 02 Apr 2010 Posts: 18 Location: IL USA
|
| I still get header missing error, did you have to do anything else. |
|
| Back to top |
|
 |
| Molly Mann |
Posted: Mon Apr 13, 2026 12:31 am Post subject: Drift Hunters |
|
|
Newbie
Joined: 13 Apr 2026 Posts: 2
|
| That's a good question about config parsers! While configparser is a solid choice, depending on your needs, you might also consider using python-decouple. It's great for managing settings, especially when dealing with different environments. If you're focusing more on a lightweight and highly customizable option, maybe something simple like parsing a JSON file would work. I was messing around with a basic configuration for something similar while playing Drift Hunters the other day, and even then, flexibility was key! Good luck! |
|
| Back to top |
|
 |
|
|