Argument types

merge-requests/30/head
Bob Mottram 2021-06-20 12:28:35 +01:00
parent 5d5020a6e4
commit 546dda34bb
20 changed files with 142 additions and 118 deletions

View File

@ -30,7 +30,8 @@ def getHashtagCategory(baseDir: str, hashtag: str) -> str:
return '' return ''
def getHashtagCategories(baseDir: str, recent=False, category=None) -> None: def getHashtagCategories(baseDir: str,
recent: bool = False, category: str = None) -> None:
"""Returns a dictionary containing hashtag categories """Returns a dictionary containing hashtag categories
""" """
maxTagLength = 42 maxTagLength = 42
@ -128,7 +129,7 @@ def _validHashtagCategory(category: str) -> bool:
def setHashtagCategory(baseDir: str, hashtag: str, category: str, def setHashtagCategory(baseDir: str, hashtag: str, category: str,
force=False) -> bool: force: bool = False) -> bool:
"""Sets the category for the hashtag """Sets the category for the hashtag
""" """
if not _validHashtagCategory(category): if not _validHashtagCategory(category):

View File

@ -736,7 +736,8 @@ def _autoTag(baseDir: str, nickname: str, domain: str,
def addHtmlTags(baseDir: str, httpPrefix: str, def addHtmlTags(baseDir: str, httpPrefix: str,
nickname: str, domain: str, content: str, nickname: str, domain: str, content: str,
recipients: [], hashtags: {}, isJsonContent=False) -> str: recipients: [], hashtags: {},
isJsonContent: bool = False) -> str:
""" Replaces plaintext mentions such as @nick@domain into html """ Replaces plaintext mentions such as @nick@domain into html
by matching against known following accounts by matching against known following accounts
""" """
@ -923,7 +924,7 @@ def extractMediaInFormPOST(postBytes, boundary, name: str):
def saveMediaInFormPOST(mediaBytes, debug: bool, def saveMediaInFormPOST(mediaBytes, debug: bool,
filenameBase=None) -> (str, str): filenameBase: str = None) -> (str, str):
"""Saves the given media bytes extracted from http form POST """Saves the given media bytes extracted from http form POST
Returns the filename and attachment type Returns the filename and attachment type
""" """
@ -1007,8 +1008,8 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
return filename, attachmentMediaType return filename, attachmentMediaType
def extractTextFieldsInPOST(postBytes, boundary, debug: bool, def extractTextFieldsInPOST(postBytes, boundary: str, debug: bool,
unitTestData=None) -> {}: unitTestData: str = None) -> {}:
"""Returns a dictionary containing the text fields of a http form POST """Returns a dictionary containing the text fields of a http form POST
The boundary argument comes from the http header The boundary argument comes from the http header
""" """

View File

@ -1009,7 +1009,7 @@ class PubServer(BaseHTTPRequestHandler):
return True return True
def _postToOutbox(self, messageJson: {}, version: str, def _postToOutbox(self, messageJson: {}, version: str,
postToNickname=None) -> bool: postToNickname: str = None) -> bool:
"""post is received by the outbox """post is received by the outbox
Client to server message post Client to server message post
https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery
@ -14878,14 +14878,19 @@ def runDaemon(logLoginFailures: bool,
baseDir: str, domain: str, baseDir: str, domain: str,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
YTReplacementDomain: str, YTReplacementDomain: str,
port=80, proxyPort=80, httpPrefix='https', port: int = 80, proxyPort: int = 80,
fedList=[], maxMentions=10, maxEmoji=10, httpPrefix: str = 'https',
authenticatedFetch=False, fedList: [] = [],
proxyType=None, maxReplies=64, maxMentions: int = 10, maxEmoji: int = 10,
domainMaxPostsPerDay=8640, accountMaxPostsPerDay=864, authenticatedFetch: bool = False,
allowDeletion=False, debug=False, unitTest=False, proxyType: str = None, maxReplies: int = 64,
instanceOnlySkillsSearch=False, sendThreads=[], domainMaxPostsPerDay: int = 8640,
manualFollowerApproval=True) -> None: accountMaxPostsPerDay: int = 864,
allowDeletion: bool = False,
debug: bool = False, unitTest: bool = False,
instanceOnlySkillsSearch: bool = False,
sendThreads: [] = [],
manualFollowerApproval: bool = True) -> None:
if len(domain) == 0: if len(domain) == 0:
domain = 'localhost' domain = 'localhost'
if '.' not in domain: if '.' not in domain:

View File

@ -393,8 +393,8 @@ def _textToSpeech(sayStr: str, screenreader: str,
def _sayCommand(content: str, sayStr: str, screenreader: str, def _sayCommand(content: str, sayStr: str, screenreader: str,
systemLanguage: str, systemLanguage: str,
espeak=None, espeak=None,
speakerName='screen reader', speakerName: str = 'screen reader',
speakerGender='They/Them') -> None: speakerGender: str = 'They/Them') -> None:
"""Speaks a command """Speaks a command
""" """
print(content) print(content)
@ -927,9 +927,9 @@ def _desktopShowBox(indent: str,
yourActor: str, boxName: str, boxJson: {}, yourActor: str, boxName: str, boxJson: {},
translate: {}, translate: {},
screenreader: str, systemLanguage: str, espeak, screenreader: str, systemLanguage: str, espeak,
pageNumber=1, pageNumber: int = 1,
newReplies=False, newReplies: bool = False,
newDMs=False) -> bool: newDMs: bool = False) -> bool:
"""Shows online timeline """Shows online timeline
""" """
numberWidth = 2 numberWidth = 2

View File

@ -238,8 +238,8 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str,
def unfollowAccount(baseDir: str, nickname: str, domain: str, def unfollowAccount(baseDir: str, nickname: str, domain: str,
followNickname: str, followDomain: str, followNickname: str, followDomain: str,
followFile='following.txt', followFile: str = 'following.txt',
debug=False) -> bool: debug: bool = False) -> bool:
"""Removes a person to the follow list """Removes a person to the follow list
""" """
if ':' in domain: if ':' in domain:
@ -287,7 +287,7 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
def unfollowerOfAccount(baseDir: str, nickname: str, domain: str, def unfollowerOfAccount(baseDir: str, nickname: str, domain: str,
followerNickname: str, followerDomain: str, followerNickname: str, followerDomain: str,
debug=False) -> bool: debug: bool = False) -> bool:
"""Remove a follower of a person """Remove a follower of a person
""" """
return unfollowAccount(baseDir, nickname, domain, return unfollowAccount(baseDir, nickname, domain,

2
git.py
View File

@ -44,7 +44,7 @@ def _getGitProjectName(baseDir: str, nickname: str, domain: str,
def isGitPatch(baseDir: str, nickname: str, domain: str, def isGitPatch(baseDir: str, nickname: str, domain: str,
messageType: str, messageType: str,
subject: str, content: str, subject: str, content: str,
checkProjectName=True) -> bool: checkProjectName: bool = True) -> bool:
"""Is the given post content a git patch? """Is the given post content a git patch?
""" """
if messageType != 'Note' and \ if messageType != 'Note' and \

View File

@ -173,8 +173,8 @@ def _isHappeningPost(postJsonObject: {}) -> bool:
def getTodaysEvents(baseDir: str, nickname: str, domain: str, def getTodaysEvents(baseDir: str, nickname: str, domain: str,
currYear=None, currMonthNumber=None, currYear: int = None, currMonthNumber: int = None,
currDayOfMonth=None) -> {}: currDayOfMonth: int = None) -> {}:
"""Retrieves calendar events for today """Retrieves calendar events for today
Returns a dictionary of lists containing Event and Place activities Returns a dictionary of lists containing Event and Place activities
""" """

View File

@ -248,7 +248,7 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict,
path: str, GETmethod: bool, path: str, GETmethod: bool,
messageBodyDigest: str, messageBodyDigest: str,
messageBodyJsonStr: str, debug: bool, messageBodyJsonStr: str, debug: bool,
noRecencyCheck=False) -> bool: noRecencyCheck: bool = False) -> bool:
"""Returns true or false depending on if the key that we plugged in here """Returns true or false depending on if the key that we plugged in here
validates against the headers, method, and path. validates against the headers, method, and path.
publicKeyPem - the public key from an rsa key pair publicKeyPem - the public key from an rsa key pair

View File

@ -145,7 +145,7 @@ def _addNewswireDictEntry(baseDir: str, domain: str,
] ]
def _validFeedDate(pubDate: str, debug=False) -> bool: def _validFeedDate(pubDate: str, debug: bool = False) -> bool:
# convert from YY-MM-DD HH:MM:SS+00:00 to # convert from YY-MM-DD HH:MM:SS+00:00 to
# YY-MM-DDTHH:MM:SSZ # YY-MM-DDTHH:MM:SSZ
postDate = pubDate.replace(' ', 'T').replace('+00:00', 'Z') postDate = pubDate.replace(' ', 'T').replace('+00:00', 'Z')
@ -226,7 +226,7 @@ def loadHashtagCategories(baseDir: str, language: str) -> None:
def _xml2StrToHashtagCategories(baseDir: str, xmlStr: str, def _xml2StrToHashtagCategories(baseDir: str, xmlStr: str,
maxCategoriesFeedItemSizeKb: int, maxCategoriesFeedItemSizeKb: int,
force=False) -> None: force: bool = False) -> None:
"""Updates hashtag categories based upon an rss feed """Updates hashtag categories based upon an rss feed
""" """
rssItems = xmlStr.split('<item>') rssItems = xmlStr.split('<item>')

