Create variable

merge-requests/8/head
Bob Mottram 2020-11-01 17:18:05 +00:00
parent 769929268f
commit 2738254d0b
2 changed files with 49 additions and 34 deletions

View File

@ -279,6 +279,7 @@ def htmlBlogPostRSS2(authorized: bool,
handle: str, restrictToDomain: bool) -> str: handle: str, restrictToDomain: bool) -> str:
"""Returns the RSS version 2 feed for a single blog post """Returns the RSS version 2 feed for a single blog post
""" """
rssStr = ''
messageLink = '' messageLink = ''
if postJsonObject['object'].get('id'): if postJsonObject['object'].get('id'):
messageLink = postJsonObject['object']['id'].replace('/statuses/', '/') messageLink = postJsonObject['object']['id'].replace('/statuses/', '/')
@ -305,6 +306,7 @@ def htmlBlogPostRSS3(authorized: bool,
handle: str, restrictToDomain: bool) -> str: handle: str, restrictToDomain: bool) -> str:
"""Returns the RSS version 3 feed for a single blog post """Returns the RSS version 3 feed for a single blog post
""" """
rssStr = ''
messageLink = '' messageLink = ''
if postJsonObject['object'].get('id'): if postJsonObject['object'].get('id'):
messageLink = postJsonObject['object']['id'].replace('/statuses/', '/') messageLink = postJsonObject['object']['id'].replace('/statuses/', '/')

View File

@ -1147,7 +1147,7 @@ class PubServer(BaseHTTPRequestHandler):
self.headers['Authorization']) self.headers['Authorization'])
return False return False
def _clearLoginDetails(self, nickname: str, callingDomain: str): def _clearLoginDetails(self, nickname: str, callingDomain: str) -> None:
"""Clears login details for the given account """Clears login details for the given account
""" """
# remove any token # remove any token
@ -1160,7 +1160,8 @@ class PubServer(BaseHTTPRequestHandler):
callingDomain) callingDomain)
def _benchmarkGETtimings(self, GETstartTime, GETtimings: {}, def _benchmarkGETtimings(self, GETstartTime, GETtimings: {},
prevGetId: str, currGetId: str): prevGetId: str,
currGetId: str) -> None:
"""Updates a dictionary containing how long each segment of GET takes """Updates a dictionary containing how long each segment of GET takes
""" """
timeDiff = int((time.time() - GETstartTime) * 1000) timeDiff = int((time.time() - GETstartTime) * 1000)
@ -1175,7 +1176,7 @@ class PubServer(BaseHTTPRequestHandler):
print('GET TIMING ' + currGetId + ' = ' + str(timeDiff)) print('GET TIMING ' + currGetId + ' = ' + str(timeDiff))
def _benchmarkPOSTtimings(self, POSTstartTime, POSTtimings: [], def _benchmarkPOSTtimings(self, POSTstartTime, POSTtimings: [],
postID: int): postID: int) -> None:
"""Updates a list containing how long each segment of POST takes """Updates a list containing how long each segment of POST takes
""" """
if self.server.debug: if self.server.debug:
@ -1226,7 +1227,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
debug: bool): debug: bool) -> None:
"""Shows the login screen """Shows the login screen
""" """
# get the contents of POST containing login credentials # get the contents of POST containing login credentials
@ -1381,7 +1382,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
debug: bool): debug: bool) -> None:
"""Actions on the moderator screeen """Actions on the moderator screeen
""" """
usersPath = path.replace('/moderationaction', '') usersPath = path.replace('/moderationaction', '')
@ -1534,7 +1535,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
debug: bool): debug: bool) -> None:
"""Receive POST from person options screen """Receive POST from person options screen
""" """
pageNumber = 1 pageNumber = 1
@ -1916,7 +1917,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Confirm to unfollow """Confirm to unfollow
""" """
usersPath = path.split('/unfollowconfirm')[0] usersPath = path.split('/unfollowconfirm')[0]
@ -1995,7 +1997,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Confirm to follow """Confirm to follow
""" """
usersPath = path.split('/followconfirm')[0] usersPath = path.split('/followconfirm')[0]
@ -2078,7 +2081,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Confirms a block """Confirms a block
""" """
usersPath = path.split('/blockconfirm')[0] usersPath = path.split('/blockconfirm')[0]
@ -2166,7 +2170,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Confirms a unblock """Confirms a unblock
""" """
usersPath = path.split('/unblockconfirm')[0] usersPath = path.split('/unblockconfirm')[0]
@ -2255,7 +2260,8 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
port: int, searchForEmoji: bool, port: int, searchForEmoji: bool,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Receive a search query """Receive a search query
""" """
# get the page number # get the page number
@ -2489,7 +2495,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Receive a vote via POST """Receive a vote via POST
""" """
pageNumber = 1 pageNumber = 1
@ -2574,7 +2581,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Receives an image via POST """Receives an image via POST
""" """
if not self.outboxAuthenticated: if not self.outboxAuthenticated:
@ -2641,7 +2649,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Removes a shared item """Removes a shared item
""" """
usersPath = path.split('/rmshare')[0] usersPath = path.split('/rmshare')[0]
@ -2699,7 +2708,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Endpoint for removing posts """Endpoint for removing posts
""" """
pageNumber = 1 pageNumber = 1
@ -2796,7 +2806,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, debug: bool, onionDomain: str, i2pDomain: str, debug: bool,
defaultTimeline: str): defaultTimeline: str) -> None:
"""Updates the left links column of the timeline """Updates the left links column of the timeline
""" """
usersPath = path.replace('/linksdata', '') usersPath = path.replace('/linksdata', '')
@ -2901,7 +2911,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, debug: bool, onionDomain: str, i2pDomain: str, debug: bool,
defaultTimeline: str): defaultTimeline: str) -> None:
"""Updates the right newswire column of the timeline """Updates the right newswire column of the timeline
""" """
usersPath = path.replace('/newswiredata', '') usersPath = path.replace('/newswiredata', '')
@ -3040,7 +3050,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, debug: bool, onionDomain: str, i2pDomain: str, debug: bool,
defaultTimeline: str): defaultTimeline: str) -> None:
"""edits a news post """edits a news post
""" """
usersPath = path.replace('/newseditdata', '') usersPath = path.replace('/newseditdata', '')
@ -3184,7 +3194,8 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, path: str, authorized: bool, path: str,
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, debug: bool): onionDomain: str, i2pDomain: str,
debug: bool) -> None:
"""Updates your user profile after editing via the Edit button """Updates your user profile after editing via the Edit button
on the profile screen on the profile screen
""" """
@ -4107,7 +4118,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.POSTbusy = False self.server.POSTbusy = False
def _progressiveWebAppManifest(self, callingDomain: str, def _progressiveWebAppManifest(self, callingDomain: str,
GETstartTime, GETtimings: {}): GETstartTime,
GETtimings: {}) -> None:
"""gets the PWA manifest """gets the PWA manifest
""" """
app1 = "https://f-droid.org/en/packages/eu.siacs.conversations" app1 = "https://f-droid.org/en/packages/eu.siacs.conversations"
@ -4202,7 +4214,7 @@ class PubServer(BaseHTTPRequestHandler):
'show logout', 'send manifest') 'show logout', 'send manifest')
def _getFavicon(self, callingDomain: str, def _getFavicon(self, callingDomain: str,
baseDir: str, debug: bool): baseDir: str, debug: bool) -> None:
"""Return the favicon """Return the favicon
""" """
favType = 'image/x-icon' favType = 'image/x-icon'
@ -4255,7 +4267,7 @@ class PubServer(BaseHTTPRequestHandler):
def _getFonts(self, callingDomain: str, path: str, def _getFonts(self, callingDomain: str, path: str,
baseDir: str, debug: bool, baseDir: str, debug: bool,
GETstartTime, GETtimings: {}): GETstartTime, GETtimings: {}) -> None:
"""Returns a font """Returns a font
""" """
fontStr = path.split('/fonts/')[1] fontStr = path.split('/fonts/')[1]
@ -4317,7 +4329,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, port: int, proxyType: str, domain: str, port: int, proxyType: str,
GETstartTime, GETtimings: {}, GETstartTime, GETtimings: {},
debug: bool): debug: bool) -> None:
"""Returns an RSS2 feed for the blog """Returns an RSS2 feed for the blog
""" """
nickname = path.split('/blog/')[1] nickname = path.split('/blog/')[1]
@ -4370,7 +4382,7 @@ class PubServer(BaseHTTPRequestHandler):
domainFull: str, port: int, proxyType: str, domainFull: str, port: int, proxyType: str,
translate: {}, translate: {},
GETstartTime, GETtimings: {}, GETstartTime, GETtimings: {},
debug: bool): debug: bool) -> None:
"""Returns an RSS2 feed for all blogs on this instance """Returns an RSS2 feed for all blogs on this instance
""" """
if not self.server.session: if not self.server.session:
@ -4429,7 +4441,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, port: int, proxyType: str, domain: str, port: int, proxyType: str,
GETstartTime, GETtimings: {}, GETstartTime, GETtimings: {},
debug: bool): debug: bool) -> None:
"""Returns the newswire feed """Returns the newswire feed
""" """
if not self.server.session: if not self.server.session:
@ -4465,7 +4477,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, port: int, proxyType: str, domain: str, port: int, proxyType: str,
GETstartTime, GETtimings: {}, GETstartTime, GETtimings: {},
debug: bool): debug: bool) -> None:
"""Returns an RSS3 feed """Returns an RSS3 feed
""" """
nickname = path.split('/blog/')[1] nickname = path.split('/blog/')[1]
@ -4512,7 +4524,7 @@ class PubServer(BaseHTTPRequestHandler):
domain: str, domainFull: str, domain: str, domainFull: str,
GETstartTime, GETtimings: {}, GETstartTime, GETtimings: {},
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
cookie: str, debug: bool): cookie: str, debug: bool) -> None:
"""Show person options screen """Show person options screen
""" """
optionsStr = path.split('?options=')[1] optionsStr = path.split('?options=')[1]
@ -4592,7 +4604,7 @@ class PubServer(BaseHTTPRequestHandler):
def _showMedia(self, callingDomain: str, def _showMedia(self, callingDomain: str,
path: str, baseDir: str, path: str, baseDir: str,
GETstartTime, GETtimings: {}): GETstartTime, GETtimings: {}) -> None:
"""Returns a media file """Returns a media file
""" """
if self._pathIsImage(path) or \ if self._pathIsImage(path) or \
@ -4640,7 +4652,7 @@ class PubServer(BaseHTTPRequestHandler):
def _showEmoji(self, callingDomain: str, path: str, def _showEmoji(self, callingDomain: str, path: str,
baseDir: str, baseDir: str,
GETstartTime, GETtimings: {}): GETstartTime, GETtimings: {}) -> None:
"""Returns an emoji image """Returns an emoji image
""" """
if self._pathIsImage(path): if self._pathIsImage(path):
@ -4678,7 +4690,7 @@ class PubServer(BaseHTTPRequestHandler):
def _showIcon(self, callingDomain: str, path: str, def _showIcon(self, callingDomain: str, path: str,
baseDir: str, baseDir: str,
GETstartTime, GETtimings: {}): GETstartTime, GETtimings: {}) -> None:
"""Shows an icon """Shows an icon
""" """
if path.endswith('.png'): if path.endswith('.png'):
@ -4714,7 +4726,7 @@ class PubServer(BaseHTTPRequestHandler):
def _showCachedAvatar(self, callingDomain: str, path: str, def _showCachedAvatar(self, callingDomain: str, path: str,
baseDir: str, baseDir: str,
GETstartTime, GETtimings: {}): GETstartTime, GETtimings: {}) -> None:
"""Shows an avatar image obtained from the cache """Shows an avatar image obtained from the cache
""" """
mediaFilename = baseDir + '/cache' + path mediaFilename = baseDir + '/cache' + path
@ -4770,7 +4782,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
GETstartTime, GETtimings: {}): GETstartTime, GETtimings: {}) -> None:
"""Return the result of a hashtag search """Return the result of a hashtag search
""" """
pageNumber = 1 pageNumber = 1
@ -4837,7 +4849,7 @@ class PubServer(BaseHTTPRequestHandler):
baseDir: str, httpPrefix: str, baseDir: str, httpPrefix: str,
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
GETstartTime, GETtimings: {}): GETstartTime, GETtimings: {}) -> None:
"""Return an RSS 2 feed for a hashtag """Return an RSS 2 feed for a hashtag
""" """
hashtag = path.split('/tags/rss2/')[1] hashtag = path.split('/tags/rss2/')[1]
@ -4893,7 +4905,8 @@ class PubServer(BaseHTTPRequestHandler):
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
GETstartTime, GETtimings: {}, GETstartTime, GETtimings: {},
repeatPrivate: bool, debug: bool): repeatPrivate: bool,
debug: bool) -> None:
"""The announce/repeat button was pressed on a post """The announce/repeat button was pressed on a post
""" """
pageNumber = 1 pageNumber = 1