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 = \ followersList = \
downloadFollowCollection(signingPrivateKeyPem, downloadFollowCollection(signingPrivateKeyPem,
'followers', session, 'followers', session,
httpPrefix, personUrl, 1, 3) httpPrefix, personUrl, 1, 3, args.debug)
if followersList: if followersList:
for actor in followersList: for actor in followersList:
print(actor) print(actor)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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