mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
5e2b02ad81
commit
53f6b637bf
2
auth.py
2
auth.py
|
@ -202,7 +202,7 @@ def authorize(baseDir: str, path: str, authHeader: str, debug: bool) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def createPassword(length=10):
|
||||
def createPassword(length: int = 10):
|
||||
validChars = 'abcdefghijklmnopqrstuvwxyz' + \
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
|
||||
return ''.join((secrets.choice(validChars) for i in range(length)))
|
||||
|
|
|
@ -741,7 +741,7 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
|
|||
setConfigParam(baseDir, "brochMode", enabled)
|
||||
|
||||
|
||||
def brochModeLapses(baseDir: str, lapseDays=7) -> bool:
|
||||
def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
|
||||
"""After broch mode is enabled it automatically
|
||||
elapses after a period of time
|
||||
"""
|
||||
|
|
|
@ -340,7 +340,7 @@ def _speakerPicospeaker(pitch: int, rate: int, systemLanguage: str,
|
|||
os.system(speakerCmd)
|
||||
|
||||
|
||||
def _playNotificationSound(soundFilename: str, player='ffplay') -> None:
|
||||
def _playNotificationSound(soundFilename: str, player: str = 'ffplay') -> None:
|
||||
"""Plays a sound
|
||||
"""
|
||||
if not os.path.isfile(soundFilename):
|
||||
|
|
|
@ -19,7 +19,7 @@ from utils import locatePost
|
|||
from utils import hasObjectDict
|
||||
|
||||
|
||||
def _validUuid(testUuid: str, version=4):
|
||||
def _validUuid(testUuid: str, version: int = 4):
|
||||
"""Check if uuid_to_test is a valid UUID
|
||||
"""
|
||||
try:
|
||||
|
|
3
media.py
3
media.py
|
@ -267,7 +267,8 @@ def attachMedia(baseDir: str, httpPrefix: str,
|
|||
return postJson
|
||||
|
||||
|
||||
def archiveMedia(baseDir: str, archiveDirectory: str, maxWeeks=4) -> None:
|
||||
def archiveMedia(baseDir: str, archiveDirectory: str,
|
||||
maxWeeks: int = 4) -> None:
|
||||
"""Any media older than the given number of weeks gets archived
|
||||
"""
|
||||
if maxWeeks == 0:
|
||||
|
|
|
@ -4298,7 +4298,8 @@ class JsonLdProcessor(object):
|
|||
elif v not in urls:
|
||||
urls[v] = False
|
||||
|
||||
def _retrieve_context_urls(self, input_, cycles, load_document, base=''):
|
||||
def _retrieve_context_urls(self, input_, cycles, load_document,
|
||||
base: str = ''):
|
||||
"""
|
||||
Retrieves external @context URLs using the given document loader. Each
|
||||
instance of @context in the input that refers to a URL will be
|
||||
|
@ -4860,7 +4861,7 @@ class ActiveContextCache(object):
|
|||
the overhead of recomputing them.
|
||||
"""
|
||||
|
||||
def __init__(self, size=100):
|
||||
def __init__(self, size: int = 100):
|
||||
self.order = deque()
|
||||
self.cache = {}
|
||||
self.size = size
|
||||
|
|
|
@ -53,8 +53,8 @@ def createSession(proxyType: str):
|
|||
return session
|
||||
|
||||
|
||||
def urlExists(session, url: str, timeoutSec=3,
|
||||
httpPrefix='https', domain='testdomain') -> bool:
|
||||
def urlExists(session, url: str, timeoutSec: int = 3,
|
||||
httpPrefix: str = 'https', domain: str = 'testdomain') -> bool:
|
||||
if not isinstance(url, str):
|
||||
print('url: ' + str(url))
|
||||
print('ERROR: urlExists failed, url should be a string')
|
||||
|
|
|
@ -93,7 +93,7 @@ def _siteActiveHttpRequest(loc, timeout: int):
|
|||
return result
|
||||
|
||||
|
||||
def siteIsActive(url: str, timeout=10) -> bool:
|
||||
def siteIsActive(url: str, timeout: int = 10) -> 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.
|
||||
|
|
|
@ -71,7 +71,7 @@ class threadWithTrace(threading.Thread):
|
|||
|
||||
|
||||
def removeDormantThreads(baseDir: str, threadsList: [], debug: bool,
|
||||
timeoutMins=30) -> None:
|
||||
timeoutMins: int = 30) -> None:
|
||||
"""Removes threads whose execution has completed
|
||||
"""
|
||||
if len(threadsList) == 0:
|
||||
|
|
8
utils.py
8
utils.py
|
@ -153,7 +153,7 @@ def getFullDomain(domain: str, port: int) -> str:
|
|||
|
||||
|
||||
def isDormant(baseDir: str, nickname: str, domain: str, actor: str,
|
||||
dormantMonths=3) -> bool:
|
||||
dormantMonths: int = 3) -> bool:
|
||||
"""Is the given followed actor dormant, from the standpoint
|
||||
of the given account
|
||||
"""
|
||||
|
@ -544,7 +544,7 @@ def saveJson(jsonObject: {}, filename: str) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def loadJson(filename: str, delaySec=2, maxTries=5) -> {}:
|
||||
def loadJson(filename: str, delaySec: int = 2, maxTries: int = 5) -> {}:
|
||||
"""Makes a few attempts to load a json formatted file
|
||||
"""
|
||||
jsonObject = None
|
||||
|
@ -564,7 +564,7 @@ def loadJson(filename: str, delaySec=2, maxTries=5) -> {}:
|
|||
|
||||
|
||||
def loadJsonOnionify(filename: str, domain: str, onionDomain: str,
|
||||
delaySec=2) -> {}:
|
||||
delaySec: int = 2) -> {}:
|
||||
"""Makes a few attempts to load a json formatted file
|
||||
This also converts the domain name to the onion domain
|
||||
"""
|
||||
|
@ -2163,7 +2163,7 @@ def mediaFileMimeType(filename: str) -> str:
|
|||
return extensions[fileExt]
|
||||
|
||||
|
||||
def isRecentPost(postJsonObject: {}, maxDays=3) -> bool:
|
||||
def isRecentPost(postJsonObject: {}, maxDays: int = 3) -> bool:
|
||||
""" Is the given post recent?
|
||||
"""
|
||||
if not hasObjectDict(postJsonObject):
|
||||
|
|
|
@ -32,7 +32,7 @@ def loadPeertubeInstances(baseDir: str, peertubeInstances: []) -> None:
|
|||
|
||||
def _addEmbeddedVideoFromSites(translate: {}, content: str,
|
||||
peertubeInstances: [],
|
||||
width=400, height=300) -> str:
|
||||
width: int = 400, height: int = 300) -> str:
|
||||
"""Adds embedded videos
|
||||
"""
|
||||
if '>vimeo.com/' in content:
|
||||
|
|
Loading…
Reference in New Issue