View File

@ -220,7 +220,7 @@ def getDefaultPersonContext() -> str:
def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int, def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
httpPrefix: str, saveToFile: bool, httpPrefix: str, saveToFile: bool,
manualFollowerApproval: bool, manualFollowerApproval: bool,
password=None) -> (str, str, {}, {}): password: str = None) -> (str, str, {}, {}):
"""Returns the private key, public key, actor and webfinger endpoint """Returns the private key, public key, actor and webfinger endpoint
""" """
privateKeyPem, publicKeyPem = generateRSAKey() privateKeyPem, publicKeyPem = generateRSAKey()
@ -421,7 +421,7 @@ def registerAccount(baseDir: str, httpPrefix: str, domain: str, port: int,
def createGroup(baseDir: str, nickname: str, domain: str, port: int, def createGroup(baseDir: str, nickname: str, domain: str, port: int,
httpPrefix: str, saveToFile: bool, httpPrefix: str, saveToFile: bool,
password=None) -> (str, str, {}, {}): password: str = None) -> (str, str, {}, {}):
"""Returns a group """Returns a group
""" """
(privateKeyPem, publicKeyPem, (privateKeyPem, publicKeyPem,
@ -451,7 +451,7 @@ def savePersonQrcode(baseDir: str,
def createPerson(baseDir: str, nickname: str, domain: str, port: int, def createPerson(baseDir: str, nickname: str, domain: str, port: int,
httpPrefix: str, saveToFile: bool, httpPrefix: str, saveToFile: bool,
manualFollowerApproval: bool, manualFollowerApproval: bool,
password=None) -> (str, str, {}, {}): password: str = None) -> (str, str, {}, {}):
"""Returns the private key, public key, actor and webfinger endpoint """Returns the private key, public key, actor and webfinger endpoint
""" """
if not validNickname(domain, nickname): if not validNickname(domain, nickname):
@ -1210,7 +1210,7 @@ def setPersonNotes(baseDir: str, nickname: str, domain: str,
def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool, def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
debug: bool, quiet=False) -> ({}, {}): debug: bool, quiet: bool = False) -> ({}, {}):
"""Returns the actor json """Returns the actor json
""" """
if debug: if debug:

3
pgp.py
View File

@ -332,7 +332,8 @@ def _pgpEncrypt(content: str, recipientPubKey: str) -> str:
return encryptResult return encryptResult
def _getPGPPublicKeyFromActor(domain: str, handle: str, actorJson=None) -> str: def _getPGPPublicKeyFromActor(domain: str, handle: str,
actorJson: {} = None) -> str:
"""Searches tags on the actor to see if there is any PGP """Searches tags on the actor to see if there is any PGP
public key specified public key specified
""" """

130
posts.py
View File

@ -121,8 +121,8 @@ def noOfFollowersOnDomain(baseDir: str, handle: str,
return ctr return ctr
def _getPersonKey(nickname: str, domain: str, baseDir: str, keyType='public', def _getPersonKey(nickname: str, domain: str, baseDir: str,
debug=False): keyType: str = 'public', debug: bool = False):
"""Returns the public or private key of a person """Returns the public or private key of a person
""" """
handle = nickname + '@' + domain handle = nickname + '@' + domain
@ -147,7 +147,7 @@ def _cleanHtml(rawHtml: str) -> str:
return html.unescape(text) return html.unescape(text)
def getUserUrl(wfRequest: {}, sourceId=0, debug=False) -> str: def getUserUrl(wfRequest: {}, sourceId: int = 0, debug: bool = False) -> str:
"""Gets the actor url from a webfinger request """Gets the actor url from a webfinger request
""" """
if not wfRequest.get('links'): if not wfRequest.get('links'):
@ -871,15 +871,18 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
mediaType: str, imageDescription: str, city: str, mediaType: str, imageDescription: str, city: str,
isModerationReport: bool, isModerationReport: bool,
isArticle: bool, isArticle: bool,
inReplyTo=None, inReplyTo: str = None,
inReplyToAtomUri=None, subject=None, schedulePost=False, inReplyToAtomUri: str = None,
eventDate=None, eventTime=None, location=None, subject: str = None, schedulePost: bool = False,
eventUUID=None, category=None, joinMode=None, eventDate: str = None, eventTime: str = None,
endDate=None, endTime=None, location: str = None,
maximumAttendeeCapacity=None, eventUUID: str = None, category: str = None,
repliesModerationOption=None, joinMode: str = None,
anonymousParticipationEnabled=None, endDate: str = None, endTime: str = None,
eventStatus=None, ticketUrl=None) -> {}: maximumAttendeeCapacity: int = None,
repliesModerationOption: str = None,
anonymousParticipationEnabled: bool = None,
eventStatus: str = None, ticketUrl: str = None) -> {}:
"""Creates a message """Creates a message
""" """
content = removeInvalidChars(content) content = removeInvalidChars(content)
@ -1399,10 +1402,12 @@ def createPublicPost(baseDir: str,
clientToServer: bool, commentsEnabled: bool, clientToServer: bool, commentsEnabled: bool,
attachImageFilename: str, mediaType: str, attachImageFilename: str, mediaType: str,
imageDescription: str, city: str, imageDescription: str, city: str,
inReplyTo=None, inReplyToAtomUri=None, subject=None, inReplyTo: str = None,
schedulePost=False, inReplyToAtomUri: str = None, subject: str = None,
eventDate=None, eventTime=None, location=None, schedulePost: bool = False,
isArticle=False) -> {}: eventDate: str = None, eventTime: str = None,
location: str = None,
isArticle: bool = False) -> {}:
"""Public post """Public post
""" """
domainFull = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
@ -1472,9 +1477,10 @@ def createBlogPost(baseDir: str,
clientToServer: bool, commentsEnabled: bool, clientToServer: bool, commentsEnabled: bool,
attachImageFilename: str, mediaType: str, attachImageFilename: str, mediaType: str,
imageDescription: str, city: str, imageDescription: str, city: str,
inReplyTo=None, inReplyToAtomUri=None, subject=None, inReplyTo: str = None, inReplyToAtomUri: str = None,
schedulePost=False, subject: str = None, schedulePost: bool = False,
eventDate=None, eventTime=None, location=None) -> {}: eventDate: str = None, eventTime: str = None,
location: str = None) -> {}:
blogJson = \ blogJson = \
createPublicPost(baseDir, createPublicPost(baseDir,
nickname, domain, port, httpPrefix, nickname, domain, port, httpPrefix,
@ -1570,9 +1576,10 @@ def createUnlistedPost(baseDir: str,
clientToServer: bool, commentsEnabled: bool, clientToServer: bool, commentsEnabled: bool,
attachImageFilename: str, mediaType: str, attachImageFilename: str, mediaType: str,
imageDescription: str, city: str, imageDescription: str, city: str,
inReplyTo=None, inReplyToAtomUri=None, subject=None, inReplyTo: str = None, inReplyToAtomUri: str = None,
schedulePost=False, subject: str = None, schedulePost: bool = False,
eventDate=None, eventTime=None, location=None) -> {}: eventDate: str = None, eventTime: str = None,
location: str = None) -> {}:
"""Unlisted post. This has the #Public and followers links inverted. """Unlisted post. This has the #Public and followers links inverted.
""" """
domainFull = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
@ -1599,10 +1606,11 @@ def createFollowersOnlyPost(baseDir: str,
clientToServer: bool, commentsEnabled: bool, clientToServer: bool, commentsEnabled: bool,
attachImageFilename: str, mediaType: str, attachImageFilename: str, mediaType: str,
imageDescription: str, city: str, imageDescription: str, city: str,
inReplyTo=None, inReplyToAtomUri=None, inReplyTo: str = None,
subject=None, schedulePost=False, inReplyToAtomUri: str = None,
eventDate=None, eventTime=None, subject: str = None, schedulePost: bool = False,
location=None) -> {}: eventDate: str = None, eventTime: str = None,
location: str = None) -> {}:
"""Followers only post """Followers only post
""" """
domainFull = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
@ -1629,14 +1637,15 @@ def createEventPost(baseDir: str,
clientToServer: bool, commentsEnabled: bool, clientToServer: bool, commentsEnabled: bool,
attachImageFilename: str, mediaType: str, attachImageFilename: str, mediaType: str,
imageDescription: str, city: str, imageDescription: str, city: str,
subject=None, schedulePost=False, subject: str = None, schedulePost: str = False,
eventDate=None, eventTime=None, eventDate: str = None, eventTime: str = None,
location=None, category=None, joinMode=None, location: str = None, category: str = None,
endDate=None, endTime=None, joinMode: str = None,
maximumAttendeeCapacity=None, endDate: str = None, endTime: str = None,
repliesModerationOption=None, maximumAttendeeCapacity: int = None,
anonymousParticipationEnabled=None, repliesModerationOption: str = None,
eventStatus=None, ticketUrl=None) -> {}: anonymousParticipationEnabled: bool = None,
eventStatus: str = None, ticketUrl: str = None) -> {}:
"""Mobilizon-type Event post """Mobilizon-type Event post
""" """
if not attachImageFilename: if not attachImageFilename:
@ -1714,11 +1723,12 @@ def createDirectMessagePost(baseDir: str,
commentsEnabled: bool, commentsEnabled: bool,
attachImageFilename: str, mediaType: str, attachImageFilename: str, mediaType: str,
imageDescription: str, city: str, imageDescription: str, city: str,
inReplyTo=None, inReplyToAtomUri=None, inReplyTo: str = None,
subject=None, debug=False, inReplyToAtomUri: str = None,
schedulePost=False, subject: str = None, debug: bool = False,
eventDate=None, eventTime=None, schedulePost: bool = False,
location=None) -> {}: eventDate: str = None, eventTime: str = None,
location: str = None) -> {}:
"""Direct Message post """Direct Message post
""" """
content = resolvePetnames(baseDir, nickname, domain, content) content = resolvePetnames(baseDir, nickname, domain, content)
@ -1759,7 +1769,7 @@ def createReportPost(baseDir: str,
clientToServer: bool, commentsEnabled: bool, clientToServer: bool, commentsEnabled: bool,
attachImageFilename: str, mediaType: str, attachImageFilename: str, mediaType: str,
imageDescription: str, city: str, imageDescription: str, city: str,
debug: bool, subject=None) -> {}: debug: bool, subject: str = None) -> {}:
"""Send a report to moderators """Send a report to moderators
""" """
domainFull = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
@ -1916,8 +1926,8 @@ def sendPost(projectVersion: str,
federationList: [], sendThreads: [], postLog: [], federationList: [], sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
isArticle: bool, isArticle: bool,
debug=False, inReplyTo=None, debug: bool = False, inReplyTo: str = None,
inReplyToAtomUri=None, subject=None) -> int: inReplyToAtomUri: str = None, subject: str = None) -> int:
"""Post to another inbox """Post to another inbox
""" """
withDigest = True withDigest = True
@ -2035,8 +2045,10 @@ def sendPostViaServer(projectVersion: str,
attachImageFilename: str, mediaType: str, attachImageFilename: str, mediaType: str,
imageDescription: str, city: str, imageDescription: str, city: str,
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
isArticle: bool, debug=False, inReplyTo=None, isArticle: bool, debug: bool = False,
inReplyToAtomUri=None, subject=None) -> int: inReplyTo: str = None,
inReplyToAtomUri: str = None,
subject: str = None) -> int:
"""Send a post via a proxy (c2s) """Send a post via a proxy (c2s)
""" """
if not session: if not session:
@ -2784,7 +2796,7 @@ def sendToFollowersThread(session, baseDir: str,
def createInbox(recentPostsCache: {}, def createInbox(recentPostsCache: {},
session, baseDir: str, nickname: str, domain: str, port: int, session, baseDir: str, nickname: str, domain: str, port: int,
httpPrefix: str, itemsPerPage: int, headerOnly: bool, httpPrefix: str, itemsPerPage: int, headerOnly: bool,
pageNumber=None) -> {}: pageNumber: int = None) -> {}:
return _createBoxIndexed(recentPostsCache, return _createBoxIndexed(recentPostsCache,
session, baseDir, 'inbox', session, baseDir, 'inbox',
nickname, domain, port, httpPrefix, nickname, domain, port, httpPrefix,
@ -2794,7 +2806,7 @@ def createInbox(recentPostsCache: {},
def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str, def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int, port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber=None) -> {}: headerOnly: bool, pageNumber: int = None) -> {}:
return _createBoxIndexed({}, session, baseDir, 'tlbookmarks', return _createBoxIndexed({}, session, baseDir, 'tlbookmarks',
nickname, domain, nickname, domain,
port, httpPrefix, itemsPerPage, headerOnly, port, httpPrefix, itemsPerPage, headerOnly,
@ -2804,7 +2816,7 @@ def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
def createEventsTimeline(recentPostsCache: {}, def createEventsTimeline(recentPostsCache: {},
session, baseDir: str, nickname: str, domain: str, session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int, port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber=None) -> {}: headerOnly: bool, pageNumber: int = None) -> {}:
return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlevents', return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlevents',
nickname, domain, nickname, domain,
port, httpPrefix, itemsPerPage, headerOnly, port, httpPrefix, itemsPerPage, headerOnly,
@ -2814,7 +2826,7 @@ def createEventsTimeline(recentPostsCache: {},
def createDMTimeline(recentPostsCache: {}, def createDMTimeline(recentPostsCache: {},
session, baseDir: str, nickname: str, domain: str, session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int, port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber=None) -> {}: headerOnly: bool, pageNumber: int = None) -> {}:
return _createBoxIndexed(recentPostsCache, return _createBoxIndexed(recentPostsCache,
session, baseDir, 'dm', nickname, session, baseDir, 'dm', nickname,
domain, port, httpPrefix, itemsPerPage, domain, port, httpPrefix, itemsPerPage,
@ -2824,7 +2836,7 @@ def createDMTimeline(recentPostsCache: {},
def createRepliesTimeline(recentPostsCache: {}, def createRepliesTimeline(recentPostsCache: {},
session, baseDir: str, nickname: str, domain: str, session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int, port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber=None) -> {}: headerOnly: bool, pageNumber: int = None) -> {}:
return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlreplies', return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlreplies',
nickname, domain, port, httpPrefix, nickname, domain, port, httpPrefix,
itemsPerPage, headerOnly, True, itemsPerPage, headerOnly, True,
@ -2833,7 +2845,7 @@ def createRepliesTimeline(recentPostsCache: {},
def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str, def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int, port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber=None) -> {}: headerOnly: bool, pageNumber: int = None) -> {}:
return _createBoxIndexed({}, session, baseDir, 'tlblogs', nickname, return _createBoxIndexed({}, session, baseDir, 'tlblogs', nickname,
domain, port, httpPrefix, domain, port, httpPrefix,
itemsPerPage, headerOnly, True, itemsPerPage, headerOnly, True,
@ -2842,7 +2854,7 @@ def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
def createFeaturesTimeline(session, baseDir: str, nickname: str, domain: str, def createFeaturesTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int, port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber=None) -> {}: headerOnly: bool, pageNumber: int = None) -> {}:
return _createBoxIndexed({}, session, baseDir, 'tlfeatures', nickname, return _createBoxIndexed({}, session, baseDir, 'tlfeatures', nickname,
domain, port, httpPrefix, domain, port, httpPrefix,
itemsPerPage, headerOnly, True, itemsPerPage, headerOnly, True,
@ -2851,7 +2863,7 @@ def createFeaturesTimeline(session, baseDir: str, nickname: str, domain: str,
def createMediaTimeline(session, baseDir: str, nickname: str, domain: str, def createMediaTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int, port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber=None) -> {}: headerOnly: bool, pageNumber: int = None) -> {}:
return _createBoxIndexed({}, session, baseDir, 'tlmedia', nickname, return _createBoxIndexed({}, session, baseDir, 'tlmedia', nickname,
domain, port, httpPrefix, domain, port, httpPrefix,
itemsPerPage, headerOnly, True, itemsPerPage, headerOnly, True,
@ -2862,7 +2874,7 @@ def createNewsTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int, port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, newswireVotesThreshold: int, headerOnly: bool, newswireVotesThreshold: int,
positiveVoting: bool, votingTimeMins: int, positiveVoting: bool, votingTimeMins: int,
pageNumber=None) -> {}: pageNumber: int = None) -> {}:
return _createBoxIndexed({}, session, baseDir, 'outbox', 'news', return _createBoxIndexed({}, session, baseDir, 'outbox', 'news',
domain, port, httpPrefix, domain, port, httpPrefix,
itemsPerPage, headerOnly, True, itemsPerPage, headerOnly, True,
@ -2873,7 +2885,7 @@ def createNewsTimeline(session, baseDir: str, nickname: str, domain: str,
def createOutbox(session, baseDir: str, nickname: str, domain: str, def createOutbox(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, port: int, httpPrefix: str,
itemsPerPage: int, headerOnly: bool, authorized: bool, itemsPerPage: int, headerOnly: bool, authorized: bool,
pageNumber=None) -> {}: pageNumber: int = None) -> {}:
return _createBoxIndexed({}, session, baseDir, 'outbox', return _createBoxIndexed({}, session, baseDir, 'outbox',
nickname, domain, port, httpPrefix, nickname, domain, port, httpPrefix,
itemsPerPage, headerOnly, authorized, itemsPerPage, headerOnly, authorized,
@ -2882,7 +2894,7 @@ def createOutbox(session, baseDir: str, nickname: str, domain: str,
def createModeration(baseDir: str, nickname: str, domain: str, port: int, def createModeration(baseDir: str, nickname: str, domain: str, port: int,
httpPrefix: str, itemsPerPage: int, headerOnly: bool, httpPrefix: str, itemsPerPage: int, headerOnly: bool,
pageNumber=None) -> {}: pageNumber: int = None) -> {}:
boxDir = createPersonDir(nickname, domain, baseDir, 'inbox') boxDir = createPersonDir(nickname, domain, baseDir, 'inbox')
boxname = 'moderation' boxname = 'moderation'
@ -3137,7 +3149,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=None) -> {}: votingTimeMins: int, pageNumber: int = None) -> {}:
"""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:
@ -3611,9 +3623,9 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
def downloadFollowCollection(followType: str, def downloadFollowCollection(followType: str,
session, httpPrefix, session, httpPrefix: str,
actor: str, pageNumber=1, actor: str, pageNumber: int = 1,
noOfPages=1, debug=False) -> []: noOfPages: int = 1, debug: bool = False) -> []:
"""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

@ -84,8 +84,9 @@ def urlExists(session, url: str, timeoutSec=3,
def getJson(session, url: str, headers: {}, params: {}, debug: bool, def getJson(session, url: str, headers: {}, params: {}, debug: bool,
version='1.2.0', httpPrefix='https', version: str = '1.2.0', httpPrefix: str = 'https',
domain='testdomain', timeoutSec=20, quiet=False) -> {}: domain: str = 'testdomain',
timeoutSec: int = 20, quiet: bool = False) -> {}:
if not isinstance(url, str): if not isinstance(url, str):
if debug and not quiet: if debug and not quiet:
print('url: ' + str(url)) print('url: ' + str(url))
@ -149,7 +150,8 @@ def getJson(session, url: str, headers: {}, params: {}, debug: bool,
def postJson(session, postJsonObject: {}, federationList: [], def postJson(session, postJsonObject: {}, federationList: [],
inboxUrl: str, headers: {}, timeoutSec=60, quiet=False) -> str: inboxUrl: str, headers: {}, timeoutSec: int = 60,
quiet: bool = False) -> str:
"""Post a json message to the inbox of another person """Post a json message to the inbox of another person
""" """
# check that we are posting to a permitted domain # check that we are posting to a permitted domain
@ -195,8 +197,8 @@ def postJsonString(session, postJsonStr: str,
inboxUrl: str, inboxUrl: str,
headers: {}, headers: {},
debug: bool, debug: bool,
timeoutSec=30, timeoutSec: int = 30,
quiet=False) -> (bool, bool): quiet: bool = False) -> (bool, bool):
"""Post a json message string to the inbox of another person """Post a json message string to the inbox of another person
The second boolean returned is true if the send is unauthorized The second boolean returned is true if the send is unauthorized
NOTE: Here we post a string rather than the original json so that NOTE: Here we post a string rather than the original json so that

View File

@ -110,7 +110,8 @@ def hasUsersPath(pathStr: str) -> bool:
return False return False
def validPostDate(published: str, maxAgeDays=90, debug=False) -> bool: def validPostDate(published: str, maxAgeDays: int = 90,
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)
@ -545,7 +546,7 @@ def loadJsonOnionify(filename: str, domain: str, onionDomain: str,
return jsonObject return jsonObject
def getStatusNumber(publishedStr=None) -> (str, str): def getStatusNumber(publishedStr: str = None) -> (str, str):
"""Returns the status number and published date """Returns the status number and published date
""" """
if not publishedStr: if not publishedStr:
@ -1146,7 +1147,7 @@ def clearFromPostCaches(baseDir: str, recentPostsCache: {},
def locatePost(baseDir: str, nickname: str, domain: str, def locatePost(baseDir: str, nickname: str, domain: str,
postUrl: str, replies=False) -> str: postUrl: str, replies: bool = False) -> str:
"""Returns the filename for the given status post url """Returns the filename for the given status post url
""" """
if not replies: if not replies:
@ -1535,7 +1536,7 @@ def isPublicPost(postJsonObject: {}) -> bool:
return False return False
def copytree(src: str, dst: str, symlinks=False, ignore=None): def copytree(src: str, dst: str, symlinks: str = False, ignore: bool = None):
"""Copy a directory """Copy a directory
""" """
for item in os.listdir(src): for item in os.listdir(src):

View File

@ -98,8 +98,9 @@ def htmlFrontScreen(rssIconAtTop: bool,
peertubeInstances: [], peertubeInstances: [],
allowLocalNetworkAccess: bool, allowLocalNetworkAccess: bool,
accessKeys: {}, accessKeys: {},
extraJson=None, extraJson: {} = None,
pageNumber=None, maxItemsPerPage=None) -> str: pageNumber: int = None,
maxItemsPerPage: int = None) -> str:
"""Show the news instance front screen """Show the news instance front screen
""" """
nickname = profileJson['preferredUsername'] nickname = profileJson['preferredUsername']

View File

@ -21,7 +21,7 @@ from webapp_utils import htmlFooter
def getHashtagCategoriesFeed(baseDir: str, def getHashtagCategoriesFeed(baseDir: str,
hashtagCategories=None) -> str: hashtagCategories: {} = None) -> str:
"""Returns an rss feed for hashtag categories """Returns an rss feed for hashtag categories
""" """
if not hashtagCategories: if not hashtagCategories:

View File

@ -55,7 +55,7 @@ def htmlLogin(cssCache: {}, translate: {},
baseDir: str, baseDir: str,
httpPrefix: str, domain: str, httpPrefix: str, domain: str,
systemLanguage: str, systemLanguage: str,
autocomplete=True) -> str: autocomplete: bool = True) -> str:
"""Shows the login screen """Shows the login screen
""" """
accounts = noOfAccounts(baseDir) accounts = noOfAccounts(baseDir)

View File

@ -1159,11 +1159,11 @@ def individualPostAsHtml(allowDownloads: bool,
peertubeInstances: [], peertubeInstances: [],
allowLocalNetworkAccess: bool, allowLocalNetworkAccess: bool,
themeName: str, themeName: str,
showRepeats=True, showRepeats: bool = True,
showIcons=False, showIcons: bool = False,
manuallyApprovesFollowers=False, manuallyApprovesFollowers: bool = False,
showPublicOnly=False, showPublicOnly: bool = False,
storeToCache=True) -> str: storeToCache: bool = True) -> str:
""" Shows a single post as html """ Shows a single post as html
""" """
if not postJsonObject: if not postJsonObject:

View File

@ -444,8 +444,8 @@ def htmlProfile(rssIconAtTop: bool,
allowLocalNetworkAccess: bool, allowLocalNetworkAccess: bool,
textModeBanner: str, textModeBanner: str,
debug: bool, accessKeys: {}, city: str, debug: bool, accessKeys: {}, city: str,
extraJson=None, pageNumber=None, extraJson: {} = None, pageNumber: int = None,
maxItemsPerPage=None) -> str: maxItemsPerPage: int = None) -> str:
"""Show the profile page as html """Show the profile page as html
""" """
nickname = profileJson['preferredUsername'] nickname = profileJson['preferredUsername']

View File

@ -104,7 +104,7 @@ def _markdownReplaceQuotes(markdown: str) -> str:
return result return result
def _markdownReplaceLinks(markdown: str, images=False) -> str: def _markdownReplaceLinks(markdown: str, images: bool = False) -> str:
"""Replaces markdown links with html """Replaces markdown links with html
Optionally replace image links Optionally replace image links
""" """
@ -442,7 +442,7 @@ def setBlogAddress(actorJson: {}, blogAddress: str) -> None:
def updateAvatarImageCache(session, baseDir: str, httpPrefix: str, def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
actor: str, avatarUrl: str, actor: str, avatarUrl: str,
personCache: {}, allowDownloads: bool, personCache: {}, allowDownloads: bool,
force=False, debug=False) -> str: force: bool = False, debug: bool = False) -> str:
"""Updates the cached avatar for the given actor """Updates the cached avatar for the given actor
""" """
if not avatarUrl: if not avatarUrl:
@ -1327,9 +1327,9 @@ def htmlHideFromScreenReader(htmlStr: str) -> str:
def htmlKeyboardNavigation(banner: str, links: {}, accessKeys: {}, def htmlKeyboardNavigation(banner: str, links: {}, accessKeys: {},
subHeading=None, subHeading: str = None,
usersPath=None, translate=None, usersPath: str = None, translate: {} = None,
followApprovals=False) -> str: followApprovals: bool = False) -> str:
"""Given a set of links return the html for keyboard navigation """Given a set of links return the html for keyboard navigation
""" """
htmlStr = '<div class="transparent"><ul>\n' htmlStr = '<div class="transparent"><ul>\n'