This repository has been archived by the owner on Mar 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
BuyerInterface.py
69 lines (62 loc) · 2.42 KB
/
BuyerInterface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import abc
from abc import ABCMeta, abstractmethod
from ThreadSafeCounter import ThreadSafeCounter
class BuyerInterface(metaclass=abc.ABCMeta):
@classmethod
def __subclasshook__(cls, subclass):
return (hasattr(subclass, 'try_authenticate')
and callable(subclass.try_authenticate)
and hasattr(subclass, 'try_buy_item')
and callable(subclass.try_buy_item)
and hasattr(subclass, '__del__')
and callable(subclass.__del__)
and hasattr(subclass, '__enter__')
and callable(subclass.__enter__)
and hasattr(subclass, '__exit__')
and callable(subclass.__exit__)
and hasattr(subclass, 'is_authenticated')
and not callable(subclass.is_authenticated)
and hasattr(subclass, 'item_counter')
and not callable(subclass.item_counter)
and hasattr(subclass, 'max_buy_count')
and not callable(subclass.max_buy_count)
and hasattr(subclass, 'item_indice')
and not callable(subclass.item_indice)
and hasattr(subclass, 'item_name')
and not callable(subclass.item_name)
and hasattr(subclass, 'BUYER_NAME')
and not callable(subclass.BUYER_NAME))
#@abc.abstractmethod
@abstractmethod
def __init__(self,
chrome_driver_path: str,
item_indice : int,
item_name: str,
max_buy_count: int,
max_cost_per_item: float,
item_counter: ThreadSafeCounter,
max_retry_limit: int,
timeout_in_seconds: int,
is_test_run: bool):
self.chrome_driver_path = chrome_driver_path
self.item_indice = item_indice
self.item_name = item_name
self.max_buy_count = max_buy_count
self.max_cost_per_item = max_cost_per_item
self.item_counter = item_counter
self.max_retry_limit = max_retry_limit
self.timeout_in_seconds = timeout_in_seconds
self.is_test_run = is_test_run
self.retry_counter = 0
@abstractmethod
def try_authenticate() -> bool:
pass
@abstractmethod
def try_buy_item() -> bool:
pass
@abstractmethod
def __enter__():
pass
@abstractmethod
def __exit__():
pass