Simplify comparer

This commit is contained in:
Ferit Yiğit BALABAN 2022-06-07 15:27:35 +03:00
parent 1ff0df87ad
commit 2c468b5cd7

View File

@ -2,43 +2,40 @@
# #
# Ferit Yiğit BALABAN <fyb@duck.com>, 2022 # Ferit Yiğit BALABAN <fyb@duck.com>, 2022
# #
import urllib.request
# noinspection PyUnreachableCode
def main(): def main():
if False: follower_path = '/home/ferit/scripts/follower'
follower_path = '/home/ferit/Downloads/followers.csv' followed_path = '/home/ferit/scripts/followed'
following_path = '/home/ferit/Downloads/following.csv' follower2_path = '/home/ferit/scripts/follower2'
with open(follower_path, 'r') as f:
follower_list = f.readlines()
f.close()
with open(followed_path, 'r') as f:
followed_list = f.readlines()
f.close()
with open(follower2_path, 'r') as f:
follower2_list = f.readlines()
f.close()
with open(follower_path, 'r') as f: follower_list = [x.removesuffix('\n') for x in follower_list]
follower_list = f.readlines() followed_list = [x.removesuffix('\n') for x in followed_list]
f.close() follower2_list = [x.removesuffix('\n') for x in follower2_list]
with open(following_path, 'r') as f:
following_list = f.readlines()
f.close()
follower_list.remove(follower_list[0]) print('Old method:')
following_list.remove(following_list[0]) for followed in followed_list:
if followed not in follower1_list:
print(followed, 'doesn\'t follow you back.')
follower_list = [line.split(',')[1] for line in follower_list] print('New method:')
following_list = [line.split(',')[1] for line in following_list] for followed in followed_list:
else: if followed not in follower2_list:
follower_path = '/home/ferit/scripts/follower' print(followed, 'doesn\t follow you back.')
followed_path = '/home/ferit/scripts/followed'
with open(follower_path, 'r') as f:
follower_list = f.readlines()
f.close()
with open(followed_path, 'r') as f:
followed_list = f.readlines()
f.close()
follower_list = [x.removesuffix('\n') for x in follower_list] print('Who unfollowed me:')
followed_list = [x.removesuffix('\n') for x in followed_list] for old_follower in follower_list:
if old_follower not in follower2_list:
for followed in followed_list: print(old_follower, 'unfollowed you.')
if followed not in follower_list:
print(followed, 'doesn\'t follow you.')
if __name__ == '__main__': if __name__ == '__main__':