-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.py
112 lines (90 loc) · 1.97 KB
/
models.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from dataclasses import dataclass
from datetime import datetime
from typing import Callable
from pathier import Pathier
root = Pathier(__file__).parent
@dataclass
class Company:
"""
Fields:
* id: int
* name: str
* date_added: datetime
"""
id: int = -1
name: str = ""
date_added: datetime = datetime.now()
@dataclass
class Board:
"""
Fields:
* company: models.Company
* id: int
* url: str
* active: bool
* date_added: datetime
"""
company: Company
id: int = -1
url: str = ""
active: bool = True
date_added: datetime = datetime.now()
@dataclass
class Listing:
"""
Fields:
* company: models.Company
* id: int
* position: str
* location: str
* url: str
* alive: bool
* date_added: datetime
* date_removed: datetime | None
"""
company: Company
id: int = -1
position: str = ""
location: str = ""
url: str = ""
alive: bool = True
date_added: datetime = datetime.now()
date_removed: datetime | None = None
def __post_init__(self):
self.alive = bool(self.alive)
def prune_strings(self):
"""Remove extra whitespaces from `self.position` and `self.location` strings."""
prune: Callable[[str], str] = lambda s: " ".join(s.strip().split())
self.position = prune(self.position)
self.location = prune(self.location)
@dataclass
class Application:
"""
Fields:
* listing: models.Listing
* id: int
* date_applied: datetime
"""
listing: Listing
id: int = -1
date_applied: datetime = datetime.now()
@dataclass
class Rejection:
"""
Fields:
* application: Application
* id: int
* date_rejected: datetime
"""
application: Application
id: int = -1
date_rejected: datetime = datetime.now()
@dataclass
class Scraper:
"""
Fields:
* company: models.Company
* board: models.Board
"""
company: Company
board: Board