# 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/util.py
# def load_config(config_class, config_name,
#                 default=None, configs=None, config_cleanup=True):
#     """
#     Load any dput configuration given a ``config_class`` (such as
#     ``hooks``), and a ``config_name`` (such as
#     ``lintian`` or ``tweet``).
# 
#     Optional kwargs:
# 
#         ``default`` is a default to return, in case the config file
#         isn't found. If this isn't provided, this function will
#         raise a :class:`dput.exceptions.NoSuchConfigError`.
# 
#         ``configs`` is a list of config files to check. When this
#         isn't provided, we check dput.core.CONFIG_LOCATIONS.
#     """
# 
#     logger.debug("Loading configuration: %s %s" % (
#         config_class,
#         config_name
#     ))
#     roots = []
#     ret = {}
#     found = False
#     template_path = "%s/%s/%s.json"
#     locations = configs or dput.core.CONFIG_LOCATIONS
#     for config in locations:
#         logger.trace("Checking for configuration: %s" % (config))
#         path = template_path % (
#             config,
#             config_class,
#             config_name
#         )
#         logger.trace("Checking - %s" % (path))
#         try:
#             if os.path.exists(path):
#                 found = True
#                 roots.append(path)
#                 ret.update(json.load(open(path, 'r')))
#         except ValueError as e:
#             raise DputConfigurationError("syntax error in %s: %s" % (
#                 path, e
#             ))
# 
#     if not found:
#         if default is not None:
#             return default
# 
#         raise NoSuchConfigError("No such config: %s/%s" % (
#             config_class,
#             config_name
#         ))
# 
#     if 'meta' in ret and (
#         config_class != 'metas' or
#         ret['meta'] != config_name
#     ):
#         metainfo = load_config(
#             "metas",
#             ret['meta'],
#             default={}
#         )  # configs=configs)
#         # Erm, is this right? For some reason, I don't think it is. Meta
#         # handling is a hemorrhoid in my ass. Fuck it, it works. Ship it.
#         #   -- PRT
#         for key in metainfo:
#             if not key in ret:
#                 ret[key] = metainfo[key]
#             else:
#                 logger.trace("Ignoring key %s for %s (%s)" % (
#                     key,
#                     ret['meta'],
#                     metainfo[key]
#                 ))
# 
#     obj = ret
#     if config_cleanup:
#         obj = _config_cleanup(ret)
# 
#     if obj != {}:
#         return obj
# 
#     if default is not None:
#         return default
# 
#     logger.debug("Failed to load configuration %s" % (config_name))
# 
#     nsce = NoSuchConfigError("No such configuration: '%s' in class '%s'" % (
#         config_name,
#         config_class
#     ))
# 
#     nsce.config_class = config_class
#     nsce.config_name = config_name
#     nsce.checked = dput.core.CONFIG_LOCATIONS
#     raise nsce
# 
# Path: dput/exceptions.py
# class HookException(DputError):
#     """
#     Thrown when there's an error checking, or creating a checker. Usually
#     thrown by a checker invoked by :class:`dput.checker.run_hooks`.
#     """
#     pass
# 
# Path: dput/interface.py
# BUTTON_NO = "no"


