1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-10 04:02:17 +00:00

Read config files without interpolation

Fixes #84
This commit is contained in:
spl0k 2018-01-08 19:17:00 +01:00
parent 1605fcd202
commit 8674965c03
3 changed files with 14 additions and 4 deletions

View File

@ -10,9 +10,9 @@
# Distributed under terms of the GNU AGPLv3 license. # Distributed under terms of the GNU AGPLv3 license.
try: try:
from configparser import ConfigParser from configparser import RawConfigParser
except ImportError: except ImportError:
from ConfigParser import SafeConfigParser as ConfigParser from ConfigParser import RawConfigParser
import os import os
import tempfile import tempfile
@ -55,7 +55,7 @@ class IniConfig(DefaultConfig):
] ]
def __init__(self, paths): def __init__(self, paths):
parser = ConfigParser() parser = RawConfigParser()
parser.read(paths) parser.read(paths)
for section in parser.sections(): for section in parser.sections():

View File

@ -11,3 +11,7 @@ switch_true = on
yn_false = no yn_false = no
yn_true = yes yn_true = yes
[issue84]
variable = value
key = some value with a %variable

View File

@ -4,7 +4,7 @@
# This file is part of Supysonic. # This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API. # Supysonic is a Python implementation of the Subsonic server API.
# #
# Copyright (C) 2017 Alban 'spl0k' Féron # Copyright (C) 2017-2018 Alban 'spl0k' Féron
# #
# Distributed under terms of the GNU AGPLv3 license. # Distributed under terms of the GNU AGPLv3 license.
@ -32,6 +32,12 @@ class ConfigTestCase(unittest.TestCase):
self.assertFalse(conf.BOOLEANS[t + '_false']) self.assertFalse(conf.BOOLEANS[t + '_false'])
self.assertTrue(conf.BOOLEANS[t + '_true']) self.assertTrue(conf.BOOLEANS[t + '_true'])
def test_no_interpolation(self):
conf = IniConfig('tests/assets/sample.ini')
self.assertEqual(conf.ISSUE84['variable'], 'value')
self.assertEqual(conf.ISSUE84['key'], 'some value with a %variable')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()