-
Notifications
You must be signed in to change notification settings - Fork 0
/
userAccount15.py
63 lines (49 loc) · 1.89 KB
/
userAccount15.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
import warnings
class UserAccount:
"""A class representing a user account with username and password."""
def __init__(self, username, password):
"""
Initialize a UserAccount object.
:param username: The username for the user account.
:type username: str
:param password: The password for the user account.
:type password: str
"""
self.username = username
self.password = password
def retrieve_login_details(self):
"""
Retrieve the login details of the user account.
:return: A dictionary containing the username and password.
:rtype: dict
"""
return {'username': self.username, 'password': self.password}
def change_username(self, new_username):
"""
Change the username of the user account.
:param new_username: The new username to set.
:type new_username: str
"""
self.username = new_username
def change_password(self, new_password):
"""
Change the password of the user account.
:param new_password: The new password to set.
:type new_password: str
"""
self.password = new_password
def delete_username(self):
"""Delete the username of the user account."""
self.username = None
def delete_password(self):
"""Delete the password of the user account."""
self.password = None
def is_valid_username(self):
"""
Check if the username is valid.
Username must be at least 3 characters long and contain only alphanumeric characters.
:return: True if the username is valid, False otherwise.
:rtype: bool
"""
warnings.warn("The is_valid_username method is deprecated and will be removed in a future release.", DeprecationWarning)
return len(self.username) >= 3 and self.username.isalnum()