Remove default arguments for better static analysis

main
Bob Mottram 2021-10-29 23:40:09 +01:00
parent 24ac3184b4
commit eeb95973d9
11 changed files with 24 additions and 24 deletions

View File

@ -2127,7 +2127,7 @@ if args.followers:
followersList = \
downloadFollowCollection(signingPrivateKeyPem,
'followers', session,
httpPrefix, personUrl, 1, 3)
httpPrefix, personUrl, 1, 3, args.debug)
if followersList:
for actor in followersList:
print(actor)

View File

@ -1688,7 +1688,7 @@ def _receiveAnnounce(recentPostsCache: {},
if '/statuses/' in lookupActor:
lookupActor = lookupActor.split('/statuses/')[0]
if isRecentPost(postJsonObject):
if isRecentPost(postJsonObject, 3):
if not os.path.isfile(postFilename + '.tts'):
domainFull = getFullDomain(domain, port)
updateSpeaker(baseDir, httpPrefix,
@ -2945,7 +2945,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
print('ERROR: unable to update ' + boxname + ' index')
else:
if boxname == 'inbox':
if isRecentPost(postJsonObject):
if isRecentPost(postJsonObject, 3):
domainFull = getFullDomain(domain, port)
updateSpeaker(baseDir, httpPrefix,
nickname, domain, domainFull,

View File

@ -2536,7 +2536,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
toDomain = getFullDomain(toDomain, toPort)
toDomainUrl = httpPrefix + '://' + toDomain
if not siteIsActive(toDomainUrl):
if not siteIsActive(toDomainUrl, 10):
print('Domain is inactive: ' + toDomainUrl)
return 9
print('Domain is active: ' + toDomainUrl)
@ -3043,7 +3043,7 @@ def sendToFollowers(session, baseDir: str,
# check that the follower's domain is active
followerDomainUrl = httpPrefix + '://' + followerDomain
if not siteIsActive(followerDomainUrl):
if not siteIsActive(followerDomainUrl, 10):
print('Sending post to followers domain is inactive: ' +
followerDomainUrl)
continue
@ -3547,7 +3547,7 @@ def _createBoxIndexed(recentPostsCache: {},
nickname: str, domain: str, port: int, httpPrefix: str,
itemsPerPage: int, headerOnly: bool, authorized: bool,
newswireVotesThreshold: int, positiveVoting: bool,
votingTimeMins: int, pageNumber: int = None) -> {}:
votingTimeMins: int, pageNumber: int) -> {}:
"""Constructs the box feed for a person with the given nickname
"""
if not authorized or not pageNumber:
@ -4072,8 +4072,8 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
def downloadFollowCollection(signingPrivateKeyPem: str,
followType: str,
session, httpPrefix: str,
actor: str, pageNumber: int = 1,
noOfPages: int = 1, debug: bool = False) -> []:
actor: str, pageNumber: int,
noOfPages: int, debug: bool) -> []:
"""Returns a list of following/followers for the given actor
by downloading the json for their following/followers collection
"""

View File

@ -452,7 +452,7 @@ def getSharesFeedForPerson(baseDir: str,
domain: str, port: int,
path: str, httpPrefix: str,
sharesFileType: str,
sharesPerPage: int = 12) -> {}:
sharesPerPage: int) -> {}:
"""Returns the shares for an account from GET requests
"""
if '/' + sharesFileType not in path:
@ -1574,7 +1574,7 @@ def _updateFederatedSharesCache(session, sharedItemsFederatedDomains: [],
if not tokensJson.get(federatedDomainFull):
# token has been obtained for the other domain
continue
if not siteIsActive(httpPrefix + '://' + federatedDomainFull):
if not siteIsActive(httpPrefix + '://' + federatedDomainFull, 10):
continue
if sharesFileType == 'shares':
url = httpPrefix + '://' + federatedDomainFull + '/catalog'

View File

@ -93,7 +93,7 @@ def _siteActiveHttpRequest(loc, timeout: int):
return result
def siteIsActive(url: str, timeout: int = 10) -> bool:
def siteIsActive(url: str, timeout: int) -> bool:
"""Returns true if the current url is resolvable.
This can be used to check that an instance is online before
trying to send posts to it.

View File

@ -3579,9 +3579,10 @@ def _testJsonld():
def _testSiteIsActive():
print('testSiteIsActive')
assert(siteIsActive('https://archive.org'))
assert(siteIsActive('https://mastodon.social'))
assert(not siteIsActive('https://notarealwebsite.a.b.c'))
timeout = 10
assert(siteIsActive('https://archive.org', timeout))
assert(siteIsActive('https://mastodon.social', timeout))
assert(not siteIsActive('https://notarealwebsite.a.b.c', timeout))
def _testRemoveHtml():

View File

@ -75,7 +75,7 @@ class threadWithTrace(threading.Thread):
def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
timeoutMins: int = 30) -> None:
timeoutMins: int) -> None:
"""Removes threads whose execution has completed
"""
if len(threadsList) == 0:

View File

@ -209,8 +209,7 @@ def hasUsersPath(pathStr: str) -> bool:
return False
def validPostDate(published: str, maxAgeDays: int = 90,
debug: bool = False) -> bool:
def validPostDate(published: str, maxAgeDays: int, debug: bool) -> bool:
"""Returns true if the published date is recent and is not in the future
"""
baselineTime = datetime.datetime(1970, 1, 1)
@ -254,7 +253,7 @@ def getFullDomain(domain: str, port: int) -> str:
def isDormant(baseDir: str, nickname: str, domain: str, actor: str,
dormantMonths: int = 3) -> bool:
dormantMonths: int) -> bool:
"""Is the given followed actor dormant, from the standpoint
of the given account
"""
@ -2433,7 +2432,7 @@ def mediaFileMimeType(filename: str) -> str:
return extensions[fileExt]
def isRecentPost(postJsonObject: {}, maxDays: int = 3) -> bool:
def isRecentPost(postJsonObject: {}, maxDays: int) -> bool:
""" Is the given post recent?
"""
if not hasObjectDict(postJsonObject):

View File

@ -32,7 +32,7 @@ def loadPeertubeInstances(baseDir: str, peertubeInstances: []) -> None:
def _addEmbeddedVideoFromSites(translate: {}, content: str,
peertubeInstances: [],
width: int = 400, height: int = 300) -> str:
width: int, height: int) -> str:
"""Adds embedded videos
"""
if '>vimeo.com/' in content:
@ -250,6 +250,6 @@ def addEmbeddedElements(translate: {}, content: str,
"""Adds embedded elements for various media types
"""
content = _addEmbeddedVideoFromSites(translate, content,
peertubeInstances)
peertubeInstances, 400, 300)
content = _addEmbeddedAudio(translate, content)
return _addEmbeddedVideo(translate, content)

View File

@ -132,7 +132,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
followersList = \
downloadFollowCollection(signingPrivateKeyPem,
'followers', session,
httpPrefix, searchActor, 1, 5)
httpPrefix, searchActor, 1, 5, debug)
blockedFollowers = []
for followerActor in followersList:
followerNickname = getNicknameFromActor(followerActor)
@ -146,7 +146,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
followingList = \
downloadFollowCollection(signingPrivateKeyPem,
'following', session,
httpPrefix, searchActor, 1, 5)
httpPrefix, searchActor, 1, 5, debug)
blockedFollowing = []
for followingActor in followingList:
followingNickname = getNicknameFromActor(followingActor)

View File

@ -1403,7 +1403,7 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
postActor, nickname, domainFull, False)
# create a file for use by text-to-speech
if isRecentPost(postJsonObject):
if isRecentPost(postJsonObject, 3):
if postJsonObject.get('actor'):
if not os.path.isfile(announceFilename + '.tts'):
updateSpeaker(baseDir, httpPrefix,