Snake case

main
Bob Mottram 2021-12-27 17:42:35 +00:00
parent 218ea067c0
commit f15fed2145
12 changed files with 44 additions and 44 deletions

View File

@ -13,7 +13,7 @@ from utils import remove_domain_port
from utils import remove_id_ending
from utils import has_users_path
from utils import get_full_domain
from utils import getStatusNumber
from utils import get_status_number
from utils import createOutboxDir
from utils import urlPermitted
from utils import getNicknameFromActor
@ -137,7 +137,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
domain = remove_domain_port(domain)
fullDomain = get_full_domain(domain, port)
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
newAnnounceId = http_prefix + '://' + fullDomain + \
'/users/' + nickname + '/statuses/' + statusNumber
atomUriStr = local_actor_url(http_prefix, nickname, fullDomain) + \
@ -229,7 +229,7 @@ def sendAnnounceViaServer(base_dir: str, session,
actorStr = local_actor_url(http_prefix, fromNickname, fromDomainFull)
ccUrl = actorStr + '/followers'
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
newAnnounceId = actorStr + '/statuses/' + statusNumber
newAnnounceJson = {
"@context": "https://www.w3.org/ns/activitystreams",
@ -321,7 +321,7 @@ def sendUndoAnnounceViaServer(base_dir: str, session,
actor = local_actor_url(http_prefix, nickname, domain_full)
handle = replace_users_with_at(actor)
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
unAnnounceJson = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': actor + '/statuses/' + str(statusNumber) + '/undo',

View File

@ -295,7 +295,7 @@ from utils import get_cached_post_filename
from utils import remove_post_from_cache
from utils import getNicknameFromActor
from utils import getDomainFromActor
from utils import getStatusNumber
from utils import get_status_number
from utils import urlPermitted
from utils import load_json
from utils import save_json
@ -2941,7 +2941,7 @@ class PubServer(BaseHTTPRequestHandler):
followingActor)
followActor = \
local_actor_url(http_prefix, followerNickname, domain_full)
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
followId = followActor + '/statuses/' + str(statusNumber)
unfollowJson = {
'@context': 'https://www.w3.org/ns/activitystreams',
@ -6518,7 +6518,7 @@ class PubServer(BaseHTTPRequestHandler):
actor_json['id'].replace('/', '#') + '.json'
save_json(actor_json, actorCacheFilename)
# send profile update to followers
pubNumber, pubDate = getStatusNumber()
pubNumber, pubDate = get_status_number()
updateActorJson = getActorUpdateJson(actor_json)
print('Sending actor update: ' + str(updateActorJson))
self._postToOutbox(updateActorJson,

View File

@ -19,7 +19,7 @@ from utils import validNickname
from utils import domainPermitted
from utils import getDomainFromActor
from utils import getNicknameFromActor
from utils import getStatusNumber
from utils import get_status_number
from utils import follow_person
from posts import sendSignedJson
from posts import getPersonBox
@ -869,7 +869,7 @@ def sendFollowRequest(session, base_dir: str,
requestDomain = get_full_domain(followDomain, followPort)
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
group_account = False
if followNickname:
@ -962,7 +962,7 @@ def sendFollowRequestViaServer(base_dir: str, session,
followedId = \
http_prefix + '://' + followDomainFull + '/@' + followNickname
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
newFollowJson = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': followActor + '/statuses/' + str(statusNumber),
@ -1050,7 +1050,7 @@ def sendUnfollowRequestViaServer(base_dir: str, session,
followActor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
followedId = \
http_prefix + '://' + followDomainFull + '/@' + followNickname
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
unfollowJson = {
'@context': 'https://www.w3.org/ns/activitystreams',

View File

@ -48,7 +48,7 @@ from utils import get_cached_post_filename
from utils import remove_post_from_cache
from utils import urlPermitted
from utils import createInboxQueueDir
from utils import getStatusNumber
from utils import get_status_number
from utils import getDomainFromActor
from utils import getNicknameFromActor
from utils import locate_post
@ -540,7 +540,7 @@ def savePostToInboxQueue(base_dir: str, http_prefix: str,
post_id = remove_id_ending(post_json_object['id'])
published = curr_time.strftime("%Y-%m-%dT%H:%M:%SZ")
if not post_id:
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
if actor:
post_id = actor + '/statuses/' + statusNumber
else:

View File

@ -30,7 +30,7 @@ from utils import remove_html
from utils import get_full_domain
from utils import load_json
from utils import save_json
from utils import getStatusNumber
from utils import get_status_number
from utils import clearFromPostCaches
from utils import dangerousMarkup
from utils import local_actor_url
@ -581,7 +581,7 @@ def _convertRSStoActivityPub(base_dir: str, http_prefix: str,
str(dateStrWithOffset))
continue
statusNumber, published = getStatusNumber(dateStr)
statusNumber, published = get_status_number(dateStr)
newPostId = \
local_actor_url(http_prefix, 'news', domain) + \
'/statuses/' + statusNumber

View File

@ -43,7 +43,7 @@ from utils import containsInvalidChars
from utils import replace_users_with_at
from utils import remove_line_endings
from utils import remove_domain_port
from utils import getStatusNumber
from utils import get_status_number
from utils import get_full_domain
from utils import validNickname
from utils import load_json
@ -199,7 +199,7 @@ def randomizeActorImages(personJson: {}) -> None:
def getActorUpdateJson(actor_json: {}) -> {}:
"""Returns the json for an Person Update
"""
pubNumber, _ = getStatusNumber()
pubNumber, _ = get_status_number()
manuallyApprovesFollowers = actor_json['manuallyApprovesFollowers']
return {
'@context': [
@ -403,7 +403,7 @@ def _createPersonBase(base_dir: str, nickname: str, domain: str, port: int,
personId + '/avatar' + \
str(randint(10000000000000, 99999999999999)) + '.png' # nosec
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
newPerson = {
'@context': [
'https://www.w3.org/ns/activitystreams',
@ -740,7 +740,7 @@ def personUpgradeActor(base_dir: str, personJson: {},
updateActor = True
if not personJson.get('published'):
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
personJson['published'] = published
updateActor = True

4
pgp.py
View File

@ -14,7 +14,7 @@ from person import getActorJson
from utils import contains_pgp_public_key
from utils import is_pgp_encrypted
from utils import get_full_domain
from utils import getStatusNumber
from utils import get_status_number
from utils import local_actor_url
from utils import replace_users_with_at
from webfinger import webfingerHandle
@ -542,7 +542,7 @@ def pgpPublicKeyUpload(base_dir: str, session,
setPGPpubKey(actor_json, PGPpubKey)
# create an actor update
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
actorUpdate = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': actor + '#updates/' + statusNumber,

View File

@ -51,7 +51,7 @@ from utils import valid_post_date
from utils import get_full_domain
from utils import get_followers_list
from utils import isEvil
from utils import getStatusNumber
from utils import get_status_number
from utils import createPersonDir
from utils import urlPermitted
from utils import getNicknameFromActor
@ -919,7 +919,7 @@ def savePostToBox(base_dir: str, http_prefix: str, post_id: str,
domain = remove_domain_port(domain)
if not post_id:
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
post_id = \
local_actor_url(http_prefix, nickname, originalDomain) + \
'/statuses/' + statusNumber
@ -1426,7 +1426,7 @@ def _createPostBase(base_dir: str,
if tag['name'] not in content:
del hashtagsDict[tagName]
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
newPostId = \
local_actor_url(http_prefix, nickname, domain) + \
'/statuses/' + statusNumber
@ -1570,7 +1570,7 @@ def outboxMessageCreateWrap(http_prefix: str,
"""
domain = get_full_domain(domain, port)
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
if message_json.get('published'):
published = message_json['published']
newPostId = \

View File

@ -10,7 +10,7 @@ __module_group__ = "Profile Metadata"
import os
from utils import load_json
from utils import save_json
from utils import getStatusNumber
from utils import get_status_number
from utils import remove_domain_port
from utils import acct_dir
@ -153,7 +153,7 @@ def _setActorRole(actor_json: {}, roleName: str) -> bool:
continue
if occupationItem['hasOccupation']['name'] == roleName:
return True
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
newRole = {
"@type": "Role",
"hasOccupation": {

View File

@ -11,7 +11,7 @@ import os
import time
import datetime
from utils import has_object_dict
from utils import getStatusNumber
from utils import get_status_number
from utils import load_json
from utils import is_account_dir
from utils import acct_dir
@ -82,7 +82,7 @@ def _updatePostSchedule(base_dir: str, handle: str, httpd,
# set the published time
# If this is not recent then http checks on the receiving side
# will reject it
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
if post_json_object.get('published'):
post_json_object['published'] = published
if has_object_dict(post_json_object):

View File

@ -80,7 +80,7 @@ from utils import getDomainFromActor
from utils import copytree
from utils import load_json
from utils import save_json
from utils import getStatusNumber
from utils import get_status_number
from utils import get_followers_of_person
from utils import remove_html
from utils import dangerousMarkup
@ -3459,7 +3459,7 @@ def _testGetStatusNumber():
print('testGetStatusNumber')
prevStatusNumber = None
for i in range(1, 20):
statusNumber, published = getStatusNumber()
statusNumber, published = get_status_number()
if prevStatusNumber:
assert len(statusNumber) == 18
assert int(statusNumber) > prevStatusNumber

View File

@ -657,8 +657,8 @@ def save_json(json_object: {}, filename: str) -> bool:
tries = 0
while tries < 5:
try:
with open(filename, 'w+') as fp:
fp.write(json.dumps(json_object))
with open(filename, 'w+') as json_file:
json_file.write(json.dumps(json_object))
return True
except OSError:
print('EX: save_json ' + str(tries))
@ -670,20 +670,20 @@ def save_json(json_object: {}, filename: str) -> bool:
def load_json(filename: str, delay_sec: int = 2, max_tries: int = 5) -> {}:
"""Makes a few attempts to load a json formatted file
"""
jsonObject = None
json_object = None
tries = 0
while tries < max_tries:
try:
with open(filename, 'r') as fp:
data = fp.read()
jsonObject = json.loads(data)
with open(filename, 'r') as json_file:
data = json_file.read()
json_object = json.loads(data)
break
except BaseException:
print('EX: load_json exception ' + str(filename))
if delay_sec > 0:
time.sleep(delay_sec)
tries += 1
return jsonObject
return json_object
def load_json_onionify(filename: str, domain: str, onion_domain: str,
@ -691,27 +691,27 @@ def load_json_onionify(filename: str, domain: str, onion_domain: str,
"""Makes a few attempts to load a json formatted file
This also converts the domain name to the onion domain
"""
jsonObject = None
json_object = None
tries = 0
while tries < 5:
try:
with open(filename, 'r') as fp:
data = fp.read()
with open(filename, 'r') as json_file:
data = json_file.read()
if data:
data = data.replace(domain, onion_domain)
data = data.replace('https:', 'http:')
print('*****data: ' + data)
jsonObject = json.loads(data)
json_object = json.loads(data)
break
except BaseException:
print('EX: load_json_onionify exception ' + str(filename))
if delay_sec > 0:
time.sleep(delay_sec)
tries += 1
return jsonObject
return json_object
def getStatusNumber(publishedStr: str = None) -> (str, str):
def get_status_number(publishedStr: str = None) -> (str, str):
"""Returns the status number and published date
"""
if not publishedStr: