fixed csv + checkdescription func

This commit is contained in:
root 2025-01-22 08:53:18 +01:00
parent e2dbe8374a
commit 97bebe2128
4 changed files with 70 additions and 70 deletions

View file

@ -458,8 +458,8 @@ Maintenance:
webring_participant_url = input("What is the onion domain of the new webring participant? (ex: lantern.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion) ")
# check if the directory exists locally or not,
participantdir=rootpath+'www/participants/'+webring_participant_url
if not os.path.isdir(participantdir): # to test on your own instance
#if os.path.isdir(participantdir):
#if not os.path.isdir(participantdir): # to test on your own instance
if os.path.isdir(participantdir):
# if it does, it means that the webring is ALREADY added
print("[-] Webring Participant is already listed, skipping.")
return False
@ -567,7 +567,7 @@ Maintenance:
#print(i,row)
### SANITY CHECK 1: Mark all the rows that have incorrect formatting for deletion###
#print("[+] ROW=",i,"ROW CONTENTS=", IsUrlValid(uvdf.at[i, 'Instance']), IsCategoryValid(uvdf.at[i, 'Category']), IsNameValid(uvdf.at[i, 'Name']), IsUrlValid(uvdf.at[i, 'URL']), IsStatusValid(uvdf.at[i, 'Sensitive']), IsDescriptionValid(uvdf.at[i, 'Description']), IsStatusValid(uvdf.at[i, 'Status']), IsScoreValid(uvdf.at[i, 'Score']))
#print("[+] ROW=",i,"ROW CONTENTS=", IsUrlValid(csvdf.at[i, 'Instance']), IsCategoryValid(csvdf.at[i, 'Category']), IsNameValid(csvdf.at[i, 'Name']), IsUrlValid(csvdf.at[i, 'URL']), IsStatusValid(csvdf.at[i, 'Sensitive']), IsDescriptionValid(csvdf.at[i, 'Description']), IsStatusValid(csvdf.at[i, 'Status']), IsScoreValid(csvdf.at[i, 'Score']))
if IsUrlValid(csvdf.at[i, 'Instance']) is False or IsCategoryValid(csvdf.at[i, 'Category']) is False or IsNameValid(csvdf.at[i, 'Name']) is False or IsUrlValid(csvdf.at[i, 'URL']) is False or IsStatusValid(csvdf.at[i, 'Sensitive']) is False or IsDescriptionValid(csvdf.at[i, 'Description']) is False or IsStatusValid(csvdf.at[i, 'Status']) is False or IsScoreValid(csvdf.at[i, 'Score']) is False:
#mark the row for deletion as it has invalid inputs
if i not in rows2delete:
@ -593,13 +593,13 @@ Maintenance:
print("Marking row", i,"as sensitive, as it matches with a sensitive word")
csvdf.at[i, 'Sensitive']='✔️'
print('[-] Rows to delete: ',rows2delete)
print('[-] Rows to delete: ',rows2delete)
for i in rows2delete:
row=csvdf.loc[i,:].values.tolist()
print('[+] REMOVING ROW :',i,row)
csvdf.drop(i, inplace= True)
csvdf.to_csv(csvfilepath, index=False)
for i in rows2delete:
row=csvdf.loc[i,:].values.tolist()
print('[+] REMOVING ROW :',i,row)
csvdf.drop(i, inplace= True)
csvdf.to_csv(csvfilepath, index=False)
##############################################
@ -1124,7 +1124,7 @@ def IsDescriptionValid(desc:str)->bool:
if desc == "":
# empty description is fine as it's optional
return True
pattern = re.compile("^[A-Za-z0-9-.' ]+$")
pattern = re.compile("^[A-Za-z0-9-.' \"]+$")
desc = str(desc)
desc.strip()
if pattern.fullmatch(desc) is None: