# Path: dput/command.py
# class AbstractCommand(object):
#     """
#     Abstract base class for all concrete dcut command implementations.
#     """
# 
#     __metaclass__ = abc.ABCMeta
# 
#     def __init__(self, interface):
#         self.cmd_name = None
#         self.cmd_purpose = None
#         self.interface = interface
# 
#     @abc.abstractmethod
#     def register(self, parser, **kwargs):
#         pass
# 
#     @abc.abstractmethod
#     def produce(self, fh, args):
#         pass
# 
#     @abc.abstractmethod
#     def validate(self, args):
#         pass
# 
#     @abc.abstractmethod
#     def name_and_purpose(self):
#         pass
# 
#     @abc.abstractmethod
#     def generate_commands_name(self, profile):
#         pass
# 
# Path: dput/exceptions.py
# class DcutError(Exception):
#     pass
# 
# Path: dput/commands/dm.py
# def generate_dak_commands_name(profile):
#     # for debianqueued: $login-$timestamp.commands
#     # for dak: $login-$timestamp.dak-commands
#     the_file = "%s-%s.dak-commands" % (get_local_username(), int(time.time()))
#     # XXX: override w/ DEBEMAIL (if DEBEMAIL is @debian.org?)
#     logger.trace("Commands file will be named %s" % (the_file))
#     return the_file
# 
# Path: dput/interface.py
# BUTTON_NO = "no"


from dput.command import AbstractCommand
from dput.exceptions import DcutError
from dput.commands.dm import generate_dak_commands_name
from dput.interface import BUTTON_NO

class BreakTheArchiveCommand(AbstractCommand):
    def __init__(self, interface):
        super(BreakTheArchiveCommand, self).__init__(interface)
        self.cmd_name = "break-the-archive"
        self.cmd_purpose = "break the archive (no, really)"

    def generate_commands_name(self, profile):
        return generate_dak_commands_name(profile)

    def register(self, parser, **kwargs):
        pass

    def produce(self, fh, args):
        fh.write("\n")  # yes, this newline matters
        fh.write("Action: %s\n" % (self.cmd_name))

    def validate(self, args):
        if args.force:
            return
        self.interface.message(
            'WARNING: Dangerous command',
            "Break the archive is totally dangerous! Make sure you know "
            "what you are doing before proceeding."
        )

        if not self.interface.boolean(
            'Break the Archive command',
            "Do you really want to break the archive?",
            default=BUTTON_NO

# Path: dput/command.py
# class AbstractCommand(object):
#     """
#     Abstract base class for all concrete dcut command implementations.
#     """
# 
#     __metaclass__ = abc.ABCMeta
# 
#     def __init__(self, interface):
#         self.cmd_name = None
#         self.cmd_purpose = None
#         self.interface = interface
# 
#     @abc.abstractmethod
#     def register(self, parser, **kwargs):
#         pass
# 
#     @abc.abstractmethod
#     def produce(self, fh, args):
#         pass
# 
#     @abc.abstractmethod
#     def validate(self, args):
#         pass
# 
#     @abc.abstractmethod
#     def name_and_purpose(self):
#         pass
# 
#     @abc.abstractmethod
#     def generate_commands_name(self, profile):
#         pass
# 
# Path: dput/exceptions.py
# class DcutError(Exception):
#     pass
# 
# Path: dput/commands/dm.py
# def generate_dak_commands_name(profile):
#     # for debianqueued: $login-$timestamp.commands
#     # for dak: $login-$timestamp.dak-commands
#     the_file = "%s-%s.dak-commands" % (get_local_username(), int(time.time()))
#     # XXX: override w/ DEBEMAIL (if DEBEMAIL is @debian.org?)
#     logger.trace("Commands file will be named %s" % (the_file))
#     return the_file
# 
# Path: dput/interface.py
# BUTTON_NO = "no"


# Path: dput/commands/breakthearchive.py
from dput.command import AbstractCommand
from dput.exceptions import DcutError
from dput.commands.dm import generate_dak_commands_name
from dput.interface import BUTTON_NO


class BreakTheArchiveCommand(AbstractCommand):
    def __init__(self, interface):
        super(BreakTheArchiveCommand, self).__init__(interface)
        self.cmd_name = "break-the-archive"
        self.cmd_purpose = "break the archive (no, really)"

    def generate_commands_name(self, profile):
        return generate_dak_commands_name(profile)

    def register(self, parser, **kwargs):
        pass

    def produce(self, fh, args):
        fh.write("\n")  # yes, this newline matters
        fh.write("Action: %s\n" % (self.cmd_name))

    def validate(self, args):
        if args.force:
            return
        self.interface.message(
            'WARNING: Dangerous command',
            "Break the archive is totally dangerous! Make sure you know "
            "what you are doing before proceeding."
        )

        if not self.interface.boolean(
            'Break the Archive command',
            "Do you really want to break the archive?",
            default=BUTTON_NO

        ):