Commit 0759b54a authored by Jacek Sowiński's avatar Jacek Sowiński

Don't crash on duplicates in config

Use last definition of an option instead. Section duplicates are also
supported from now.

Example:

'''
[column_keymap]
a = foo
a = bar

[column_keymap]
b = foobar
'''

is equivalent of:

'''
[column_keymap]
a = bar
b = foobar
'''
parent 8b9e3877
[column_keymap]
k = foo
k = bar
[column_keymap]
z = foobar
......@@ -165,5 +165,12 @@ class ConfigTest(TopydoTest):
self.assertNotIn('<Esc', keystates)
self.assertIn('<Esc>', keystates)
def test_config28(self):
""" test duplicates. """
keymap, keystates = config("test/data/ConfigTest7.conf").column_keymap()
self.assertEqual(keymap['k'], 'bar')
self.assertEqual(keymap['z'], 'foobar')
if __name__ == '__main__':
unittest.main()
......@@ -162,7 +162,7 @@ class _Config:
self.config = {}
self.cp = configparser.RawConfigParser()
self.cp = configparser.RawConfigParser(strict=False)
# allow uppercase config keys
self.cp.optionxform = lambda option: option
......
......@@ -49,7 +49,7 @@ def columns(p_alt_layout_path=None):
'show_all': '0',
}
cp = RawConfigParser(defaults)
cp = RawConfigParser(defaults, strict=False)
files = [
"topydo_columns.ini",
"topydo_columns.conf",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment