From bdb5fa580497ea8975738e541f4b1507b5c9121c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 25 Sep 2020 10:20:58 +0000 Subject: [PATCH] Function for non-mutuals --- follow.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/follow.py b/follow.py index ea3ac55b..2dd88048 100644 --- a/follow.py +++ b/follow.py @@ -112,8 +112,7 @@ def isFollowingActor(baseDir: str, def getMutualsOfPerson(baseDir: str, - nickname: str, domain: str, - followFile='following.txt') -> []: + nickname: str, domain: str) -> []: """Returns the mutuals of a person i.e. accounts which they follow and which also follow back """ @@ -128,6 +127,22 @@ def getMutualsOfPerson(baseDir: str, return mutuals +def getNonMutualsOfPerson(baseDir: str, + nickname: str, domain: str) -> []: + """Returns the followers who are not mutuals of a person + i.e. accounts which follow you but you don't follow them + """ + followers = \ + getFollowersOfPerson(baseDir, nickname, domain, 'followers') + following = \ + getFollowersOfPerson(baseDir, nickname, domain, 'following') + nonMutuals = [] + for handle in following: + if handle not in followers: + nonMutuals.append(handle) + return nonMutuals + + def getFollowersOfPerson(baseDir: str, nickname: str, domain: str, followFile='following.txt') -> []: