Issue31535
Created on 2017-09-20 16:28 by philippewagnieres@hispeed.ch, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg302633 - (view) | Author: Philippe Wagnieres (philippewagnieres@hispeed.ch) | Date: 2017-09-20 16:28 | |
I create entry with this:
self.settings.set('General', 'Initial filter', 'All file (*.*)')
self.settings.set('General', '# 1 => Text files (*.txt)')
self.settings.set('General', '# 2 => CSV files (*.csv)')
self.settings.set('General', '# 3 => Text files (*.txt) \n')
and after writing in a file:
initial filter = All file (*.*)
; 1 => text files (*.txt)
; 2 => csv files (*.csv)
# 3 => text files (*.txt)
(; or # to test if differ)
It is normal or not?
Thank & Best Regards
|
|||
| msg325000 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2018-09-11 11:15 | |
All config options are converted to lowercase when they are stored. You can customise this with https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.optionxform. You can customize it more with https://docs.python.org/3/library/configparser.html#customizing-parser-behaviour > Note also that keys in sections are case-insensitive and stored in lowercase >>> from configparser import ConfigParser >>> c = ConfigParser() >>> c["A"] = {'FOO': 'bar'} >>> with open('example.ini', 'w') as configfile: c.write(configfile) ... >>> with open('example.ini', 'r') as configfile: print(configfile.read()) ... [A] foo = bar # Don't convert to lower case >>> d = ConfigParser() >>> d.optionxform = str >>> d["A"] = {'FOO': 'bar'} >>> with open('example_case.ini', 'w') as configfile: d.write(configfile) ... >>> with open('example_case.ini', 'r') as configfile: print(configfile.read()) ... [A] FOO = bar Hope this answers your question. Feel free to close this if it's clear. Thanks |
|||
| msg325002 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2018-09-11 11:34 | |
Ah sorry, didn't notice it was about comments. It seems config.optionxform = str has no effect on comments. Thanks |
|||
| msg325003 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2018-09-11 11:38 | |
Ah my bad again. The config.optionxform = str does the trick. I was using an older object.
from configparser import ConfigParser
config = ConfigParser(allow_no_value=True)
config.optionxform = str
config.add_section('default_settings')
config.set('default_settings', '; comment HERE')
with open('example_case.ini', 'w') as configfile: config.write(configfile)
with open('example_case.ini', 'r') as configfile: print(configfile.read())
Thanks
|
|||
| msg326255 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2018-09-24 15:42 | |
All config options including comment are converted to lowercase when they are stored. You can customize this behavior using https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.optionxform . You can also refer to https://docs.python.org/3/library/configparser.html#customizing-parser-behaviour for more customization. I am closing this as not a bug as part of triaging. Feel free to reopen this if needed. Thanks for the report Philippe! |
|||
| msg326422 - (view) | Author: Philippe Wagnieres (philippewagnieres@hispeed.ch) | Date: 2018-09-26 07:15 | |
Thank for your support. Sorry I have no time to give you an answer and work on with Python, but I have understand the solution. Best Regards Philippe Wagnières Chalamont 6 1400 Yverdon-les-Bains Suisse tel.: +41 76 367 27 43 Le 24.09.2018 à 17:42, Karthikeyan Singaravelan a écrit : > Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: > > All config options including comment are converted to lowercase when they are stored. You can customize this behavior using https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.optionxform . You can also refer to https://docs.python.org/3/library/configparser.html#customizing-parser-behaviour for more customization. I am closing this as not a bug as part of triaging. Feel free to reopen this if needed. > > Thanks for the report Philippe! > > ---------- > resolution: -> not a bug > stage: -> resolved > status: open -> closed > > _______________________________________ > Python tracker <report@bugs.python.org> > <https://bugs.python.org/issue31535> > _______________________________________ |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:52 | admin | set | github: 75716 |
| 2018-09-26 07:15:50 | philippewagnieres@hispeed.ch | set | messages: + msg326422 |
| 2018-09-24 15:42:26 | xtreak | set | status: open -> closed resolution: not a bug messages: + msg326255 stage: resolved |
| 2018-09-11 11:38:37 | xtreak | set | messages: + msg325003 |
| 2018-09-11 11:34:27 | xtreak | set | messages: + msg325002 |
| 2018-09-11 11:15:23 | xtreak | set | messages: + msg325000 |
| 2018-09-11 10:53:13 | xtreak | set | nosy:
+ xtreak |
| 2017-09-20 16:28:22 | philippewagnieres@hispeed.ch | create | |
