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