How to use the isbnlib.config function in isbnlib

To help you get started, we’ve selected a few isbnlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xlcnd / isbnlib / isbnlib / _merge.py View on Github external
def query(isbn, processor=None):
    """Query function for the 'merge provider' (waterfall model)."""
    if not processor:
        processor = config.options.get('VIAS_MERGE', processor).lower()
        if not processor:  # pragma: no cover
            processor = 'parallel'

    named_tasks = (('wcat', qwcat), ('goob', qgoob), ('openl', qopen))
    if processor == 'parallel':
        results = vias.parallel(named_tasks, isbn)
    elif processor == 'serial':
        results = vias.serial(named_tasks, isbn)
    elif processor == 'multi':
        results = vias.multi(named_tasks, isbn)

    rw = results.get('wcat')
    rg = results.get('goob') or results.get('openl')

    if not rw and not rg:  # pragma: no cover
        return None
github xlcnd / isbntools / isbntools / _initapp.py View on Github external
def setconfpath(confpath):
    """Set the directory of the conf file."""
    global CONF_PATH
    CONF_PATH = confpath
    config.set_option('CONF_PATH', confpath)
github xlcnd / isbntools / isbntools / _initapp.py View on Github external
DEFAULTS = r"""
[MISC]
REN_FORMAT={firstAuthorLastName}{year}_{title}_{isbn}
DEBUG=False
[SYS]
URLOPEN_TIMEOUT=10
THREADS_TIMEOUT=12
[SERVICES]
DEFAULT_SERVICE=goob
VIAS_MERGE=parallel
[MODULES]
"""

# get defaults
URLOPEN_TIMEOUT = float(config.URLOPEN_TIMEOUT)
THREADS_TIMEOUT = float(config.THREADS_TIMEOUT)

# set conf path
CONF_PATH = None


# pylint: disable=global-statement
def setconfpath(confpath):
    """Set the directory of the conf file."""
    global CONF_PATH
    CONF_PATH = confpath
    config.set_option('CONF_PATH', confpath)


# read/set conf file
conf = configparser.ConfigParser()
github xlcnd / isbntools / isbntools / _initapp.py View on Github external
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:
        pass

# set metadata cache
if config.options.get('CACHE', 'UNDEFINED').lower() == 'no':