File: config.py

package info (click to toggle)
voctomix 1.3-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 3,368 kB
  • sloc: python: 4,958; sh: 733; makefile: 23
file content (25 lines) | stat: -rw-r--r-- 562 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os.path
from configparser import SafeConfigParser

__all__ = ['get_config']


def get_config(filename=None):

    modulepath = os.path.dirname(os.path.realpath(__file__))

    files = [
        os.path.join(modulepath, '../default-config.ini'),
        os.path.join(modulepath, '../config.ini'),
        '/etc/voctomix/voctomidi.ini',
        '/etc/voctomidi.ini',
        os.path.expanduser('~/.voctomidi.ini'),
    ]

    if filename is not None:
        files.append(filename)

    Config = SafeConfigParser()
    Config.read(files)

    return Config