"""
Configuration
=============

Simple module for loading pywincffi's configuration, intended
for internal use. A configuration file which is reasonable for
every day use ships with pywincffi but can be overridden at
runtime by dropping a file named ``pywincffi.ini`` in the
current working directory or the current users's home directory.
"""

import logging
from os.path import join, expanduser

try:
    from configparser import RawConfigParser
except ImportError:
    # pylint: disable=wrong-import-order,import-error
    from ConfigParser import RawConfigParser

from pkg_resources import resource_filename

from pywincffi.exceptions import ConfigurationError


class Configuration(RawConfigParser):
    """
    Class responsible for loading and retrieving
    data from the configuration files.  This is used
    by a few parts of pywincffi to control various aspects
    of execution.
    """
    # NOTE: This list is documented in the module's documentation.
    FILES = (
        resource_filename("pywincffi", join("core", "pywincffi.ini")),
        expanduser(join("~", "pywincffi.ini")),
        "pywincffi.ini"
    )
    LOGGER_LEVEL_MAPPINGS = {
        "notset": logging.NOTSET,
        "debug": logging.DEBUG,
        "warning": logging.WARNING,
        "info": logging.INFO,
        "error": logging.ERROR,
        "critical": logging.CRITICAL
    }

    def __init__(self):
        super(Configuration, self).__init__()
        self.load()

    def load(self):
        """Loads the configuration from disk"""
        self.clear()
        self.read(self.FILES)

    def precompiled(self):
        """
        Returns True if the configuration states that we should be using
        the precompiled library rather than trying to compile inline.
        """
        return self.get("pywincffi", "library") == "precompiled"

    def logging_level(self):
        """
        Returns the logging level that the configuration currently
        dictates.
        """
        level = self.get("pywincffi", "log_level")

        if level not in self.LOGGER_LEVEL_MAPPINGS:
            raise ConfigurationError(
                "Invalid level %s, valid levels are %s" % (
                    level, " ".join(self.LOGGER_LEVEL_MAPPINGS.keys())))

        return self.LOGGER_LEVEL_MAPPINGS[level]

config = Configuration()  # pylint: disable=invalid-name

@@ -390,16 +390,36 @@
 panduser
+%0Afrom six import PY2
 %0A%0Atry:%0A 
@@ -1398,32 +1398,156 @@
 __init__(self):%0A
+        if PY2:%0A            Configuration.__init__(self)%0A        else:%0A            # pylint: disable=super-on-old-class%0A    
         super(Co
@@ -1576,16 +1576,17 @@
 nit__()%0A
+%0A
         

fix init call for Python 2