File: optionfile.py

package info (click to toggle)
python-asyncmy 0.2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 676 kB
  • sloc: python: 3,528; makefile: 40
file content (14 lines) | stat: -rw-r--r-- 432 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from configparser import RawConfigParser


class Parser(RawConfigParser):
    def __init__(self, **kwargs):
        kwargs["allow_no_value"] = True
        super().__init__(**kwargs)

    def get(self, section, option, **kwargs):
        value = super().get(section, option)
        quotes = ("'", '"')
        if len(value) >= 2 and value[0] == value[-1] and value[0] in quotes:
            return value[1:-1]
        return value