Exemplo n.º 1
0
            os.path.expanduser('~/.local/isbntools/isbntools.conf'),
            os.path.expanduser('~/.config/isbntools/isbntools.conf'),
            os.path.expanduser('~/.isbntools/isbntools.conf'),
        ])
try:  # pragma: no cover
    setconfpath(os.path.dirname(conf.files[0]))
except:
    pass

# set options
if conf.has_section('SYS'):
    # get user defined values for timeouts
    URLOPEN_TIMEOUT = float(conf.get('SYS', 'URLOPEN_TIMEOUT'))
    THREADS_TIMEOUT = float(conf.get('SYS', 'THREADS_TIMEOUT'))
    # URLOPEN_TIMEOUT is used by webservice.py and is a number
    config.seturlopentimeout(URLOPEN_TIMEOUT)
    # THREADS_TIMEOUT is used by vias.py and is a number
    config.setthreadstimeout(THREADS_TIMEOUT)
    # LOAD_METADATA_PLUGINS
    LOAD_METADATA_PLUGINS = bool(
        conf.get('SYS', 'LOAD_METADATA_PLUGINS') == 'True')
    config.set_option('LOAD_METADATA_PLUGINS', LOAD_METADATA_PLUGINS)
    # LOAD_FORMATTER_PLUGINS
    LOAD_FORMATTER_PLUGINS = bool(
        conf.get('SYS', 'LOAD_FORMATTER_PLUGINS') == 'True')
    config.set_option('LOAD_FORMATTER_PLUGINS', LOAD_FORMATTER_PLUGINS)

# only now we can import registry!
# pylint: disable=wrong-import-position
from isbnlib import registry
Exemplo n.º 2
0
        if 'api_key' in o:  # pragma: no cover
            name = o[:-8]
            config.add_apikey(name, v)
        else:
            config.set_option(o.upper(), v)

if conf.has_section('MISC'):  # pragma: no cover
    for o, v in conf.items('MISC'):
        config.set_option(o.upper(), v)

if conf.has_section('MODULES'):  # pragma: no cover
    for o, v in conf.items('MODULES'):
        config.set_option(o.upper(), v)

# URLOPEN_TIMEOUT is used by webservice.py
config.seturlopentimeout(URLOPEN_TIMEOUT)

# THREADS_TIMEOUT is used by vias.py
config.setthreadstimeout(THREADS_TIMEOUT)

# set CONF_PATH
if not CONF_PATH:
    if VIRTUAL:
        CONF_PATH = os.path.join(sys.prefix, 'isbntools')
    else:
        CONF_PATH = os.path.join(os.getenv('APPDATA'), 'isbntools') \
                    if WINDOWS else os.path.expanduser('~/.isbntools')
    # make the folder if it doesn't exist (see issue #101)!
    try:  # pragma: no cover
        os.mkdir(CONF_PATH)
    except: