diff --git a/anyconfig/api.py b/anyconfig/api.py index 24025971..a532634e 100644 --- a/anyconfig/api.py +++ b/anyconfig/api.py @@ -29,14 +29,14 @@ container = anyconfig.mergeabledict.MergeableDict # pylint: enable=C0103 -logger = logging.getLogger(__name__) +LOGGER = logging.getLogger(__name__) def set_loglevel(level): """ :param level: Log level, e.g. logging.INFO and logging.WARN. """ - logger.setLevel(level) + LOGGER.setLevel(level) def find_loader(config_path, forced_type=None): @@ -48,15 +48,15 @@ def find_loader(config_path, forced_type=None): if forced_type is not None: cparser = anyconfig.backend.backends.find_by_type(forced_type) if not cparser: - logger.error("No parser found for given type: %s", forced_type) + LOGGER.error("No parser found for given type: %s", forced_type) return None else: cparser = anyconfig.backend.backends.find_by_file(config_path) if not cparser: - logger.error("No parser found for given file: %s", config_path) + LOGGER.error("No parser found for given file: %s", config_path) return None - logger.debug("Using config parser of type: %s", cparser.type()) + LOGGER.debug("Using config parser of type: %s", cparser.type()) return cparser @@ -84,15 +84,15 @@ def single_load(config_path, forced_type=None, ignore_missing=False, if cparser is None: return None - logger.info("Loading: %s", config_path) + LOGGER.info("Loading: %s", config_path) if template: try: - logger.debug("Compiling: %s", config_path) + LOGGER.debug("Compiling: %s", config_path) config_content = anyconfig.template.render(config_path, context) return cparser.loads(config_content, ignore_missing=ignore_missing, **kwargs) except: - logger.warn("Failed to compile %s, fallback to no template " + LOGGER.warn("Failed to compile %s, fallback to no template " "mode", config_path) return cparser.load(config_path, ignore_missing=ignore_missing, @@ -201,11 +201,11 @@ def loads(config_content, forced_type=None, template=True, context={}, if template: try: - logger.debug("Compiling") + LOGGER.debug("Compiling") config_content = anyconfig.template.render_s(config_content, context) except: - logger.warn("Failed to compile and fallback to no template " + LOGGER.warn("Failed to compile and fallback to no template " "mode: '%s'", config_content[:50] + '...') return cparser.loads(config_content, **kwargs) @@ -222,7 +222,7 @@ def _find_dumper(config_path, forced_type=None): cparser = find_loader(config_path, forced_type) if cparser is None or not getattr(cparser, "dump", False): - logger.warn("Dump method not implemented. Fallback to " + LOGGER.warn("Dump method not implemented. Fallback to " "JsonConfigParser") cparser = anyconfig.backend.json_.JsonConfigParser() @@ -242,7 +242,7 @@ def dump(data, config_path, forced_type=None, **kwargs): """ dumper = _find_dumper(config_path, forced_type) - logger.info("Dumping: %s", config_path) + LOGGER.info("Dumping: %s", config_path) dumper.dump(data, config_path, **kwargs) diff --git a/anyconfig/backend/base.py b/anyconfig/backend/base.py index 0e1f6315..57244c02 100644 --- a/anyconfig/backend/base.py +++ b/anyconfig/backend/base.py @@ -9,9 +9,9 @@ import anyconfig.mergeabledict import anyconfig.utils -SUPPORTED = False -logger = logging.getLogger(__name__) +SUPPORTED = False +LOGGER = logging.getLogger(__name__) def mk_opt_args(keys, kwargs): @@ -43,7 +43,7 @@ def mk_dump_dir_if_not_exist(f): dumpdir = os.path.dirname(f) if not os.path.exists(dumpdir): - logger.debug("Creating output dir as it's not found: %s", dumpdir) + LOGGER.debug("Creating output dir as it's not found: %s", dumpdir) os.makedirs(dumpdir) diff --git a/anyconfig/backend/ini_.py b/anyconfig/backend/ini_.py index 997e52b2..0c9134f0 100644 --- a/anyconfig/backend/ini_.py +++ b/anyconfig/backend/ini_.py @@ -10,10 +10,9 @@ from anyconfig.compat import configparser, iteritems -logger = logging.getLogger(__name__) +LOGGER = logging.getLogger(__name__) SUPPORTED = True # It should be available w/ python dist always. - _SEP = ',' @@ -82,7 +81,7 @@ def _load_impl(config_fp, sep=_SEP, **kwargs): config[s][k] = _parse(v, sep) except Exception: - logger.warn(sys.exc_info()[-1]) + LOGGER.warn(sys.exc_info()[-1]) raise return config diff --git a/anyconfig/backend/xml_.py b/anyconfig/backend/xml_.py index 0020e8b3..e6d9ab9d 100644 --- a/anyconfig/backend/xml_.py +++ b/anyconfig/backend/xml_.py @@ -3,16 +3,14 @@ # License: MIT # # pylint: disable=R0921 - import logging import anyconfig.backend.base as Base import anyconfig.compat -logger = logging.getLogger(__name__) +LOGGER = logging.getLogger(__name__) SUPPORTED = True - try: # First, try lxml which is compatible with elementtree and looks faster a # lot. See also: http://getpython3.com/diveintopython3/xml.html @@ -24,7 +22,7 @@ try: import elementtree.ElementTree as etree except ImportError: - logger.warn("ElementTree module is not available. Disabled " + LOGGER.warn("ElementTree module is not available. Disabled " "XML support.") SUPPORTED = False @@ -45,7 +43,7 @@ def etree_getroot_fromsrc(src): return etree.parse(src).getroot() else: def _dummy_fun(*args, **kwargs): - logger.warn("Return None as XML module is not available: " + LOGGER.warn("Return None as XML module is not available: " "args=%s, kwargs=%s", ','.join(args), str(kwargs)) return None diff --git a/anyconfig/backend/yaml_.py b/anyconfig/backend/yaml_.py index b6dc5ee1..da7bc3cd 100644 --- a/anyconfig/backend/yaml_.py +++ b/anyconfig/backend/yaml_.py @@ -5,14 +5,14 @@ import logging import anyconfig.backend.base as Base -logger = logging.getLogger(__name__) +LOGGER = logging.getLogger(__name__) SUPPORTED = False try: import yaml SUPPORTED = True except ImportError: - logger.warn("YAML module is not available. Disabled its support.") + LOGGER.warn("YAML module is not available. Disabled its support.") if SUPPORTED: @@ -34,12 +34,12 @@ def yaml_dump(data, fp, **kwargs): return yaml.dump(data, fp, **kwargs) else: def yaml_load(*args, **kwargs): - logger.warn("Return {} as YAML module is not available: " + LOGGER.warn("Return {} as YAML module is not available: " "args=%s, kwargs=%s", ','.join(args), str(kwargs)) return {} def yaml_dump(*args, **kwargs): - logger.warn("Do nothing as YAML module is not available: " + LOGGER.warn("Do nothing as YAML module is not available: " "args=%s, kwargs=%s", ','.join(args), str(kwargs)) pass diff --git a/anyconfig/template.py b/anyconfig/template.py index 619349a2..3618b00f 100644 --- a/anyconfig/template.py +++ b/anyconfig/template.py @@ -9,8 +9,7 @@ from anyconfig.compat import raw_input, copen -logger = logging.getLogger(__name__) - +LOGGER = logging.getLogger(__name__) TEMPLATE_SUPPORT = False try: import jinja2 @@ -22,7 +21,7 @@ def tmpl_env(paths): return jinja2.Environment(loader=jinja2.FileSystemLoader(paths)) except ImportError: - logger.warn("Jinja2 is not available on your system, so " + LOGGER.warn("Jinja2 is not available on your system, so " "template support will be disabled.") class TemplateNotFound(RuntimeError):