File size: 425 Bytes
dbe7b05
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from typing import Optional
from abc import ABC, abstractmethod

class CommandHandler(ABC):
    def __init__(self, successor: Optional["CommandHandler"] = None):
        self.successor = successor

    def handle_command(self, command):
        if self.successor:
            self.successor.handle_command(command)

    @abstractmethod
    def execute_command(self):
        """Method of processing command execution logic"""