import re
from dput.core import logger
from dput.util import load_config
from dput.exceptions import HookException
from dput.interface import BUTTON_NO
    The ``protected distributions`` checker is a stock dput checker that makes
    sure, users intending an upload for a special care archive (
    testing-proposed-updates, stable-security, etc.) did really follow the
    archive policies for that.

    Profile key: none

    """
    # XXX: This check does not contain code names yet. We need a global way
    #      to retrieve and share current code names.
    suite = changes['Distribution']
    query_user = False
    release_team_suites = ["testing-proposed-updates", "proposed-updates",
                           "oldstable", "stable", "testing"]
    if suite in release_team_suites:
        msg = "Are you sure to upload to %s? Did you coordinate with the " \
            "Release Team before your upload?" % (suite)
        error_msg = "Aborting upload to Release Team managed suite upon " \
            "request"
        query_user = True
    security_team_suites = ["stable-security", "oldstable-security",
                            "testing-security"]
    if suite in security_team_suites:
        msg = "Are you sure to upload to %s? Did you coordinate with the " \
            "Security Team before your upload?" % (suite)
        error_msg = "Aborting upload to Security Team managed suite upon " \
            "request"
        query_user = True

    if query_user:

# 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/util.py
# def load_config(config_class, config_name,
#                 default=None, configs=None, config_cleanup=True):
#     """
#     Load any dput configuration given a ``config_class`` (such as
#     ``hooks``), and a ``config_name`` (such as
#     ``lintian`` or ``tweet``).
# 
#     Optional kwargs:
# 
#         ``default`` is a default to return, in case the config file
#         isn't found. If this isn't provided, this function will
#         raise a :class:`dput.exceptions.NoSuchConfigError`.
# 
#         ``configs`` is a list of config files to check. When this
#         isn't provided, we check dput.core.CONFIG_LOCATIONS.
#     """
# 
#     logger.debug("Loading configuration: %s %s" % (
#         config_class,
#         config_name
#     ))
#     roots = []
#     ret = {}
#     found = False
#     template_path = "%s/%s/%s.json"
#     locations = configs or dput.core.CONFIG_LOCATIONS
#     for config in locations:
#         logger.trace("Checking for configuration: %s" % (config))
#         path = template_path % (
#             config,
#             config_class,
#             config_name
#         )
#         logger.trace("Checking - %s" % (path))
#         try:
#             if os.path.exists(path):
#                 found = True
#                 roots.append(path)
#                 ret.update(json.load(open(path, 'r')))
#         except ValueError as e:
#             raise DputConfigurationError("syntax error in %s: %s" % (
#                 path, e
#             ))
# 
#     if not found:
#         if default is not None:
#             return default
# 
#         raise NoSuchConfigError("No such config: %s/%s" % (
#             config_class,
#             config_name
#         ))
# 
#     if 'meta' in ret and (
#         config_class != 'metas' or
#         ret['meta'] != config_name
#     ):
#         metainfo = load_config(
#             "metas",
#             ret['meta'],
#             default={}
#         )  # configs=configs)
#         # Erm, is this right? For some reason, I don't think it is. Meta
#         # handling is a hemorrhoid in my ass. Fuck it, it works. Ship it.
#         #   -- PRT
#         for key in metainfo:
#             if not key in ret:
#                 ret[key] = metainfo[key]
#             else:
#                 logger.trace("Ignoring key %s for %s (%s)" % (
#                     key,
#                     ret['meta'],
#                     metainfo[key]
#                 ))
# 
#     obj = ret
#     if config_cleanup:
#         obj = _config_cleanup(ret)
# 
#     if obj != {}:
#         return obj
# 
#     if default is not None:
#         return default
# 
#     logger.debug("Failed to load configuration %s" % (config_name))
# 
#     nsce = NoSuchConfigError("No such configuration: '%s' in class '%s'" % (
#         config_name,
#         config_class
#     ))
# 
#     nsce.config_class = config_class
#     nsce.config_name = config_name
#     nsce.checked = dput.core.CONFIG_LOCATIONS
#     raise nsce
# 
# Path: dput/exceptions.py
# class HookException(DputError):
#     """
#     Thrown when there's an error checking, or creating a checker. Usually
#     thrown by a checker invoked by :class:`dput.checker.run_hooks`.
#     """
#     pass
# 
# Path: dput/interface.py
# BUTTON_NO = "no"


# Path: dput/hooks/distribution.py
import re
from dput.core import logger
from dput.util import load_config
from dput.exceptions import HookException
from dput.interface import BUTTON_NO

    The ``protected distributions`` checker is a stock dput checker that makes
    sure, users intending an upload for a special care archive (
    testing-proposed-updates, stable-security, etc.) did really follow the
    archive policies for that.

    Profile key: none

    """
    # XXX: This check does not contain code names yet. We need a global way
    #      to retrieve and share current code names.
    suite = changes['Distribution']
    query_user = False
    release_team_suites = ["testing-proposed-updates", "proposed-updates",
                           "oldstable", "stable", "testing"]
    if suite in release_team_suites:
        msg = "Are you sure to upload to %s? Did you coordinate with the " \
            "Release Team before your upload?" % (suite)
        error_msg = "Aborting upload to Release Team managed suite upon " \
            "request"
        query_user = True
    security_team_suites = ["stable-security", "oldstable-security",
                            "testing-security"]
    if suite in security_team_suites:
        msg = "Are you sure to upload to %s? Did you coordinate with the " \
            "Security Team before your upload?" % (suite)
        error_msg = "Aborting upload to Security Team managed suite upon " \
            "request"
        query_user = True

    if query_user:

        logger.trace("Querying the user for input. The upload targets a "