Less indentation

merge-requests/30/head
Bob Mottram 2022-08-19 17:22:53 +01:00
parent ced75a7b3d
commit f2917482db
1 changed files with 48 additions and 46 deletions

View File

@ -3082,29 +3082,30 @@ def _like_notify(base_dir: str, domain: str,
print('_like_notify liker_handle: ' + print('_like_notify liker_handle: ' +
str(liker_nickname) + '@' + str(liker_domain)) str(liker_nickname) + '@' + str(liker_domain))
liker_handle = actor liker_handle = actor
if liker_handle != handle: if liker_handle == handle:
like_str = liker_handle + ' ' + url + '?likedBy=' + actor return
prev_like_file = account_dir + '/.prevLike' like_str = liker_handle + ' ' + url + '?likedBy=' + actor
# was there a previous like notification? prev_like_file = account_dir + '/.prevLike'
if os.path.isfile(prev_like_file): # was there a previous like notification?
# is it the same as the current notification ? if os.path.isfile(prev_like_file):
with open(prev_like_file, 'r', encoding='utf-8') as fp_like: # is it the same as the current notification ?
prev_like_str = fp_like.read() with open(prev_like_file, 'r', encoding='utf-8') as fp_like:
if prev_like_str == like_str: prev_like_str = fp_like.read()
return if prev_like_str == like_str:
try: return
with open(prev_like_file, 'w+', encoding='utf-8') as fp_like: try:
fp_like.write(like_str) with open(prev_like_file, 'w+', encoding='utf-8') as fp_like:
except OSError: fp_like.write(like_str)
print('EX: ERROR: unable to save previous like notification ' + except OSError:
prev_like_file) print('EX: ERROR: unable to save previous like notification ' +
prev_like_file)
try: try:
with open(like_file, 'w+', encoding='utf-8') as fp_like: with open(like_file, 'w+', encoding='utf-8') as fp_like:
fp_like.write(like_str) fp_like.write(like_str)
except OSError: except OSError:
print('EX: ERROR: unable to write like notification file ' + print('EX: ERROR: unable to write like notification file ' +
like_file) like_file)
def _reaction_notify(base_dir: str, domain: str, onion_domain: str, def _reaction_notify(base_dir: str, domain: str, onion_domain: str,
@ -3144,31 +3145,32 @@ def _reaction_notify(base_dir: str, domain: str, onion_domain: str,
print('_reaction_notify reaction_handle: ' + print('_reaction_notify reaction_handle: ' +
str(reaction_nickname) + '@' + str(reaction_domain)) str(reaction_nickname) + '@' + str(reaction_domain))
reaction_handle = actor reaction_handle = actor
if reaction_handle != handle: if reaction_handle == handle:
reaction_str = \ return
reaction_handle + ' ' + url + '?reactBy=' + actor + \ reaction_str = \
';emoj=' + emoji_content reaction_handle + ' ' + url + '?reactBy=' + actor + \
prev_reaction_file = account_dir + '/.prevReaction' ';emoj=' + emoji_content
# was there a previous reaction notification? prev_reaction_file = account_dir + '/.prevReaction'
if os.path.isfile(prev_reaction_file): # was there a previous reaction notification?
# is it the same as the current notification ? if os.path.isfile(prev_reaction_file):
with open(prev_reaction_file, 'r', encoding='utf-8') as fp_react: # is it the same as the current notification ?
prev_reaction_str = fp_react.read() with open(prev_reaction_file, 'r', encoding='utf-8') as fp_react:
if prev_reaction_str == reaction_str: prev_reaction_str = fp_react.read()
return if prev_reaction_str == reaction_str:
try: return
with open(prev_reaction_file, 'w+', encoding='utf-8') as fp_react: try:
fp_react.write(reaction_str) with open(prev_reaction_file, 'w+', encoding='utf-8') as fp_react:
except OSError: fp_react.write(reaction_str)
print('EX: ERROR: unable to save previous reaction notification ' + except OSError:
prev_reaction_file) print('EX: ERROR: unable to save previous reaction notification ' +
prev_reaction_file)
try: try:
with open(reaction_file, 'w+', encoding='utf-8') as fp_react: with open(reaction_file, 'w+', encoding='utf-8') as fp_react:
fp_react.write(reaction_str) fp_react.write(reaction_str)
except OSError: except OSError:
print('EX: ERROR: unable to write reaction notification file ' + print('EX: ERROR: unable to write reaction notification file ' +
reaction_file) reaction_file)
def _notify_post_arrival(base_dir: str, handle: str, url: str) -> None: def _notify_post_arrival(base_dir: str, handle: str, url: str) -> None: