# 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/cancel.py
# def generate_debianqueued_commands_name(profile):
#     # for debianqueued: $login-$timestamp.commands
#     # for dak: $login-$timestamp.dak-commands
#     the_file = "%s-%s.commands" % (get_local_username(), int(time.time()))
#     logger.trace("Commands file will be named %s" % (the_file))
#     return the_file
# 
# Path: dput/profile.py
# def load_profile(host):
#     """
#     Load a profile, for a given host ``host``. In the case where
#     ``host`` has a ":", that'll be treated as an expansion for
#     config strings. For instance:
# 
#     ``ppa:paultag/fluxbox`` will expand any ``%(ppa)s`` strings to
#     ``paultag/fluxbox``. Comes in super handy.
#     """
#     global _multi_config
# 
#     repls = {}
#     if host and ":" in host:
#         host, arg = host.split(":", 1)
#         repls[host] = arg
# 
#     if _multi_config is None:
#         _multi_config = MultiConfig()
#     config = _multi_config
#     config.set_replacements(repls)
#     configs = config.get_config_blocks()
# 
#     if host in configs:
#         return config.get_config(host)
# 
#     if host is not None:
#         raise DputConfigurationError("Error, was given host, "
#                                      "but we don't know about it.")
# 
#     for block in configs:
#         try:
#             obj = config.get_config(block)
#         except DputConfigurationError:
#             continue  # We don't have fully converted blocks.
# 
#         host_main = obj.get('default_host_main')
#         if host_main:  # If we have a default_host_main, let's return that.
#             return config.get_config(host_main)
#     return config.get_config("ftp-master")


from dput.command import AbstractCommand
from dput.exceptions import DcutError
from dput.commands.cancel import generate_debianqueued_commands_name
from dput.profile import load_profile
                            action='store', default=None, help="distribution "
                            "which rebuild the package for. ", required=True)
        parser.add_argument('-p', '--packages', metavar="PACKAGES",
                            action='store', default=None, help="packages to "
                            "be installed at compile time. ", required=True)

    def produce(self, fh, args):
        fh.write("Commands:\n")
        fh.write("  builddep %s_%s %s %s\n" % (args.source, args.version,
                                               args.distribution,
                                               args.packages))

    def validate(self, args):
        profile = load_profile(args.host)
        if (not 'allow_debomatic_commands' in profile
                or not profile['allow_debomatic_commands']):
            raise DebomaticCommandError(
                "Deb-o-Matic commands not supported for this profile"
            )

    def name_and_purpose(self):
        return (self.cmd_name, self.cmd_purpose)

class KillCommand(AbstractCommand):
    def __init__(self, interface):
        super(KillCommand, self).__init__(interface)
        self.cmd_name = "debomatic-kill"
        self.cmd_purpose = ("kill a build in Deb-o-Matic")

    def generate_commands_name(self, profile):

# 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/cancel.py
# def generate_debianqueued_commands_name(profile):
#     # for debianqueued: $login-$timestamp.commands
#     # for dak: $login-$timestamp.dak-commands
#     the_file = "%s-%s.commands" % (get_local_username(), int(time.time()))
#     logger.trace("Commands file will be named %s" % (the_file))
#     return the_file
# 
# Path: dput/profile.py
# def load_profile(host):
#     """
#     Load a profile, for a given host ``host``. In the case where
#     ``host`` has a ":", that'll be treated as an expansion for
#     config strings. For instance:
# 
#     ``ppa:paultag/fluxbox`` will expand any ``%(ppa)s`` strings to
#     ``paultag/fluxbox``. Comes in super handy.
#     """
#     global _multi_config
# 
#     repls = {}
#     if host and ":" in host:
#         host, arg = host.split(":", 1)
#         repls[host] = arg
# 
#     if _multi_config is None:
#         _multi_config = MultiConfig()
#     config = _multi_config
#     config.set_replacements(repls)
#     configs = config.get_config_blocks()
# 
#     if host in configs:
#         return config.get_config(host)
# 
#     if host is not None:
#         raise DputConfigurationError("Error, was given host, "
#                                      "but we don't know about it.")
# 
#     for block in configs:
#         try:
#             obj = config.get_config(block)
#         except DputConfigurationError:
#             continue  # We don't have fully converted blocks.
# 
#         host_main = obj.get('default_host_main')
#         if host_main:  # If we have a default_host_main, let's return that.
#             return config.get_config(host_main)
#     return config.get_config("ftp-master")


# Path: dput/commands/contrib/debomatic.py
from dput.command import AbstractCommand
from dput.exceptions import DcutError
from dput.commands.cancel import generate_debianqueued_commands_name
from dput.profile import load_profile

                            action='store', default=None, help="distribution "
                            "which rebuild the package for. ", required=True)
        parser.add_argument('-p', '--packages', metavar="PACKAGES",
                            action='store', default=None, help="packages to "
                            "be installed at compile time. ", required=True)

    def produce(self, fh, args):
        fh.write("Commands:\n")
        fh.write("  builddep %s_%s %s %s\n" % (args.source, args.version,
                                               args.distribution,
                                               args.packages))

    def validate(self, args):
        profile = load_profile(args.host)
        if (not 'allow_debomatic_commands' in profile
                or not profile['allow_debomatic_commands']):
            raise DebomaticCommandError(
                "Deb-o-Matic commands not supported for this profile"
            )

    def name_and_purpose(self):
        return (self.cmd_name, self.cmd_purpose)

class KillCommand(AbstractCommand):
    def __init__(self, interface):
        super(KillCommand, self).__init__(interface)
        self.cmd_name = "debomatic-kill"
        self.cmd_purpose = ("kill a build in Deb-o-Matic")

    def generate_commands_name(self, profile):

        return generate_debianqueued_commands_name(profile)