# 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 ChangesFileException(DputError):
#     """
#     Thrown when there's an error processing / verifying a .changes file
#     (most often via the :class:`dput.changes.Changes` object)
#     """
# 
#     def __init__(self, message, gpg_stderr=None):
#         super(ChangesFileException, self).__init__(message)
#         self.gpg_stderr = gpg_stderr
# 
# 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


import os
import subprocess
import dput.changes
from dput.core import logger
from dput.exceptions import (ChangesFileException, HookException)
                        "allow_unsigned_uploads being set.")
            return

    gpg = {}
    if 'gpg' in profile:
        gpg = profile['gpg']

    try:
        key = changes.validate_signature()
    except ChangesFileException as e:
        # Sign unsigned files using debsign:
        changes_file = changes.get_changes_file()
        if subprocess.call(['debsign', changes_file]) == 0:
            changes = dput.changes.parse_changes_file(
                changes_file,
                os.path.dirname(changes_file)
            )
        try:
            key = changes.validate_signature()
        except ChangesFileException as e:
            if e.gpg_stderr:
                print(e.gpg_stderr)
            raise e

    if 'allowed_keys' in gpg:
        allowed_keys = gpg['allowed_keys']

        found = False
        for k in allowed_keys:
            if k == key[-len(k):]:

# 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 ChangesFileException(DputError):
#     """
#     Thrown when there's an error processing / verifying a .changes file
#     (most often via the :class:`dput.changes.Changes` object)
#     """
# 
#     def __init__(self, message, gpg_stderr=None):
#         super(ChangesFileException, self).__init__(message)
#         self.gpg_stderr = gpg_stderr
# 
# 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/hooks/gpg.py
import os
import subprocess
import dput.changes
from dput.core import logger
from dput.exceptions import (ChangesFileException, HookException)

                        "allow_unsigned_uploads being set.")
            return

    gpg = {}
    if 'gpg' in profile:
        gpg = profile['gpg']

    try:
        key = changes.validate_signature()
    except ChangesFileException as e:
        # Sign unsigned files using debsign:
        changes_file = changes.get_changes_file()
        if subprocess.call(['debsign', changes_file]) == 0:
            changes = dput.changes.parse_changes_file(
                changes_file,
                os.path.dirname(changes_file)
            )
        try:
            key = changes.validate_signature()
        except ChangesFileException as e:
            if e.gpg_stderr:
                print(e.gpg_stderr)
            raise e

    if 'allowed_keys' in gpg:
        allowed_keys = gpg['allowed_keys']

        found = False
        for k in allowed_keys:
            if k == key[-len(k):]:

                logger.info("Key %s is trusted to upload to this host." % (