Less indentation

merge-requests/8/head
Bob Mottram 2020-12-06 14:42:42 +00:00
parent c7740de9e9
commit 18ac0231b4
1 changed files with 20 additions and 18 deletions

View File

@ -422,24 +422,26 @@ def sharesTimelineJson(actor: str, pageNumber: int, itemsPerPage: int,
allSharesJson = {} allSharesJson = {}
for subdir, dirs, files in os.walk(baseDir + '/accounts'): for subdir, dirs, files in os.walk(baseDir + '/accounts'):
for handle in dirs: for handle in dirs:
if '@' in handle: if '@' not in handle:
accountDir = baseDir + '/accounts/' + handle continue
sharesFilename = accountDir + '/shares.json' accountDir = baseDir + '/accounts/' + handle
if os.path.isfile(sharesFilename): sharesFilename = accountDir + '/shares.json'
sharesJson = loadJson(sharesFilename) if not os.path.isfile(sharesFilename):
if not sharesJson: continue
continue sharesJson = loadJson(sharesFilename)
nickname = handle.split('@')[0] if not sharesJson:
# actor who owns this share continue
owner = actor.split('/users/')[0] + '/users/' + nickname nickname = handle.split('@')[0]
ctr = 0 # actor who owns this share
for itemID, item in sharesJson.items(): owner = actor.split('/users/')[0] + '/users/' + nickname
# assign owner to the item ctr = 0
item['actor'] = owner for itemID, item in sharesJson.items():
allSharesJson[str(item['published'])] = item # assign owner to the item
ctr += 1 item['actor'] = owner
if ctr >= maxSharesPerAccount: allSharesJson[str(item['published'])] = item
break ctr += 1
if ctr >= maxSharesPerAccount:
break
# sort the shared items in descending order of publication date # sort the shared items in descending order of publication date
sharesJson = OrderedDict(sorted(allSharesJson.items(), reverse=True)) sharesJson = OrderedDict(sorted(allSharesJson.items(), reverse=True))
lastPage = False lastPage = False