from logging import Logger
from typing import Dict

from production.box import RemoveReprocessedOrdersBox
from production.command import ProductionCommandProcessor
from production.treebuilder import BoxConfiguration

from ._BoxBuilder import BoxBuilder


class RemoveReprocessedOrdersBoxBuilder(BoxBuilder):
    def __init__(
        self,
        command_processor,  # type: ProductionCommandProcessor
        loggers,            # type: Dict[unicode, Logger]
    ):
        # type: (...) -> None

        super(RemoveReprocessedOrdersBoxBuilder, self).__init__(loggers)

        self.command_processor = command_processor

    def build(self, config):
        # type: (BoxConfiguration) -> RemoveReprocessedOrdersBox
        
        return RemoveReprocessedOrdersBox(
            name=config.name,
            sons=config.sons,
            command_processor=self.command_processor,
            reprocessed_time_limit=self.get_extra(config, "ReprocessedTimeLimit", None),
            logger=self.get_logger(config),
        )
