# 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/interface.py
# class AbstractInterface(object):
#     """
#     Abstract base class for Concrete implementations of user interfaces.
# 
#     The invoking process will instantiate the process, call initialize,
#     query (any number of times), and shutdown.
#     """
# 
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def initialize(self, **kwargs):
#         """
#         Set up the interface state.
#         """
#         pass
# 
#     def boolean(self, title, message, question_type=BUTTON_YES_NO,
#                 default=None):
#         """
#         Display a question returning a boolean value. This is evaluated
#         by checking the button return code either to be BUTTON_YES or
#         BUTTON_OK
#         """
#         self.widget_type = WIDGET_BOOLEAN
#         self.message = message
#         self.question_type = question_type
#         self.default = default
# 
#     def message(self, title, message, question_type=BUTTON_OK):
#         """
#         Display a message and a confirmation button when required by the
#         interface to make sure the user noticed the message Some interfaces,
#         e.g. the CLI may ignore the button.
#         """
#         self.widget_type = WIDGET_MESSAGE
#         self.message = message
#         self.question_type = question_type
# 
#     def list(self, title, message, selections=[]):
#         """
#         Display a list of alternatives the user can choose from, returns a
#         list of selections.
#         """
#         self.widget_type = WIDGET_LIST
#         self.message = message
#         self.selection = selections
# 
#     def question(self, title, message, echo_input=True):
#         """
#         Query for user input. The input is returned literally
#         """
#         self.widget_type = WIDGET_QUESTION
#         self.message = message
#         self.echo_input = True
# 
#     def password(self, title, message):
#         """
#         Query for user input. The input is returned literally but not printed
#         back. This is a shortcut to
#         :meth:`dput.interface.AbstractInterface.question` with echo_input
#         defaulting to False
#         """
#         self.question(title, message, echo_input=False)
# 
#     @abc.abstractmethod
#     def shutdown(self):
#         """
#         Get rid of everything, close out.
#         """
#         pass
# 
# ALL_BUTTONS = [BUTTON_YES, BUTTON_NO, BUTTON_CANCEL, BUTTON_OK]
# 
# BUTTON_YES_NO = [BUTTON_YES, BUTTON_NO]
# 
# BUTTON_OK = "ok"
# 
# BUTTON_YES = "yes"


import sys
import getpass
from dput.core import logger
from dput.interface import (AbstractInterface, ALL_BUTTONS, BUTTON_YES_NO,
                            BUTTON_OK, BUTTON_YES)

    def button_to_str(self, button):
        """
        Translate a button name to it's label value.
        """
        for item in ALL_BUTTONS:
            if item == button:
                return item
        assert(False)

    def str_to_button(self, str_button, default):
        """
        Translate a string input to a button known to the interface. In case
        of the CLI interface there is no straight notion of a button, so this
        is abstracted by expected data input treated as button.

        This method guesses based on the supplied argument and the supplied
        default value, which button the user meant in 'Do you wanna foo [y/N]?'
        situations.
        """
        str_button = str_button.lower()
        # return default when no input was supplied
        if default and not str_button:
            return default
        # compare literally
        if str_button in ALL_BUTTONS:
            return str_button
        # guess input button until only one choice is left or the outcome is
        # known to be ambiguous
        for index in range(0, len(str_button) + 1):

# 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/interface.py
# class AbstractInterface(object):
#     """
#     Abstract base class for Concrete implementations of user interfaces.
# 
#     The invoking process will instantiate the process, call initialize,
#     query (any number of times), and shutdown.
#     """
# 
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def initialize(self, **kwargs):
#         """
#         Set up the interface state.
#         """
#         pass
# 
#     def boolean(self, title, message, question_type=BUTTON_YES_NO,
#                 default=None):
#         """
#         Display a question returning a boolean value. This is evaluated
#         by checking the button return code either to be BUTTON_YES or
#         BUTTON_OK
#         """
#         self.widget_type = WIDGET_BOOLEAN
#         self.message = message
#         self.question_type = question_type
#         self.default = default
# 
#     def message(self, title, message, question_type=BUTTON_OK):
#         """
#         Display a message and a confirmation button when required by the
#         interface to make sure the user noticed the message Some interfaces,
#         e.g. the CLI may ignore the button.
#         """
#         self.widget_type = WIDGET_MESSAGE
#         self.message = message
#         self.question_type = question_type
# 
#     def list(self, title, message, selections=[]):
#         """
#         Display a list of alternatives the user can choose from, returns a
#         list of selections.
#         """
#         self.widget_type = WIDGET_LIST
#         self.message = message
#         self.selection = selections
# 
#     def question(self, title, message, echo_input=True):
#         """
#         Query for user input. The input is returned literally
#         """
#         self.widget_type = WIDGET_QUESTION
#         self.message = message
#         self.echo_input = True
# 
#     def password(self, title, message):
#         """
#         Query for user input. The input is returned literally but not printed
#         back. This is a shortcut to
#         :meth:`dput.interface.AbstractInterface.question` with echo_input
#         defaulting to False
#         """
#         self.question(title, message, echo_input=False)
# 
#     @abc.abstractmethod
#     def shutdown(self):
#         """
#         Get rid of everything, close out.
#         """
#         pass
# 
# ALL_BUTTONS = [BUTTON_YES, BUTTON_NO, BUTTON_CANCEL, BUTTON_OK]
# 
# BUTTON_YES_NO = [BUTTON_YES, BUTTON_NO]
# 
# BUTTON_OK = "ok"
# 
# BUTTON_YES = "yes"


# Path: dput/interfaces/cli.py
import sys
import getpass
from dput.core import logger
from dput.interface import (AbstractInterface, ALL_BUTTONS, BUTTON_YES_NO,
                            BUTTON_OK, BUTTON_YES)


    def button_to_str(self, button):
        """
        Translate a button name to it's label value.
        """
        for item in ALL_BUTTONS:
            if item == button:
                return item
        assert(False)

    def str_to_button(self, str_button, default):
        """
        Translate a string input to a button known to the interface. In case
        of the CLI interface there is no straight notion of a button, so this
        is abstracted by expected data input treated as button.

        This method guesses based on the supplied argument and the supplied
        default value, which button the user meant in 'Do you wanna foo [y/N]?'
        situations.
        """
        str_button = str_button.lower()
        # return default when no input was supplied
        if default and not str_button:
            return default
        # compare literally
        if str_button in ALL_BUTTONS:
            return str_button
        # guess input button until only one choice is left or the outcome is
        # known to be ambiguous
        for index in range(0, len(str_button) + 1):

            buttons = [count for count in ALL_BUTTONS if