Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
"""Functions to work with isbntools.conf file."""
import os
import sys
from .__init__ import __version__
from ._initapp import conf
from .app import defaults_conf, pkg_path
__all__ = ('pkg_version', 'pkg_path', 'pkg_options', 'reg_mod', 'conf_file',
'reg_plugin', 'reg_apikey', 'mk_conf', 'print_conf', 'reg_myopt')
pkg_version = __version__
pkg_options = conf.items('MODULES') if conf.has_section('MODULES') else []
conf_file = conf.files[-1] if conf.files else defaults_conf
VIRTUAL = True if hasattr(sys, 'real_prefix') else False
def _write2conf(section, opts):
if not conf.has_section(section):
conf.add_section(section)
for k, v in opts.items():
conf.set(section, k, v)
with open(conf_file, 'w') as f:
conf.write(f)
def reg_mod(opts):
_write2conf('MODULES', opts)