from production.box._OrderChangerProductionBox import OrderChangerProductionBox

from ._AllowedForbiddenFilter import AllowedForbiddenFilter


class TagFilterBox(OrderChangerProductionBox):
    def __init__(
        self,
        name,
        sons,
        allowed_tags,
        forbidden_tags,
        allow_combos,
        inherit_comments,
        logger=None
    ):
        super(TagFilterBox, self).__init__(name, sons, logger)
        self.filter = AllowedForbiddenFilter(
            allowed_values=allowed_tags,
            forbidden_values=forbidden_tags,
            keep_son_parts=allow_combos,
            inherit_comments=inherit_comments,
        )

    def change_order(self, order):
        order = self.filter.filter_items(order, lambda x: x.get_tags())
        return order
