Snake case

merge-requests/30/head
Bob Mottram 2021-12-27 17:46:27 +00:00
parent f15fed2145
commit 355524595c
2 changed files with 11 additions and 11 deletions

View File

@ -27,7 +27,7 @@ from utils import get_full_domain
from utils import remove_id_ending from utils import remove_id_ending
from utils import isEvil from utils import isEvil
from utils import locate_post from utils import locate_post
from utils import evilIncarnate from utils import evil_incarnate
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import acct_dir from utils import acct_dir
@ -251,7 +251,7 @@ def getDomainBlocklist(base_dir: str) -> str:
""" """
blockedStr = '' blockedStr = ''
evilDomains = evilIncarnate() evilDomains = evil_incarnate()
for evil in evilDomains: for evil in evilDomains:
blockedStr += evil + '\n' blockedStr += evil + '\n'

View File

@ -711,17 +711,17 @@ def load_json_onionify(filename: str, domain: str, onion_domain: str,
return json_object return json_object
def get_status_number(publishedStr: str = None) -> (str, str): def get_status_number(published_str: str = None) -> (str, str):
"""Returns the status number and published date """Returns the status number and published date
""" """
if not publishedStr: if not published_str:
curr_time = datetime.datetime.utcnow() curr_time = datetime.datetime.utcnow()
else: else:
curr_time = \ curr_time = \
datetime.datetime.strptime(publishedStr, '%Y-%m-%dT%H:%M:%SZ') datetime.datetime.strptime(published_str, '%Y-%m-%dT%H:%M:%SZ')
days_since_epoch = (curr_time - datetime.datetime(1970, 1, 1)).days days_since_epoch = (curr_time - datetime.datetime(1970, 1, 1)).days
# status is the number of seconds since epoch # status is the number of seconds since epoch
statusNumber = \ status_number = \
str(((days_since_epoch * 24 * 60 * 60) + str(((days_since_epoch * 24 * 60 * 60) +
(curr_time.hour * 60 * 60) + (curr_time.hour * 60 * 60) +
(curr_time.minute * 60) + (curr_time.minute * 60) +
@ -730,14 +730,14 @@ def get_status_number(publishedStr: str = None) -> (str, str):
# See https://github.com/tootsuite/mastodon/blob/ # See https://github.com/tootsuite/mastodon/blob/
# 995f8b389a66ab76ec92d9a240de376f1fc13a38/lib/mastodon/snowflake.rb # 995f8b389a66ab76ec92d9a240de376f1fc13a38/lib/mastodon/snowflake.rb
# use the leftover microseconds as the sequence number # use the leftover microseconds as the sequence number
sequenceId = curr_time.microsecond % 1000 sequence_id = curr_time.microsecond % 1000
# shift by 16bits "sequence data" # shift by 16bits "sequence data"
statusNumber = str((int(statusNumber) << 16) + sequenceId) status_number = str((int(status_number) << 16) + sequence_id)
published = curr_time.strftime("%Y-%m-%dT%H:%M:%SZ") published = curr_time.strftime("%Y-%m-%dT%H:%M:%SZ")
return statusNumber, published return status_number, published
def evilIncarnate() -> []: def evil_incarnate() -> []:
return ('fedilist.com', 'gab.com', 'gabfed.com', 'spinster.xyz', return ('fedilist.com', 'gab.com', 'gabfed.com', 'spinster.xyz',
'kiwifarms.cc', 'djitter.com') 'kiwifarms.cc', 'djitter.com')
@ -757,7 +757,7 @@ def isEvil(domain: str) -> bool:
for hostileStr in evilEmporium: for hostileStr in evilEmporium:
if hostileStr in domain: if hostileStr in domain:
return True return True
evilDomains = evilIncarnate() evilDomains = evil_incarnate()
for concentratedEvil in evilDomains: for concentratedEvil in evilDomains:
if domain.endswith(concentratedEvil): if domain.endswith(concentratedEvil):
return True return True