Created
March 12, 2022 18:18
-
-
Save valeria-aynbinder-edu/1c08ff03b64f1b45be319278d3a829fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
class Bank: | |
def __init__(self, bank_name): | |
self.name = bank_name | |
''' | |
Perform validation that the operation is being performed | |
during working hours only: Sun - Thu, 09:00 - 17:00 | |
''' | |
def working_hours_only(callable): | |
def wrapped_callable(*args, **kwargs): | |
x = datetime.datetime.today() | |
if x.strftime("%a") in ['Sun','Mon','Tue','Wed','Thu'] and 17 > int(x.strftime("%H")) > 9 : | |
ret_val = callable(*args, **kwargs) | |
return ret_val | |
else: | |
raise Exception("Outside working hours") | |
return wrapped_callable | |
@working_hours_only | |
def withdraw(self, amount): | |
print("Called withdraw", amount) | |
return amount | |
@working_hours_only | |
def deposit(self, amount): | |
print("Called deposit") | |
def feedback(self, fedback_text): | |
print("Called feedback") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment