Пример #1
0
def extend_from_file(path):
    d = imp.new_module('config')
    d.__file__ = path
    try:
        with open(path) as config_file:
            exec(compile(config_file.read(), path, 'exec'), d.__dict__)
    except IOError as e:
        from addok.helpers import red
        print(red('Unable to import {} from '
                  'ADDOK_CONFIG_MODULE'.format(path)))
        sys.exit(e)
    else:
        print('Loaded local config from', path)
        extend_from_object(d)
Пример #2
0
def extend_from_file(path):
    d = imp.new_module('config')
    d.__file__ = path
    try:
        with open(path) as config_file:
            exec(compile(config_file.read(), path, 'exec'), d.__dict__)
    except IOError as e:
        from addok.helpers import red
        print(red('Unable to import {} from '
                  'ADDOK_CONFIG_MODULE'.format(path)))
        sys.exit(e)
    else:
        print('Loaded local config from', path)
        extend_from_object(d)
Пример #3
0
    def load_local(self):
        path = (os.environ.get('ADDOK_CONFIG_MODULE')
                or os.path.join('/etc', 'addok', 'addok.conf'))
        if not os.path.exists(path):
            print('No local config file found in "{}".'.format(path))
            return

        d = imp.new_module('config')
        d.__file__ = path
        try:
            with open(path) as config_file:
                exec(compile(config_file.read(), path, 'exec'), d.__dict__)
        except IOError as e:
            from addok.helpers import red
            print(
                red('Unable to import {} from '
                    'ADDOK_CONFIG_MODULE'.format(path)))
            sys.exit(e)
        else:
            print('Loaded local config from', path)
            self.extend_from_object(d)
Пример #4
0
import sys

from .default import *  # noqa
from addok import hooks

# Try to load local setting from a local path.
localpath = os.environ.get('ADDOK_CONFIG_MODULE')
if localpath:
    d = imp.new_module('config')
    d.__file__ = localpath
    try:
        with open(localpath) as config_file:
            exec(compile(config_file.read(), localpath, 'exec'), d.__dict__)
    except IOError as e:
        from addok.helpers import red
        print(red('Unable to import {} from '
                  'ADDOK_CONFIG_MODULE'.format(localpath)))
        sys.exit(1)
    else:
        print('Loaded local config from', localpath)
        for key in dir(d):
            if key.isupper():
                globals()[key] = getattr(d, key)

HOUSENUMBERS_FIELD = None
NAME_FIELD = None
FIELDS.extend(EXTRA_FIELDS)
for field in FIELDS:
    key = field['key']
    if field.get('type') == 'housenumbers' or key == 'housenumbers':
        HOUSENUMBERS_FIELD = key
        field['type'] = 'housenumbers'