forked from paritoshk/mongodbhackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.py
121 lines (120 loc) · 5.93 KB
/
user.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
113
114
115
116
117
118
119
120
121
from typing import Any
class User:
"""
Represents a comprehensive user profile, including personal, economic, family,
and lifestyle details, as well as geographical information for detailed analysis
of legislative impacts.
Attributes:
name (str): User's full name for personalization of communications.
email (str): User's email for notifications and newsletters.
date_of_birth (str): Used to calculate age and provide age-specific advice.
employment_status (str): User's employment situation (employed, self-employed, etc.).
industry (str): Sector of employment which may be affected by specific laws.
education_level (str): Level of education which might correlate with interests or concerns.
home_ownership (str): Home ownership status (owns, rents, etc.).
number_of_dependents (int): Number of people financially dependent on the user.
marital_status (str): Marital status (single, married, etc.).
health_status (str): General health information relevant to insurance or healthcare laws.
political_alignment (str): Political interests that might affect concern for certain legislation.
hobbies (list): List of hobbies or activities that might be affected by new laws.
zip_code (str): Postal code for precise geographical localization.
"""
def __init__(self, name: str, email: str, date_of_birth: str, employment_status: str,
industry: str, education_level: str, home_ownership: str, number_of_dependents: int,
marital_status: str, health_status: str, political_alignment: str, hobbies: list, zip_code: str):
self.name = name
self.email = email
self.date_of_birth = date_of_birth
self.employment_status = employment_status
self.industry = industry
self.education_level = education_level
self.home_ownership = home_ownership
self.number_of_dependents = number_of_dependents
self.marital_status = marital_status
self.health_status = health_status
self.political_alignment = political_alignment
self.hobbies = hobbies
self.zip_code = zip_code
def update_profile(self, **kwargs) -> None:
"""
Update profile attributes based on key-value pairs provided as arguments.
Args:
**kwargs: Arbitrary keyword arguments corresponding to user attributes.
"""
for key, value in kwargs.items():
setattr(self, key, value)
def delete_profile(self) -> None:
"""
Simulate deletion of this user profile, adhering to privacy and data protection laws.
"""
print(f"Profile for {self.name} has been deleted.")
class UserActivities:
"""
Tracks dynamic user activities and expenses that may change over time.
Attributes:
user (User): The User object this activities profile is associated with.
drives_car (bool): Whether the user drives a car.
uses_toll_bridges (bool): Whether the user frequently uses toll bridges.
eats_out (bool): Whether the user regularly eats out at restaurants.
monthly_dining_out_expense (float): Monthly expenditure on dining out.
monthly_grocery_expense (float): Monthly expenditure on groceries.
monthly_transport_expense (float): Monthly expenditure on transport including tolls and gas.
monthly_liquor_expense (float): Monthly expenditure on liquor.
"""
def __init__(self, user: User, drives_car: bool, uses_toll_bridges: bool, eats_out: bool,
monthly_dining_out_expense: float, monthly_grocery_expense: float,
monthly_transport_expense: float):
"""
Initialize a new UserActivities instance linked to a specific User.
Args:
user (User): The User object to which these activities are related.
drives_car (bool): Indicator if the user drives a car.
uses_toll_bridges (bool): Indicator if the user uses toll bridges.
eats_out (bool): Indicator if the user eats out regularly.
monthly_dining_out_expense (float): Monthly spending on dining out.
monthly_grocery_expense (float): Monthly spending on groceries.
monthly_transport_expense (float): Monthly spending on transportation.
monthly_liquor_expense (float): Monthly spending on liquor.
"""
self.user = user
self.drives_car = drives_car
self.uses_toll_bridges = uses_toll_bridges
self.eats_out = eats_out
self.monthly_dining_out_expense = monthly_dining_out_expense
self.monthly_grocery_expense = monthly_grocery_expense
self.monthly_transport_expense = monthly_transport_expense
def update_activities(self, **kwargs: Any) -> None:
"""
Update activities based on key-value pairs provided as arguments.
Args:
**kwargs (Any): Arbitrary keyword arguments corresponding to activity attributes.
"""
for key, value in kwargs.items():
setattr(self, key, value)
# Example Usage
if __name__ == "__main__":
jane = User(
name="Jane Doe",
email="jane.doe@example.com",
date_of_birth="1990-04-01",
employment_status="Employed",
industry="Technology",
education_level="Master's Degree",
home_ownership="Owns",
number_of_dependents=2,
marital_status="Married",
health_status="Healthy",
political_alignment="Moderate",
hobbies=["Hiking", "Photography"],
zip_code="94043"
)
jane.update_profile(employment_status="Self-employed")
print(f"Updated employment status for {jane.name}: {jane.employment_status}")
john_activities = UserActivities(
user=jane,
drives_car=True,
uses_toll_bridges=True,
eats_out=True,
monthly_dining_out_expense=300.0,
monthly_grocery_expense=500.0,
monthly_transport_expense=200)