forked from indymedia/epicyon
Case insensitive unfollowing
parent
a5af67c669
commit
360b1be9c3
|
@ -202,23 +202,25 @@ def unfollowPerson(baseDir: str, nickname: str, domain: str,
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: follow file ' + filename + ' was not found')
|
print('DEBUG: follow file ' + filename + ' was not found')
|
||||||
return False
|
return False
|
||||||
if handleToUnfollow not in open(filename).read():
|
if handleToUnfollow.lower() not in open(filename).read().lower():
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: handle to unfollow ' + handleToUnfollow +
|
print('DEBUG: handle to unfollow ' + handleToUnfollow +
|
||||||
' is not in ' + filename)
|
' is not in ' + filename)
|
||||||
return
|
return
|
||||||
with open(filename, "r") as f:
|
with open(filename, "r") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
|
handleToUnfollowLower = handleToUnfollow.lower()
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.strip("\n").strip("\r") != handleToUnfollow:
|
if line.strip("\n").strip("\r").lower() != handleToUnfollowLower:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
|
|
||||||
# write to an unfollowed file so that if a follow accept
|
# write to an unfollowed file so that if a follow accept
|
||||||
# later arrives then it can be ignored
|
# later arrives then it can be ignored
|
||||||
unfollowedFilename = baseDir + '/accounts/' + handle + '/unfollowed.txt'
|
unfollowedFilename = baseDir + '/accounts/' + handle + '/unfollowed.txt'
|
||||||
if os.path.isfile(unfollowedFilename):
|
if os.path.isfile(unfollowedFilename):
|
||||||
if handleToUnfollow not in open(unfollowedFilename).read():
|
if handleToUnfollowLower not in \
|
||||||
|
open(unfollowedFilename).read().lower():
|
||||||
with open(filename, "a+") as f:
|
with open(filename, "a+") as f:
|
||||||
f.write(handleToUnfollow + '\n')
|
f.write(handleToUnfollow + '\n')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue