Break after loop

main
Bob Mottram 2020-12-13 22:13:45 +00:00
parent 12cccfdeb6
commit e87fd5a168
17 changed files with 33 additions and 0 deletions

View File

@ -622,6 +622,7 @@ def getBlogIndexesForAccounts(baseDir: str) -> {}:
blogsIndex = accountDir + '/tlblogs.index'
if os.path.isfile(blogsIndex):
blogIndexes[acct] = blogsIndex
break
return blogIndexes
@ -639,6 +640,7 @@ def noOfBlogAccounts(baseDir: str) -> int:
blogsIndex = accountDir + '/tlblogs.index'
if os.path.isfile(blogsIndex):
ctr += 1
break
return ctr
@ -655,6 +657,7 @@ def singleBlogAccountNickname(baseDir: str) -> str:
blogsIndex = accountDir + '/tlblogs.index'
if os.path.isfile(blogsIndex):
return acct.split('@')[0]
break
return None
@ -698,6 +701,7 @@ def htmlBlogView(authorized: bool,
httpPrefix + '://' + domainFull + '/blog/' + \
acct.split('@')[0] + '">' + acct + '</a>'
blogStr += '</p>'
break
return blogStr + htmlFooter()

View File

@ -4789,6 +4789,7 @@ class PubServer(BaseHTTPRequestHandler):
port,
maxPostsInRSSFeed, 1,
False)
break
if msg:
msg = rss2Header(httpPrefix,
'news', domainFull,
@ -12133,6 +12134,7 @@ class PubServer(BaseHTTPRequestHandler):
contentJson = loadJson(deviceFilename)
if contentJson:
devicesList.append(contentJson)
break
# return the list of devices for this handle
msg = \
json.dumps(devicesList,
@ -12932,6 +12934,7 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
continue
tokensDict[nickname] = token
tokensLookup[token] = nickname
break
def runDaemon(dormantMonths: int,

View File

@ -321,6 +321,7 @@ def removeOldHashtags(baseDir: str, maxMonths: int) -> str:
# check of the file is too old
if fileDaysSinceEpoch < maxDaysSinceEpoch:
removeHashtags.append(tagsFilename)
break
for removeFilename in removeHashtags:
try:

View File

@ -152,6 +152,7 @@ def E2EEdevicesCollection(baseDir: str, nickname: str, domain: str,
devJson = loadJson(deviceFilename)
if devJson:
deviceList.append(devJson)
break
devicesDict = {
'id': personId + '/collections/devices',

View File

@ -1203,6 +1203,7 @@ def getFollowersOfActor(baseDir: str, actor: str, debug: bool) -> {}:
print('DEBUG: ' + account +
' follows ' + actorHandle)
recipientsDict[account] = None
break
return recipientsDict

View File

@ -200,6 +200,7 @@ def validInbox(baseDir: str, nickname: str, domain: str) -> bool:
if 'postNickname' in open(filename).read():
print('queue file incorrectly saved to ' + filename)
return False
break
return True
@ -224,6 +225,7 @@ def validInboxFilenames(baseDir: str, nickname: str, domain: str,
print('Expected: ' + expectedStr)
print('Invalid filename: ' + filename)
return False
break
return True
@ -2471,6 +2473,7 @@ def clearQueueItems(baseDir: str, queue: []) -> None:
ctr += 1
except BaseException:
pass
break
if ctr > 0:
print('Removed ' + str(ctr) + ' inbox queue items')
@ -2487,6 +2490,7 @@ def restoreQueueItems(baseDir: str, queue: []) -> None:
for queuesubdir, queuedirs, queuefiles in os.walk(queueDir):
for qfile in queuefiles:
queue.append(os.path.join(queueDir, qfile))
break
if len(queue) > 0:
print('Restored ' + str(len(queue)) + ' inbox queue items')

View File

@ -221,3 +221,4 @@ def archiveMedia(baseDir: str, archiveDirectory: str, maxWeeks=4) -> None:
else:
# archive to /dev/null
rmtree(os.path.join(baseDir + '/media', weekDir))
break

View File

@ -51,3 +51,4 @@ def migrateAccount(baseDir: str, oldHandle: str, newHandle: str) -> None:
migrateFollows(followFilename, oldHandle, newHandle)
followFilename = accountDir + '/followers.txt'
migrateFollows(followFilename, oldHandle, newHandle)
break

View File

@ -760,6 +760,7 @@ def addBlogsToNewswire(baseDir: str, domain: str, newswire: {},
addAccountBlogsToNewswire(baseDir, nickname, domain,
newswire, maxBlogsPerAccount,
blogsIndex, maxTags)
break
# sort the moderation dict into chronological order, latest first
sortedModerationDict = \

View File

@ -3195,6 +3195,7 @@ def archivePosts(baseDir: str, httpPrefix: str, archiveDir: str,
archivePostsForPerson(httpPrefix, nickname, domain, baseDir,
'outbox', archiveSubdir,
recentPostsCache, maxPostsInBox)
break
def archivePostsForPerson(httpPrefix: str, nickname: str, domain: str,

View File

@ -146,6 +146,7 @@ def runPostSchedule(baseDir: str, httpd, maxScheduledPosts: int):
if not os.path.isfile(scheduleIndexFilename):
continue
updatePostSchedule(baseDir, account, httpd, maxScheduledPosts)
break
def runPostScheduleWatchdog(projectVersion: str, httpd) -> None:

View File

@ -167,6 +167,7 @@ def addShare(baseDir: str,
'/users/' + nickname + '/tlshares')
except BaseException:
pass
break
def expireShares(baseDir: str) -> None:
@ -179,6 +180,7 @@ def expireShares(baseDir: str) -> None:
nickname = account.split('@')[0]
domain = account.split('@')[1]
expireSharesForAccount(baseDir, nickname, domain)
break
def expireSharesForAccount(baseDir: str, nickname: str, domain: str) -> None:

View File

@ -557,6 +557,7 @@ def setThemeImages(baseDir: str, name: str) -> None:
os.remove(accountDir + '/right_col_image.png')
except BaseException:
pass
break
def setNewsAvatar(baseDir: str, name: str,

View File

@ -110,6 +110,7 @@ def getHashtagCategories(baseDir: str, recent=False, category=None) -> None:
else:
if hashtag not in hashtagCategories[categoryStr]:
hashtagCategories[categoryStr].append(hashtag)
break
return hashtagCategories
@ -407,6 +408,7 @@ def getFollowersOfPerson(baseDir: str,
if account not in followers:
followers.append(account)
break
break
return followers
@ -932,6 +934,7 @@ def clearFromPostCaches(baseDir: str, recentPostsCache: {},
if recentPostsCache.get('html'):
if recentPostsCache['html'].get(postId):
del recentPostsCache['html'][postId]
break
def locatePost(baseDir: str, nickname: str, domain: str,
@ -1195,6 +1198,7 @@ def noOfAccounts(baseDir: str) -> bool:
if '@' in account:
if not account.startswith('inbox@'):
accountCtr += 1
break
return accountCtr
@ -1217,6 +1221,7 @@ def noOfActiveAccountsMonthly(baseDir: str, months: int) -> bool:
timeDiff = (currTime - int(lastUsed))
if timeDiff < monthSeconds:
accountCtr += 1
break
return accountCtr
@ -1493,6 +1498,7 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
res.append(filePath)
if len(res) >= maxResults:
return res
break
return res

View File

@ -197,6 +197,7 @@ def htmlHashTagSwarm(baseDir: str, actor: str, translate: {}) -> str:
if categoryStr not in categorySwarm:
categorySwarm.append(categoryStr)
break
break
if not tagSwarm:
return ''

View File

@ -256,6 +256,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
sharedItemsForm += '</form>\n'
break
ctr = 0
break
if not resultsExist:
sharedItemsForm += \
'<center><h5>' + translate['No results'] + '</h5></center>\n'
@ -428,6 +429,7 @@ def htmlSkillsSearch(actor: str,
';' + actorJson['icon']['url']
if indexStr not in results:
results.append(indexStr)
break
if not instanceOnly:
# search actor cache
for subdir, dirs, files in os.walk(baseDir + '/cache/actors/'):
@ -465,6 +467,7 @@ def htmlSkillsSearch(actor: str,
';' + actorJson['icon']['url']
if indexStr not in results:
results.append(indexStr)
break
results.sort(reverse=True)

View File

@ -429,6 +429,7 @@ def sharesTimelineJson(actor: str, pageNumber: int, itemsPerPage: int,
ctr += 1
if ctr >= maxSharesPerAccount:
break
break
# sort the shared items in descending order of publication date
sharesJson = OrderedDict(sorted(allSharesJson.items(), reverse=True))
lastPage = False