From cf6636c90be65a67626a01bbacab0a87742bfa0c Mon Sep 17 00:00:00 2001 From: MelcomX Date: Sun, 8 Dec 2019 20:05:55 +0100 Subject: [PATCH 1/4] Create missing_followers.py It allows to take a look at the unfollowers with two connections.json files --- scripts/python/missing_followers.py | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 scripts/python/missing_followers.py diff --git a/scripts/python/missing_followers.py b/scripts/python/missing_followers.py new file mode 100644 index 0000000..8a88c23 --- /dev/null +++ b/scripts/python/missing_followers.py @@ -0,0 +1,38 @@ +import json +import sys +# from jsondiff import diff + +if len(sys.argv) == 3: + print "Old:", sys.argv[1] + print "New:", sys.argv[2] + json_file_old = open(sys.argv[1]) + connectionsold = json.load(json_file_old) + json_file_new = open(sys.argv[2]) + connectionsnew = json.load(json_file_new) + followerold = [] + followernew = [] + for user in connectionsold['followers']: + followerold.append(user) + for user in connectionsnew['followers']: + followernew.append(user) + + found = None + overall = None + print("Users that followed you before, but now stopped to follow you:") + for a, val in enumerate(followerold): + for b, val in enumerate(followernew): + #print b + if followerold[a]==followernew[b]: + found = True + break + if not found: + overall = True + print followerold[a] + continue + else: + found = None + + if not overall: + print("It looks like your friends like you. There is no unfollower!") +else: + print('correct usage: python missing_followers.py ') From d9b52f310892e9445480a18dd2868724be72467f Mon Sep 17 00:00:00 2001 From: MelcomX Date: Sun, 8 Dec 2019 20:45:14 +0100 Subject: [PATCH 2/4] Update missing_followers.py Changed according to the suggestions. --- scripts/python/missing_followers.py | 33 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/scripts/python/missing_followers.py b/scripts/python/missing_followers.py index 8a88c23..cdb6c8c 100644 --- a/scripts/python/missing_followers.py +++ b/scripts/python/missing_followers.py @@ -1,38 +1,43 @@ import json import sys -# from jsondiff import diff if len(sys.argv) == 3: + try: print "Old:", sys.argv[1] print "New:", sys.argv[2] json_file_old = open(sys.argv[1]) - connectionsold = json.load(json_file_old) + connections_old = json.load(json_file_old) json_file_new = open(sys.argv[2]) - connectionsnew = json.load(json_file_new) - followerold = [] - followernew = [] - for user in connectionsold['followers']: - followerold.append(user) - for user in connectionsnew['followers']: - followernew.append(user) + connections_new = json.load(json_file_new) + follower_old = [] + follower_new = [] + for user in connections_old['followers']: + follower_old.append(user) + for user in connections_new['followers']: + follower_new.append(user) found = None overall = None print("Users that followed you before, but now stopped to follow you:") - for a, val in enumerate(followerold): - for b, val in enumerate(followernew): + for a, val in enumerate(follower_old): + for b, val in enumerate(follower_new): #print b - if followerold[a]==followernew[b]: + if follower_old[a]==follower_new[b]: found = True break if not found: overall = True - print followerold[a] + print follower_old[a] continue else: found = None if not overall: - print("It looks like your friends like you. There is no unfollower!") + print("It looks like your friends like you. Nobody has unfollowed you!") + except FileNotFoundError: + sys.exit("At least one of your files does not exist") + except IOError: + sys.exit("At least one of your files is corrupt or doesn't exist") + else: print('correct usage: python missing_followers.py ') From a969f80f02ce9ea9e0287f3efb8b53dca1c44f08 Mon Sep 17 00:00:00 2001 From: MelcomX Date: Sun, 8 Dec 2019 21:09:24 +0100 Subject: [PATCH 3/4] Update missing_followers.py Changed according to the suggestions. --- scripts/python/missing_followers.py | 32 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/scripts/python/missing_followers.py b/scripts/python/missing_followers.py index cdb6c8c..3e47d64 100644 --- a/scripts/python/missing_followers.py +++ b/scripts/python/missing_followers.py @@ -3,7 +3,7 @@ if len(sys.argv) == 3: try: - print "Old:", sys.argv[1] + print "Old:",sys.argv[1] print "New:", sys.argv[2] json_file_old = open(sys.argv[1]) connections_old = json.load(json_file_old) @@ -16,28 +16,26 @@ for user in connections_new['followers']: follower_new.append(user) - found = None - overall = None + found_unfollower = False + found_overall = False print("Users that followed you before, but now stopped to follow you:") for a, val in enumerate(follower_old): - for b, val in enumerate(follower_new): - #print b - if follower_old[a]==follower_new[b]: - found = True - break - if not found: - overall = True - print follower_old[a] - continue - else: - found = None + for b, val in enumerate(follower_new): + if follower_old[a]==follower_new[b]: + found_unfollower = True + break + if not found_unfollower: + found_overall = True + print follower_old[a] + continue + else: + found_unfollower = False - if not overall: - print("It looks like your friends like you. Nobody has unfollowed you!") + if not found_overall: + print("It looks like your friends like you. Nobody has unfollowed you!") except FileNotFoundError: sys.exit("At least one of your files does not exist") except IOError: sys.exit("At least one of your files is corrupt or doesn't exist") - else: print('correct usage: python missing_followers.py ') From 9215207014f499402f0098505f7d581b9185240f Mon Sep 17 00:00:00 2001 From: MelcomX Date: Fri, 13 Dec 2019 08:28:34 +0100 Subject: [PATCH 4/4] Changed Variable names. Now the names of the variables correspond to the value. --- scripts/python/missing_followers.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/python/missing_followers.py b/scripts/python/missing_followers.py index 3e47d64..564c34d 100644 --- a/scripts/python/missing_followers.py +++ b/scripts/python/missing_followers.py @@ -16,22 +16,22 @@ for user in connections_new['followers']: follower_new.append(user) - found_unfollower = False - found_overall = False + found_still_following = False + found_overall_unfollower = False print("Users that followed you before, but now stopped to follow you:") for a, val in enumerate(follower_old): for b, val in enumerate(follower_new): if follower_old[a]==follower_new[b]: - found_unfollower = True + found_still_following = True break - if not found_unfollower: - found_overall = True + if not found_still_following: + found_overall_unfollower = True print follower_old[a] continue else: - found_unfollower = False + found_still_following = False - if not found_overall: + if not found_overall_unfollower: print("It looks like your friends like you. Nobody has unfollowed you!") except FileNotFoundError: sys.exit("At least one of your files does not exist")