mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-07-01 19:06:41 +00:00
Merge pull request 'fixed option 4 removing local instance rows' (#86) from fix_option_4_and_10_removing_self_added_rows into main
Reviewed-on: http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern/pulls/86
This commit is contained in:
commit
94fcec124b
2 changed files with 33 additions and 6 deletions
|
@ -16,10 +16,10 @@ def run_option_4():
|
||||||
|
|
||||||
utils.print_colors('[+] Syncing official webrings to local webrings')
|
utils.print_colors('[+] Syncing official webrings to local webrings')
|
||||||
|
|
||||||
webring_df = utils.get_local_webring_participants()
|
|
||||||
|
|
||||||
current_instance = utils.get_current_instance()
|
current_instance = utils.get_current_instance()
|
||||||
|
|
||||||
|
webring_df = utils.get_local_webring_participants(current_instance)
|
||||||
|
|
||||||
utils.print_colors('[+] Reading local blacklist and sensitive words')
|
utils.print_colors('[+] Reading local blacklist and sensitive words')
|
||||||
local_blacklist_df = utils.get_local_blacklist()
|
local_blacklist_df = utils.get_local_blacklist()
|
||||||
local_sensitive_df = utils.get_local_sensitive()
|
local_sensitive_df = utils.get_local_sensitive()
|
||||||
|
@ -28,8 +28,8 @@ def run_option_4():
|
||||||
local_verified_df, local_unverified_df = utils.get_local_verified_and_unverified()
|
local_verified_df, local_unverified_df = utils.get_local_verified_and_unverified()
|
||||||
|
|
||||||
#Remove all rows
|
#Remove all rows
|
||||||
local_unverified_df = local_unverified_df[0:0]
|
local_unverified_df = utils.renew_csv(local_unverified_df, current_instance)
|
||||||
local_verified_df = local_verified_df[0:0]
|
local_verified_df = utils.renew_csv(local_verified_df, current_instance)
|
||||||
|
|
||||||
for participant in webring_df.itertuples(index=False, name='columns'):
|
for participant in webring_df.itertuples(index=False, name='columns'):
|
||||||
# Check if the participant is my instance
|
# Check if the participant is my instance
|
||||||
|
|
|
@ -305,6 +305,26 @@ def is_row_valid(row):
|
||||||
|
|
||||||
###################### General ######################
|
###################### General ######################
|
||||||
|
|
||||||
|
def renew_csv(df, participant_url):
|
||||||
|
"""
|
||||||
|
Removes all rows that are not generated by the local instance
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
df : pd.DataFrame
|
||||||
|
Dataframe we want to renew
|
||||||
|
participant_url : str
|
||||||
|
the instance url
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
--------
|
||||||
|
pd.DataFrame
|
||||||
|
The renewed dataframe
|
||||||
|
"""
|
||||||
|
|
||||||
|
return df[df['Instance'] == participant_url]
|
||||||
|
|
||||||
|
|
||||||
def merge_verification_df(receiving_df, merging_df):
|
def merge_verification_df(receiving_df, merging_df):
|
||||||
"""
|
"""
|
||||||
Merges 2 dataframes of type verified or unverified (do not merge duplications by name or url)
|
Merges 2 dataframes of type verified or unverified (do not merge duplications by name or url)
|
||||||
|
@ -775,10 +795,15 @@ def get_local_verified_and_unverified():
|
||||||
|
|
||||||
return pd.DataFrame(), pd.DataFrame()
|
return pd.DataFrame(), pd.DataFrame()
|
||||||
|
|
||||||
def get_local_webring_participants():
|
def get_local_webring_participants(current_instance):
|
||||||
"""
|
"""
|
||||||
Make sure the official participants are registered in the webring csv file
|
Make sure the official participants are registered in the webring csv file
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
current_instance : str
|
||||||
|
The current local instance url
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
pd.DataFrame
|
pd.DataFrame
|
||||||
|
@ -792,7 +817,9 @@ def get_local_webring_participants():
|
||||||
missing_participants = set(get_official_participants()) - set(webring_df['URL'])
|
missing_participants = set(get_official_participants()) - set(webring_df['URL'])
|
||||||
|
|
||||||
for participant in missing_participants:
|
for participant in missing_participants:
|
||||||
new_row = [{'Name': '','URL': participant,'Description': '','Trusted': 'NO','Status': '','Score': ''}]
|
if participant == current_instance:
|
||||||
|
continue
|
||||||
|
new_row = [{'Name': '','URL': participant,'Description': '','Trusted': 'NO','Status': '','Score': '', 'Blacklisted': 'NO'}]
|
||||||
webring_df = pd.concat([webring_df, pd.DataFrame(new_row)], ignore_index=True)
|
webring_df = pd.concat([webring_df, pd.DataFrame(new_row)], ignore_index=True)
|
||||||
|
|
||||||
save_dataframe(webring_df, conf.LOCAL_DIR + conf.WEBRING_CSV_FILE)
|
save_dataframe(webring_df, conf.LOCAL_DIR + conf.WEBRING_CSV_FILE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue