fded6ce46cb167faaae559ff93b050c2b7d18ff1 max Mon Jun 26 08:59:00 2023 -0700 Porting hgGeneGraph to python3. refs #31563 diff --git src/hg/pyLib/pymysql/optionfile.py src/hg/pyLib/pymysql/optionfile.py new file mode 100644 index 0000000..432621b --- /dev/null +++ src/hg/pyLib/pymysql/optionfile.py @@ -0,0 +1,18 @@ +import configparser + + +class Parser(configparser.RawConfigParser): + def __init__(self, **kwargs): + kwargs["allow_no_value"] = True + configparser.RawConfigParser.__init__(self, **kwargs) + + def __remove_quotes(self, value): + quotes = ["'", '"'] + 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)