2021-03-27 16:21:31 -05:00
|
|
|
import configparser
|
2020-02-25 21:33:33 -06:00
|
|
|
|
|
|
|
|
|
|
|
class Parser(configparser.RawConfigParser):
|
|
|
|
def __init__(self, **kwargs):
|
2021-03-27 16:21:31 -05:00
|
|
|
kwargs["allow_no_value"] = True
|
2020-02-25 21:33:33 -06:00
|
|
|
configparser.RawConfigParser.__init__(self, **kwargs)
|
|
|
|
|
|
|
|
def __remove_quotes(self, value):
|
2021-03-27 16:21:31 -05:00
|
|
|
quotes = ["'", '"']
|
2020-02-25 21:33:33 -06:00
|
|
|
for quote in quotes:
|
|
|
|
if len(value) >= 2 and value[0] == value[-1] == quote:
|
|
|
|
return value[1:-1]
|
|
|
|
return value
|
|
|
|
|
|
|
|
def get(self, section, option):
|
|
|
|
value = configparser.RawConfigParser.get(self, section, option)
|
|
|
|
return self.__remove_quotes(value)
|