fix option 4 (when empty filtered dataframe it was failing)

This commit is contained in:
root 2025-03-25 08:20:06 +01:00
parent 64e703ad47
commit 57f53c95ea

View file

@ -253,7 +253,7 @@ Maintenance:
print_colors(f"{uvdf[['Name','URL']]}") print_colors(f"{uvdf[['Name','URL']]}")
while(IsNameValid(name) is not True): while(IsNameValid(name) is not True):
name = input("What is the Website name you want to Trust ? (ex: Nowhere)") name = input("What is the Website name you want to Trust ? (ex: Nowhere)")
filter_uvdf = uvdf[uvdf.Name.str.contains(name)] filter_uvdf = uvdf[uvdf.Name.str.contains(name,na=False)]
# display only the matching entries in unverified.csv in an array format (display it in CLI). # display only the matching entries in unverified.csv in an array format (display it in CLI).
print_colors(f"{filter_uvdf[['Name','URL']]}") print_colors(f"{filter_uvdf[['Name','URL']]}")
# check if there are no results, dont proceed if there are none! # check if there are no results, dont proceed if there are none!
@ -295,7 +295,7 @@ Maintenance:
print_colors(f"{vdf[['Name','URL']]}") print_colors(f"{vdf[['Name','URL']]}")
while(IsNameValid(name) is not True): while(IsNameValid(name) is not True):
name = input("What is the Website name you want to Untrust ? (ex: BreachForums)") name = input("What is the Website name you want to Untrust ? (ex: BreachForums)")
filter_vdf = vdf[vdf.Name.str.contains(name)] filter_vdf = vdf[vdf.Name.str.contains(name,na=False)]
# display only the matching entries in unverified.csv in an array format (display it in CLI). # display only the matching entries in unverified.csv in an array format (display it in CLI).
print_colors(f"{filter_vdf[['Name','URL']]}") print_colors(f"{filter_vdf[['Name','URL']]}")
# check if there are no results, dont proceed if there are none! # check if there are no results, dont proceed if there are none!
@ -331,8 +331,8 @@ Maintenance:
print_colors(f"{vdf[['Name','URL']]}") print_colors(f"{vdf[['Name','URL']]}")
while(IsNameValid(name) is not True): while(IsNameValid(name) is not True):
name = input("What is the Website name you want to Blacklist ? (ex: BreachForums)") name = input("What is the Website name you want to Blacklist ? (ex: BreachForums)")
filter_uvdf = uvdf[uvdf.Name.str.contains(name)] filter_uvdf = uvdf[uvdf.Name.str.contains(name,na=False)]
filter_vdf = vdf[vdf.Name.str.contains(name)] filter_vdf = vdf[vdf.Name.str.contains(name,na=False)]
if filter_vdf.size == 0 and filter_uvdf.size == 0 : if filter_vdf.size == 0 and filter_uvdf.size == 0 :
print_colors("ERROR no results, skipping.",is_error=True) print_colors("ERROR no results, skipping.",is_error=True)
@ -409,7 +409,7 @@ Maintenance:
print_colors(f"{vdf[['Name','URL']]}") print_colors(f"{vdf[['Name','URL']]}")
while(IsNameValid(name) is not True): while(IsNameValid(name) is not True):
name = input("What is the Website name you want to edit ? (ex: BreachForums)") name = input("What is the Website name you want to edit ? (ex: BreachForums)")
filter_vdf = vdf[vdf.Name.str.contains(name)] filter_vdf = vdf[vdf.Name.str.contains(name,na=False)]
if filter_vdf.size != 0 : if filter_vdf.size != 0 :
print_colors(f"{filter_vdf[['Name','URL']]}") print_colors(f"{filter_vdf[['Name','URL']]}")
# check if website name exists in verified.csv, if yes ask the user what index should be blacklisted # check if website name exists in verified.csv, if yes ask the user what index should be blacklisted
@ -455,7 +455,7 @@ Maintenance:
print_colors(f"{uvdf[['Name','URL']]}") print_colors(f"{uvdf[['Name','URL']]}")
while(IsNameValid(name) is not True): while(IsNameValid(name) is not True):
name = input("What is the Website name you want to edit? (ex: BreachForums)") name = input("What is the Website name you want to edit? (ex: BreachForums)")
filter_uvdf = uvdf[uvdf.Name.str.contains(name)] filter_uvdf = uvdf[uvdf.Name.str.contains(name,na=False)]
if filter_uvdf.size != 0 : if filter_uvdf.size != 0 :
print_colors(f"{filter_uvdf[['Name','URL']]}") print_colors(f"{filter_uvdf[['Name','URL']]}")
# check if website name exists in unverified.csv, if yes ask the user what index should be blacklisted # check if website name exists in unverified.csv, if yes ask the user what index should be blacklisted
@ -577,7 +577,7 @@ Maintenance:
# check if the participant is already listed in webring-participants.csv or not, and add them if not already listed # check if the participant is already listed in webring-participants.csv or not, and add them if not already listed
# and display only the matching entries in unverified.csv in an array format (display it in CLI). # and display only the matching entries in unverified.csv in an array format (display it in CLI).
filter_wdf = wdf[wdf.URL.str.contains(participant)] filter_wdf = wdf[wdf.URL.str.contains(participant,na=False)]
# check if there are no results, dont proceed if there are none! # check if there are no results, dont proceed if there are none!
if filter_wdf.size == 0: #skip if webring participant is already listed, otherwise proceed if filter_wdf.size == 0: #skip if webring participant is already listed, otherwise proceed
newrow=[name,participant,desc,trusted,status,score] newrow=[name,participant,desc,trusted,status,score]
@ -597,7 +597,7 @@ Maintenance:
rows2delete= [] # it is an empty list at first rows2delete= [] # it is an empty list at first
for i,j in csvdf.iterrows(): for i,j in csvdf.iterrows():
row=csvdf.loc[i,:].values.tolist() row=csvdf.loc[i,:].values.tolist()
#print_colors(f"{row}") print_colors(f"{row}")
@ -638,8 +638,11 @@ Maintenance:
# for each link in the participant's verified/unverified csv files, # for each link in the participant's verified/unverified csv files,
# check if the link is already listed in your own verified.csv or unverified.csv # check if the link is already listed in your own verified.csv or unverified.csv
filterterm=csvdf.at[i, 'URL'] filterterm=csvdf.at[i, 'URL']
filter_vdf= vdf[vdf.URL.str.contains(filterterm)] #print('1)',filterterm)
filter_uvdf= uvdf[uvdf.URL.str.contains(filterterm)] filter_vdf= vdf[vdf.URL.str.contains(filterterm,na=False)]
#print('2)',filter_vdf)
#print('3)',uvdf[uvdf.URL.str.contains(filterterm,na=False)] )
filter_uvdf= uvdf[uvdf.URL.str.contains(filterterm,na=False)]
if len(filter_uvdf.index) == 0 and len(filter_vdf.index) == 0: if len(filter_uvdf.index) == 0 and len(filter_vdf.index) == 0:
newrow=row newrow=row
uvdf.loc[-1] = newrow # adding a row uvdf.loc[-1] = newrow # adding a row