Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pymysql/optionfile.py: 59%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import configparser
4class Parser(configparser.RawConfigParser):
5 def __init__(self, **kwargs):
6 kwargs["allow_no_value"] = True
7 configparser.RawConfigParser.__init__(self, **kwargs)
9 def __remove_quotes(self, value):
10 quotes = ["'", '"']
11 for quote in quotes:
12 if len(value) >= 2 and value[0] == value[-1] == quote:
13 return value[1:-1]
14 return value
16 def optionxform(self, key):
17 return key.lower().replace("_", "-")
19 def get(self, section, option):
20 value = configparser.RawConfigParser.get(self, section, option)
21 return self.__remove_quotes(value)