-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomClasses.py
More file actions
171 lines (160 loc) · 5.72 KB
/
CustomClasses.py
File metadata and controls
171 lines (160 loc) · 5.72 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from enum import Enum
# Enum to represent the status of an application
class AppStatus(str, Enum):
NOAPP = 'NOAPP'
APP = 'APP'
REJ = 'REJ'
MORE = 'MORE'
INTV = 'INTV'
# Enum to represent the sector of a given company
class SectorType(str, Enum):
Energy = 'Energy'
Materials = 'Materials'
Industrials = 'Industrials'
Utilities = 'Utilities'
Healthcare = 'Healthcare'
Financials = 'Financials'
Misc = 'Consumer Discretionary'
Staples = 'Consumer Staples'
Info = 'Information Technology'
Communication = 'Communication Services'
Real = 'Real Estate'
# Function to map the given argument for sector to its SectorType enum
# Energy = 'Energy'
# Materials = 'Materials'
# Industrials = 'Industrials'
# Utilities = 'Utilities'
# Healthcare = 'Healthcare'
# Financials = 'Financials'
# Misc = 'Consumer Discretionary'
# Staples = 'Consumer Staples'
# Info = 'Information Technology'
# Communication = 'Communication Services'
# Real = 'Real Estate'
def parseSector(given):
match given:
case 'Energy':
return SectorType.Energy
case 'Materials':
return SectorType.Materials
case 'Industrials':
return SectorType.Industrials
case 'Utilities':
return SectorType.Utilities
case 'Healthcare':
return SectorType.Healthcare
case 'Health Care':
return SectorType.Healthcare
case 'Financials':
return SectorType.Financials
case 'Misc':
return SectorType.Misc
case 'Consumer Discretionary':
return SectorType.Misc
case 'Staples':
return SectorType.Staples
case 'Consumer Staples':
return SectorType.Staples
case 'Info':
return SectorType.Info
case 'Information Technology':
return SectorType.Info
case 'Communication':
return SectorType.Communication
case 'Communication Services':
return SectorType.Communication
case 'Real':
return SectorType.Real
case 'Real Estate':
return SectorType.Real
case default:
print('Unable to parse sector')
return None
# Class to represent a company
class Company:
def __init__(self, name, sector, symbol, snP):
self.Name = name
# check that given sector is one of the defined sectors
if not isinstance(sector, SectorType):
print('Sector must be a SectorType')
return
self.Sector = sector
# check that symbol is not a string > 5 in length
if len(symbol) > 5:
print('Symbol must be 5 characters or less')
return
self.Symbol = symbol
# check that snP is a boolean
if not isinstance(snP, bool):
print('snP status must be a boolean')
return
self.SnP = snP
self.Apps = set()
# Override default equals function
def __eq__(self, other):
if isinstance(other, Company):
names = self.Name == other.Name
sectors = self.Sector == other.Sector
symbols = self.Symbol == other.Symbol
snP = self.SnP == other.SnP
if names and sectors and symbols and snP:
return True
return False
# Override default hash function
def __hash__(self):
return hash(self.Name) + hash(self.Sector) + hash(self.Symbol) + hash(self.SnP)
# Enum to represent the medium used to apply to a company
class AppMedium(str, Enum):
Linkedin = 'Linkedin'
NUWorks = 'NUWorks'
Website = 'Company website'
# Function to parse the argument for application medium
# Returns null if unable to parse given medium
def parseMedium(given):
match given:
case 'L': return AppMedium.Linkedin
case 'LinkedIn': return AppMedium.Linkedin
case 'Linkedin': return AppMedium.Linkedin
case 'W': return AppMedium.Website
case 'Website': return AppMedium.Website
case 'N': return AppMedium.NUWorks
case 'NUWorks': return AppMedium.NUWorks
case default:
print('Unable to parse medium')
return None
# Class to represent an application to a company
# Coop is true if applied for a co-op; false for internship
# Cyber is true if potential for a cybersecurity role; false for straight CS
# Medium is the way you applied, i.e. NUWorks, Linkedin, website, etc.
class Application:
def __init__(self, companySymbol, position, coop, cyber, date, medium):
self.CompanySymbol = companySymbol
self.Position = position
if not isinstance(coop, bool):
print('coop status must be a boolean')
return
self.Coop = coop
if not isinstance(cyber, bool):
print('cyber status must be a boolean')
return
self.Cyber = cyber
self.Status = AppStatus.APP
self.Date = date
if not isinstance(medium, AppMedium):
print('Medium must be a valid medium')
return
self.Medium = medium
# Override default equals function
def __eq__(self, other):
if isinstance(other, Application):
positions = self.Position == other.Position
companies = self.CompanySymbol == other.CompanySymbol
coops = self.Coop == other.Coop
cybers = self.Cyber == other.Cyber
mediums = self.Medium == other.Medium
if positions and companies and coops and cybers and mediums:
return True
return False
# Override default hash function
def __hash__(self):
return hash(self.Position) + hash(self.CompanySymbol) + hash(self.Coop)