-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserManager.py
54 lines (47 loc) · 1.96 KB
/
UserManager.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
import pandas as pd
UserDataFileName="Data/users.csv"
UserData=pd.read_csv(UserDataFileName)
def CheckUserName(UserName):
for i in UserData["Name"]:
if i==UserName:
return True
return False
def AddUser(UserName,Password):
return UserData[UserData["Name"]==UserName].isin([Password]).any().any()
def AddUser(name,password):
global UserData
i=len(UserData)
if UserData['Name'].isin([name]).any():
print("User "+name+" already exist")
else:
temp=pd.DataFrame({"Name":name,"Password":password},index=[i])
UserData= pd.concat([UserData,temp])
UserData.to_csv(UserDataFileName,index=False)
def delUserByName(name,password):
if not UserData['Name'].isin([name]).any():
print("No User called "+name+" exist!!!")
elif CheckPassword(name,password):
UserData.drop(UserData[UserData['Name']==name].index,inplace=True)
UserData.to_csv(UserDataFileName,index=False)
else:
print("Please check Your password!!!")
def ChangeUsername(OldName,password,NewName):
if not UserData['Name'].isin([OldName]).any():
print("No User called "+OldName+" exist!!!")
elif UserData['Name'].isin([NewName]).any():
print("User "+NewName+" already exist")
elif CheckPassword(OldName,password):
UserData.loc[UserData['Name']==OldName,"Name"]=NewName
UserData.to_csv(UserDataFileName,index=False)
print("UserName updated!")
else:
print("Please Check your Password!!!")
def ChangePassword(UserName,OldPassword,NewPassword):
if not UserData['Name'].isin([UserName]).any():
print("No User called "+UserName+" exist!!!")
elif CheckPassword(UserName,OldPassword):
UserData.loc[UserData['Password']==OldPassword,"Password"]=NewPassword
UserData.to_csv(UserDataFileName,index=False)
print("Password Updated!")
else:
print("Please Enter correct Password")