Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions artwork_redirect/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# Copyright (C) 2011 Lukas Lalinsky
# Copyright (C) 2019 MetaBrainz Foundation
# Distributed under the MIT license, see the LICENSE file for details.

import configparser
from configparser import ConfigParser, ExtendedInterpolation
from os import path
from sqlalchemy.engine.url import URL


class EnvironmentInterpolation(ExtendedInterpolation):
def before_read(self, parser, section, option, value):
value = super().before_read(parser, section, option, value)
return path.expandvars(value)


class IAConfig(object):
def __init__(self):
self.download_prefix = None
Expand Down Expand Up @@ -74,7 +81,7 @@ class Config(object):

def __init__(self, path, static_path, test=False):
self.static_path = static_path
parser = configparser.RawConfigParser()
parser = ConfigParser(interpolation=EnvironmentInterpolation())
parser.read(path)
self.database = DatabaseConfig()
if test:
Expand Down