# Path: dput/config.py
# class AbstractConfig(object):
#     """
#     Abstract Configuration Object. All concrete configuration implementations
#     must subclass this object.
# 
#     Basically, all subclasses are bootstrapped in the same-ish way:
# 
#         * preload
#         * get_defaults
#         * set defaults
#     """
#     __metaclass__ = abc.ABCMeta
# 
#     def __init__(self, configs):
#         self.preload(configs)
#         self.path = ' '.join(configs)
# 
#     @abc.abstractmethod
#     def set_replacements(self, replacements):
#         """
#         """
#         pass  # XXX: DOCUMENT ME.
# 
#     @abc.abstractmethod
#     def get_defaults(self):
#         """
#         Get the defaults that concrete configs get overlaid on top of. In
#         theory, this is set during the bootstrapping process.
#         """
#         pass
# 
#     @abc.abstractmethod
#     def get_config(self, name, ignore_errors=False):
#         """
#         Get a configuration block. What this means is generally up to the
#         implementation. However, please keep things sane and only return
#         sensual upload target blocks.
#         """
#         pass
# 
#     @abc.abstractmethod
#     def get_config_blocks(self):
#         """
#         Get a list of all configuration blocks. Strings in a list.
#         """
#         pass
# 
#     @abc.abstractmethod
#     def preload(self, replacements):
#         """
#         Load all configuration blocks.
#         """
#         pass
# 
# Path: dput/core.py
# CONFIG_LOCATIONS = {
#     "/usr/share/dput-ng/": 30,
#     "/etc/dput.d/": 20,
#     os.path.expanduser("~/.dput.d"): 10,
#     "skel/": 100
# }
# DPUT_CONFIG_LOCATIONS = {
#     "/etc/dput.cf": 15,
#     os.path.expanduser("~/.dput.cf"): 5
# }
# SCHEMA_DIRS = [
#     "/usr/share/dput-ng/schemas",
#     "skel/schemas"
# ]
# def _write_upload_log(logfile, full_log):
# def _enable_debugging(level):
# def mangle_sys():
# def maybe_print_traceback(debug_level, stack):
# def get_local_username():
# 
# Path: dput/exceptions.py
# class DputConfigurationError(DputError):
#     """
#     Errors in the parsing or retrieving of configuration files should raise
#     an instance of this, or a subclass thereof.
#     """
#     pass


import os
import sys
    import configparser
    import ConfigParser as configparser
import dput.core
from dput.config import AbstractConfig
from dput.core import logger
from dput.exceptions import DputConfigurationError

if sys.version_info[0] >= 3:
else:



class DputCfConfig(AbstractConfig):
    """
    dput-old config file implementation. Subclass of a
    :class:`dput.config.AbstractConfig`.
    """

    def preload(self, configs):
        """
        See :meth:`dput.config.AbstractConfig.preload`
        """
        parser = configparser.ConfigParser()
        if configs is None:
            configs = dput.core.DPUT_CONFIG_LOCATIONS

        for config in configs:
            if not os.access(config, os.R_OK):
                logger.debug("Skipping file %s: Not accessible" % (
                    config
                ))
                continue
            try:
                logger.trace("Parsing %s" % (config))
                parser.readfp(open(config, 'r'))
            except IOError as e:

# Path: dput/config.py
# class AbstractConfig(object):
#     """
#     Abstract Configuration Object. All concrete configuration implementations
#     must subclass this object.
# 
#     Basically, all subclasses are bootstrapped in the same-ish way:
# 
#         * preload
#         * get_defaults
#         * set defaults
#     """
#     __metaclass__ = abc.ABCMeta
# 
#     def __init__(self, configs):
#         self.preload(configs)
#         self.path = ' '.join(configs)
# 
#     @abc.abstractmethod
#     def set_replacements(self, replacements):
#         """
#         """
#         pass  # XXX: DOCUMENT ME.
# 
#     @abc.abstractmethod
#     def get_defaults(self):
#         """
#         Get the defaults that concrete configs get overlaid on top of. In
#         theory, this is set during the bootstrapping process.
#         """
#         pass
# 
#     @abc.abstractmethod
#     def get_config(self, name, ignore_errors=False):
#         """
#         Get a configuration block. What this means is generally up to the
#         implementation. However, please keep things sane and only return
#         sensual upload target blocks.
#         """
#         pass
# 
#     @abc.abstractmethod
#     def get_config_blocks(self):
#         """
#         Get a list of all configuration blocks. Strings in a list.
#         """
#         pass
# 
#     @abc.abstractmethod
#     def preload(self, replacements):
#         """
#         Load all configuration blocks.
#         """
#         pass
# 
# Path: dput/core.py
# CONFIG_LOCATIONS = {
#     "/usr/share/dput-ng/": 30,
#     "/etc/dput.d/": 20,
#     os.path.expanduser("~/.dput.d"): 10,
#     "skel/": 100
# }
# DPUT_CONFIG_LOCATIONS = {
#     "/etc/dput.cf": 15,
#     os.path.expanduser("~/.dput.cf"): 5
# }
# SCHEMA_DIRS = [
#     "/usr/share/dput-ng/schemas",
#     "skel/schemas"
# ]
# def _write_upload_log(logfile, full_log):
# def _enable_debugging(level):
# def mangle_sys():
# def maybe_print_traceback(debug_level, stack):
# def get_local_username():
# 
# Path: dput/exceptions.py
# class DputConfigurationError(DputError):
#     """
#     Errors in the parsing or retrieving of configuration files should raise
#     an instance of this, or a subclass thereof.
#     """
#     pass


# Path: dput/configs/dputcf.py
import os
import sys
    import configparser
    import ConfigParser as configparser
import dput.core
from dput.config import AbstractConfig
from dput.core import logger
from dput.exceptions import DputConfigurationError


if sys.version_info[0] >= 3:
else:



class DputCfConfig(AbstractConfig):
    """
    dput-old config file implementation. Subclass of a
    :class:`dput.config.AbstractConfig`.
    """

    def preload(self, configs):
        """
        See :meth:`dput.config.AbstractConfig.preload`
        """
        parser = configparser.ConfigParser()
        if configs is None:
            configs = dput.core.DPUT_CONFIG_LOCATIONS

        for config in configs:
            if not os.access(config, os.R_OK):
                logger.debug("Skipping file %s: Not accessible" % (
                    config
                ))
                continue
            try:
                logger.trace("Parsing %s" % (config))
                parser.readfp(open(config, 'r'))
            except IOError as e:

                logger.warning("Skipping file %s: %s" % (