Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def executor(f):
- def wrapper(self, *args, **kwargs):
- f(self)
- command = args[0]
- getattr(self, command)(*args[1:], **kwargs)
- return wrapper
- class Commands:
- def __init__(self):
- self.voda_v_kastrule = False
- self.voda_v_chainike = False
- @executor
- def pelmeshki(self):
- self.voda_v_kastrule = not self.voda_v_kastrule
- print('nalit vodu v kastrule' if self.voda_v_kastrule else 'slit vodu from kastrule')
- def svarit(self, count, sol=0):
- print('varim', count)
- print('sol', sol)
- def est(self, count, mayonaze=None):
- print('em', count)
- print('mayonaze', mayonaze)
- @executor
- def chai(self):
- if not self.voda_v_chainike:
- self.voda_v_chainike = True
- print('nalit vodu v chainike')
- def zavarit(self, count, chai_type='chorny'):
- print('zavarit na', count, chai_type)
- c = Commands()
- pipeline = [
- ('pelmeshki', (('svarit', 5), {'sol': '2'})),
- ('pelmeshki', (('est', 4), {'mayonaze': True})),
- ('chai', (('zavarit', 2), {'chai_type': 'zeleny'})),
- ]
- for action in pipeline:
- getattr(c, action[0])(*action[1][0], **action[1][1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement