mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
dee60be26b
commit
0a2cb81a29
|
@ -16,7 +16,7 @@ from utils import hasObjectString
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
|
@ -33,7 +33,7 @@ def setAvailability(base_dir: str, nickname: str, domain: str,
|
||||||
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
actor_json['availability'] = status
|
actor_json['availability'] = status
|
||||||
save_json(actor_json, actorFilename)
|
save_json(actor_json, actorFilename)
|
||||||
|
@ -46,7 +46,7 @@ def getAvailability(base_dir: str, nickname: str, domain: str) -> str:
|
||||||
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if not actor_json.get('availability'):
|
if not actor_json.get('availability'):
|
||||||
return None
|
return None
|
||||||
|
|
12
blocking.py
12
blocking.py
|
@ -18,7 +18,7 @@ from utils import removeDomainPort
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import fileLastModified
|
from utils import fileLastModified
|
||||||
from utils import setConfigParam
|
from utils import setConfigParam
|
||||||
|
@ -529,7 +529,7 @@ def mutePost(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
print('mutePost: file not found ' + postId)
|
print('mutePost: file not found ' + postId)
|
||||||
return
|
return
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
print('mutePost: object not loaded ' + postId)
|
print('mutePost: object not loaded ' + postId)
|
||||||
return
|
return
|
||||||
|
@ -626,7 +626,7 @@ def mutePost(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
if alsoUpdatePostId:
|
if alsoUpdatePostId:
|
||||||
postFilename = locatePost(base_dir, nickname, domain, alsoUpdatePostId)
|
postFilename = locatePost(base_dir, nickname, domain, alsoUpdatePostId)
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
postJsonObj = loadJson(postFilename)
|
postJsonObj = load_json(postFilename)
|
||||||
cachedPostFilename = \
|
cachedPostFilename = \
|
||||||
getCachedPostFilename(base_dir, nickname, domain,
|
getCachedPostFilename(base_dir, nickname, domain,
|
||||||
postJsonObj)
|
postJsonObj)
|
||||||
|
@ -660,7 +660,7 @@ def unmutePost(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
postFilename = locatePost(base_dir, nickname, domain, postId)
|
postFilename = locatePost(base_dir, nickname, domain, postId)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return
|
return
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ def unmutePost(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
if alsoUpdatePostId:
|
if alsoUpdatePostId:
|
||||||
postFilename = locatePost(base_dir, nickname, domain, alsoUpdatePostId)
|
postFilename = locatePost(base_dir, nickname, domain, alsoUpdatePostId)
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
postJsonObj = loadJson(postFilename)
|
postJsonObj = load_json(postFilename)
|
||||||
cachedPostFilename = \
|
cachedPostFilename = \
|
||||||
getCachedPostFilename(base_dir, nickname, domain,
|
getCachedPostFilename(base_dir, nickname, domain,
|
||||||
postJsonObj)
|
postJsonObj)
|
||||||
|
@ -992,7 +992,7 @@ def loadCWLists(base_dir: str, verbose: bool) -> {}:
|
||||||
continue
|
continue
|
||||||
listFilename = os.path.join(base_dir + '/cwlists', f)
|
listFilename = os.path.join(base_dir + '/cwlists', f)
|
||||||
print('listFilename: ' + listFilename)
|
print('listFilename: ' + listFilename)
|
||||||
listJson = loadJson(listFilename, 0, 1)
|
listJson = load_json(listFilename, 0, 1)
|
||||||
if not listJson:
|
if not listJson:
|
||||||
continue
|
continue
|
||||||
if not listJson.get('name'):
|
if not listJson.get('name'):
|
||||||
|
|
4
blog.py
4
blog.py
|
@ -29,7 +29,7 @@ from utils import getMediaFormats
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import firstParagraphFromString
|
from utils import firstParagraphFromString
|
||||||
from utils import getActorPropertyUrl
|
from utils import getActorPropertyUrl
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
@ -785,7 +785,7 @@ def htmlEditBlog(media_instance: bool, translate: {},
|
||||||
print('Edit blog: Filename not found for ' + postUrl)
|
print('Edit blog: Filename not found for ' + postUrl)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
print('Edit blog: json not loaded for ' + postFilename)
|
print('Edit blog: json not loaded for ' + postFilename)
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -21,7 +21,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
@ -38,7 +38,7 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
actor: str, domain: str, debug: bool) -> None:
|
actor: str, domain: str, debug: bool) -> None:
|
||||||
"""Undoes a bookmark for a particular actor
|
"""Undoes a bookmark for a particular actor
|
||||||
"""
|
"""
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ def updateBookmarksCollection(recentPostsCache: {},
|
||||||
actor: str, domain: str, debug: bool) -> None:
|
actor: str, domain: str, debug: bool) -> None:
|
||||||
"""Updates the bookmarks collection within a post
|
"""Updates the bookmarks collection within a post
|
||||||
"""
|
"""
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
# remove any cached version of this post so that the
|
# remove any cached version of this post so that the
|
||||||
# bookmark icon is changed
|
# bookmark icon is changed
|
||||||
|
|
4
cache.py
4
cache.py
|
@ -11,7 +11,7 @@ import os
|
||||||
import datetime
|
import datetime
|
||||||
from session import urlExists
|
from session import urlExists
|
||||||
from session import getJson
|
from session import getJson
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import getFileCaseInsensitive
|
from utils import getFileCaseInsensitive
|
||||||
from utils import get_user_paths
|
from utils import get_user_paths
|
||||||
|
@ -89,7 +89,7 @@ def getPersonFromCache(base_dir: str, personUrl: str, person_cache: {},
|
||||||
personUrl.replace('/', '#') + '.json'
|
personUrl.replace('/', '#') + '.json'
|
||||||
actorFilename = getFileCaseInsensitive(cacheFilename)
|
actorFilename = getFileCaseInsensitive(cacheFilename)
|
||||||
if actorFilename:
|
if actorFilename:
|
||||||
personJson = loadJson(actorFilename)
|
personJson = load_json(actorFilename)
|
||||||
if personJson:
|
if personJson:
|
||||||
storePersonInCache(base_dir, personUrl, personJson,
|
storePersonInCache(base_dir, personUrl, personJson,
|
||||||
person_cache, False)
|
person_cache, False)
|
||||||
|
|
|
@ -15,7 +15,7 @@ from utils import dangerousSVG
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import isValidLanguage
|
from utils import isValidLanguage
|
||||||
from utils import get_image_extensions
|
from utils import get_image_extensions
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import fileLastModified
|
from utils import fileLastModified
|
||||||
from utils import getLinkPrefixes
|
from utils import getLinkPrefixes
|
||||||
|
@ -277,7 +277,7 @@ def _saveCustomEmoji(session, base_dir: str, emojiName: str, url: str,
|
||||||
emojiJsonFilename = customEmojiDir + '/emoji.json'
|
emojiJsonFilename = customEmojiDir + '/emoji.json'
|
||||||
emojiJson = {}
|
emojiJson = {}
|
||||||
if os.path.isfile(emojiJsonFilename):
|
if os.path.isfile(emojiJsonFilename):
|
||||||
emojiJson = loadJson(emojiJsonFilename, 0, 1)
|
emojiJson = load_json(emojiJsonFilename, 0, 1)
|
||||||
if not emojiJson:
|
if not emojiJson:
|
||||||
emojiJson = {}
|
emojiJson = {}
|
||||||
if not emojiJson.get(emojiName):
|
if not emojiJson.get(emojiName):
|
||||||
|
@ -913,12 +913,12 @@ def addHtmlTags(base_dir: str, http_prefix: str,
|
||||||
if not os.path.isfile(base_dir + '/emoji/emoji.json'):
|
if not os.path.isfile(base_dir + '/emoji/emoji.json'):
|
||||||
copyfile(base_dir + '/emoji/default_emoji.json',
|
copyfile(base_dir + '/emoji/default_emoji.json',
|
||||||
base_dir + '/emoji/emoji.json')
|
base_dir + '/emoji/emoji.json')
|
||||||
emojiDict = loadJson(base_dir + '/emoji/emoji.json')
|
emojiDict = load_json(base_dir + '/emoji/emoji.json')
|
||||||
|
|
||||||
# append custom emoji to the dict
|
# append custom emoji to the dict
|
||||||
if os.path.isfile(base_dir + '/emojicustom/emoji.json'):
|
if os.path.isfile(base_dir + '/emojicustom/emoji.json'):
|
||||||
customEmojiDict = \
|
customEmojiDict = \
|
||||||
loadJson(base_dir + '/emojicustom/emoji.json')
|
load_json(base_dir + '/emojicustom/emoji.json')
|
||||||
if customEmojiDict:
|
if customEmojiDict:
|
||||||
emojiDict = dict(emojiDict, **customEmojiDict)
|
emojiDict = dict(emojiDict, **customEmojiDict)
|
||||||
|
|
||||||
|
|
48
daemon.py
48
daemon.py
|
@ -297,7 +297,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import urlPermitted
|
from utils import urlPermitted
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import isSuspended
|
from utils import isSuspended
|
||||||
from utils import dangerousMarkup
|
from utils import dangerousMarkup
|
||||||
|
@ -528,7 +528,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(self.server.base_dir, nickname,
|
locatePost(self.server.base_dir, nickname,
|
||||||
self.server.domain, messageId)
|
self.server.domain, messageId)
|
||||||
if postFilename:
|
if postFilename:
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
populateReplies(self.server.base_dir,
|
populateReplies(self.server.base_dir,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
|
@ -2203,7 +2203,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# These don't come through via themeParams,
|
# These don't come through via themeParams,
|
||||||
# so need to be checked separately
|
# so need to be checked separately
|
||||||
themeFilename = base_dir + '/theme/' + theme_name + '/theme.json'
|
themeFilename = base_dir + '/theme/' + theme_name + '/theme.json'
|
||||||
themeJson = loadJson(themeFilename)
|
themeJson = load_json(themeFilename)
|
||||||
if themeJson:
|
if themeJson:
|
||||||
for variableName, value in themeJson.items():
|
for variableName, value in themeJson.items():
|
||||||
variableName = 'themeSetting_' + variableName
|
variableName = 'themeSetting_' + variableName
|
||||||
|
@ -4631,7 +4631,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(base_dir, nickname, domain,
|
locatePost(base_dir, nickname, domain,
|
||||||
newsPostUrl)
|
newsPostUrl)
|
||||||
if postFilename:
|
if postFilename:
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
# update the content and title
|
# update the content and title
|
||||||
post_json_object['object']['summary'] = \
|
post_json_object['object']['summary'] = \
|
||||||
newsPostTitle
|
newsPostTitle
|
||||||
|
@ -4888,7 +4888,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actorFilename = \
|
actorFilename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '.json'
|
acct_dir(base_dir, nickname, domain) + '.json'
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if not actor_json.get('discoverable'):
|
if not actor_json.get('discoverable'):
|
||||||
# discoverable in profile directory
|
# discoverable in profile directory
|
||||||
|
@ -6753,7 +6753,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._404()
|
self._404()
|
||||||
return
|
return
|
||||||
|
|
||||||
speakerJson = loadJson(speakerFilename)
|
speakerJson = load_json(speakerFilename)
|
||||||
msg = json.dumps(speakerJson,
|
msg = json.dumps(speakerJson,
|
||||||
ensure_ascii=False).encode('utf-8')
|
ensure_ascii=False).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -8180,7 +8180,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(base_dir, self.postToNickname, domain, likeUrl)
|
locatePost(base_dir, self.postToNickname, domain, likeUrl)
|
||||||
if likedPostFilename:
|
if likedPostFilename:
|
||||||
recentPostsCache = self.server.recentPostsCache
|
recentPostsCache = self.server.recentPostsCache
|
||||||
likedPostJson = loadJson(likedPostFilename, 0, 1)
|
likedPostJson = load_json(likedPostFilename, 0, 1)
|
||||||
if origFilename and origPostUrl:
|
if origFilename and origPostUrl:
|
||||||
updateLikesCollection(recentPostsCache,
|
updateLikesCollection(recentPostsCache,
|
||||||
base_dir, likedPostFilename,
|
base_dir, likedPostFilename,
|
||||||
|
@ -8344,7 +8344,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
domain, likeUrl)
|
domain, likeUrl)
|
||||||
if likedPostFilename:
|
if likedPostFilename:
|
||||||
recentPostsCache = self.server.recentPostsCache
|
recentPostsCache = self.server.recentPostsCache
|
||||||
likedPostJson = loadJson(likedPostFilename, 0, 1)
|
likedPostJson = load_json(likedPostFilename, 0, 1)
|
||||||
if origFilename and origPostUrl:
|
if origFilename and origPostUrl:
|
||||||
undoLikesCollectionEntry(recentPostsCache,
|
undoLikesCollectionEntry(recentPostsCache,
|
||||||
base_dir, likedPostFilename,
|
base_dir, likedPostFilename,
|
||||||
|
@ -8513,7 +8513,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(base_dir, self.postToNickname, domain, reactionUrl)
|
locatePost(base_dir, self.postToNickname, domain, reactionUrl)
|
||||||
if reactionPostFilename:
|
if reactionPostFilename:
|
||||||
recentPostsCache = self.server.recentPostsCache
|
recentPostsCache = self.server.recentPostsCache
|
||||||
reactionPostJson = loadJson(reactionPostFilename, 0, 1)
|
reactionPostJson = load_json(reactionPostFilename, 0, 1)
|
||||||
if origFilename and origPostUrl:
|
if origFilename and origPostUrl:
|
||||||
updateReactionCollection(recentPostsCache,
|
updateReactionCollection(recentPostsCache,
|
||||||
base_dir, reactionPostFilename,
|
base_dir, reactionPostFilename,
|
||||||
|
@ -8696,7 +8696,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(base_dir, self.postToNickname, domain, reactionUrl)
|
locatePost(base_dir, self.postToNickname, domain, reactionUrl)
|
||||||
if reactionPostFilename:
|
if reactionPostFilename:
|
||||||
recentPostsCache = self.server.recentPostsCache
|
recentPostsCache = self.server.recentPostsCache
|
||||||
reactionPostJson = loadJson(reactionPostFilename, 0, 1)
|
reactionPostJson = load_json(reactionPostFilename, 0, 1)
|
||||||
if origFilename and origPostUrl:
|
if origFilename and origPostUrl:
|
||||||
undoReactionCollectionEntry(recentPostsCache,
|
undoReactionCollectionEntry(recentPostsCache,
|
||||||
base_dir, reactionPostFilename,
|
base_dir, reactionPostFilename,
|
||||||
|
@ -8811,7 +8811,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(self.server.base_dir,
|
locatePost(self.server.base_dir,
|
||||||
self.postToNickname, domain, reactionUrl)
|
self.postToNickname, domain, reactionUrl)
|
||||||
if reactionPostFilename:
|
if reactionPostFilename:
|
||||||
post_json_object = loadJson(reactionPostFilename)
|
post_json_object = load_json(reactionPostFilename)
|
||||||
if not reactionPostFilename or not post_json_object:
|
if not reactionPostFilename or not post_json_object:
|
||||||
print('WARN: unable to locate reaction post ' + reactionUrl)
|
print('WARN: unable to locate reaction post ' + reactionUrl)
|
||||||
actorAbsolute = self._get_instance_url(callingDomain) + actor
|
actorAbsolute = self._get_instance_url(callingDomain) + actor
|
||||||
|
@ -8928,7 +8928,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(base_dir, self.postToNickname, domain, bookmarkUrl)
|
locatePost(base_dir, self.postToNickname, domain, bookmarkUrl)
|
||||||
if bookmarkFilename:
|
if bookmarkFilename:
|
||||||
print('Regenerating html post for changed bookmark')
|
print('Regenerating html post for changed bookmark')
|
||||||
bookmarkPostJson = loadJson(bookmarkFilename, 0, 1)
|
bookmarkPostJson = load_json(bookmarkFilename, 0, 1)
|
||||||
if bookmarkPostJson:
|
if bookmarkPostJson:
|
||||||
cachedPostFilename = \
|
cachedPostFilename = \
|
||||||
getCachedPostFilename(base_dir, self.postToNickname,
|
getCachedPostFilename(base_dir, self.postToNickname,
|
||||||
|
@ -9056,7 +9056,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(base_dir, self.postToNickname, domain, bookmarkUrl)
|
locatePost(base_dir, self.postToNickname, domain, bookmarkUrl)
|
||||||
if bookmarkFilename:
|
if bookmarkFilename:
|
||||||
print('Regenerating html post for changed unbookmark')
|
print('Regenerating html post for changed unbookmark')
|
||||||
bookmarkPostJson = loadJson(bookmarkFilename, 0, 1)
|
bookmarkPostJson = load_json(bookmarkFilename, 0, 1)
|
||||||
if bookmarkPostJson:
|
if bookmarkPostJson:
|
||||||
cachedPostFilename = \
|
cachedPostFilename = \
|
||||||
getCachedPostFilename(base_dir, self.postToNickname,
|
getCachedPostFilename(base_dir, self.postToNickname,
|
||||||
|
@ -9251,7 +9251,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
locatePost(base_dir, nickname, domain, muteUrl)
|
locatePost(base_dir, nickname, domain, muteUrl)
|
||||||
if muteFilename:
|
if muteFilename:
|
||||||
print('mutePost: Regenerating html post for changed mute status')
|
print('mutePost: Regenerating html post for changed mute status')
|
||||||
mutePostJson = loadJson(muteFilename, 0, 1)
|
mutePostJson = load_json(muteFilename, 0, 1)
|
||||||
if mutePostJson:
|
if mutePostJson:
|
||||||
cachedPostFilename = \
|
cachedPostFilename = \
|
||||||
getCachedPostFilename(base_dir, nickname,
|
getCachedPostFilename(base_dir, nickname,
|
||||||
|
@ -9361,7 +9361,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if muteFilename:
|
if muteFilename:
|
||||||
print('unmutePost: ' +
|
print('unmutePost: ' +
|
||||||
'Regenerating html post for changed unmute status')
|
'Regenerating html post for changed unmute status')
|
||||||
mutePostJson = loadJson(muteFilename, 0, 1)
|
mutePostJson = load_json(muteFilename, 0, 1)
|
||||||
if mutePostJson:
|
if mutePostJson:
|
||||||
cachedPostFilename = \
|
cachedPostFilename = \
|
||||||
getCachedPostFilename(base_dir, nickname,
|
getCachedPostFilename(base_dir, nickname,
|
||||||
|
@ -9667,7 +9667,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -9773,7 +9773,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = postSections[0]
|
nickname = postSections[0]
|
||||||
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if noOfActorSkills(actor_json) > 0:
|
if noOfActorSkills(actor_json) > 0:
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
|
@ -9968,7 +9968,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.GETbusy = False
|
self.server.GETbusy = False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
self.send_response(429)
|
self.send_response(429)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
@ -12971,7 +12971,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
replyPostFilename = \
|
replyPostFilename = \
|
||||||
locatePost(base_dir, nickname, domain, inReplyToUrl)
|
locatePost(base_dir, nickname, domain, inReplyToUrl)
|
||||||
if replyPostFilename:
|
if replyPostFilename:
|
||||||
post_json_object = loadJson(replyPostFilename)
|
post_json_object = load_json(replyPostFilename)
|
||||||
|
|
||||||
msg = htmlNewPost(self.server.cssCache,
|
msg = htmlNewPost(self.server.cssCache,
|
||||||
media_instance,
|
media_instance,
|
||||||
|
@ -14163,7 +14163,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.domain_full,
|
self.server.domain_full,
|
||||||
self.path)
|
self.path)
|
||||||
if blogFilename and nickname:
|
if blogFilename and nickname:
|
||||||
post_json_object = loadJson(blogFilename)
|
post_json_object = load_json(blogFilename)
|
||||||
if isBlogPost(post_json_object):
|
if isBlogPost(post_json_object):
|
||||||
msg = htmlBlogPost(self.server.session,
|
msg = htmlBlogPost(self.server.session,
|
||||||
authorized,
|
authorized,
|
||||||
|
@ -16751,7 +16751,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname, self.server.domain,
|
nickname, self.server.domain,
|
||||||
fields['postUrl'])
|
fields['postUrl'])
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
cachedFilename = \
|
cachedFilename = \
|
||||||
acct_dir(self.server.base_dir,
|
acct_dir(self.server.base_dir,
|
||||||
|
@ -17405,7 +17405,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
deviceFilename = os.path.join(personDir + '/devices', f)
|
deviceFilename = os.path.join(personDir + '/devices', f)
|
||||||
if not os.path.isfile(deviceFilename):
|
if not os.path.isfile(deviceFilename):
|
||||||
continue
|
continue
|
||||||
contentJson = loadJson(deviceFilename)
|
contentJson = load_json(deviceFilename)
|
||||||
if contentJson:
|
if contentJson:
|
||||||
devicesList.append(contentJson)
|
devicesList.append(contentJson)
|
||||||
break
|
break
|
||||||
|
@ -18539,7 +18539,7 @@ def runDaemon(content_license_url: str,
|
||||||
fitness_filename = base_dir + '/accounts/fitness.json'
|
fitness_filename = base_dir + '/accounts/fitness.json'
|
||||||
httpd.fitness = {}
|
httpd.fitness = {}
|
||||||
if os.path.isfile(fitness_filename):
|
if os.path.isfile(fitness_filename):
|
||||||
httpd.fitness = loadJson(fitness_filename)
|
httpd.fitness = load_json(fitness_filename)
|
||||||
|
|
||||||
# initialize authorized fetch key
|
# initialize authorized fetch key
|
||||||
httpd.signing_priv_key_pem = None
|
httpd.signing_priv_key_pem = None
|
||||||
|
@ -18812,7 +18812,7 @@ def runDaemon(content_license_url: str,
|
||||||
httpd.knownCrawlers = {}
|
httpd.knownCrawlers = {}
|
||||||
knownCrawlersFilename = base_dir + '/accounts/knownCrawlers.json'
|
knownCrawlersFilename = base_dir + '/accounts/knownCrawlers.json'
|
||||||
if os.path.isfile(knownCrawlersFilename):
|
if os.path.isfile(knownCrawlersFilename):
|
||||||
httpd.knownCrawlers = loadJson(knownCrawlersFilename)
|
httpd.knownCrawlers = load_json(knownCrawlersFilename)
|
||||||
# when was the last crawler seen?
|
# when was the last crawler seen?
|
||||||
httpd.lastKnownCrawler = 0
|
httpd.lastKnownCrawler = 0
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ __module_group__ = "Security"
|
||||||
# POST /api/v1/crypto/encrypted_messages/clear
|
# POST /api/v1/crypto/encrypted_messages/clear
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
|
@ -155,7 +155,7 @@ def E2EEdevicesCollection(base_dir: str, nickname: str, domain: str,
|
||||||
if not dev.endswith('.json'):
|
if not dev.endswith('.json'):
|
||||||
continue
|
continue
|
||||||
deviceFilename = os.path.join(personDir + '/devices', dev)
|
deviceFilename = os.path.join(personDir + '/devices', dev)
|
||||||
devJson = loadJson(deviceFilename)
|
devJson = load_json(deviceFilename)
|
||||||
if devJson:
|
if devJson:
|
||||||
deviceList.append(devJson)
|
deviceList.append(devJson)
|
||||||
break
|
break
|
||||||
|
|
|
@ -23,7 +23,7 @@ from utils import getStatusNumber
|
||||||
from utils import followPerson
|
from utils import followPerson
|
||||||
from posts import sendSignedJson
|
from posts import sendSignedJson
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import get_user_paths
|
from utils import get_user_paths
|
||||||
|
@ -574,7 +574,7 @@ def followApprovalRequired(base_dir: str, nicknameToFollow: str,
|
||||||
actorFilename = base_dir + '/accounts/' + \
|
actorFilename = base_dir + '/accounts/' + \
|
||||||
nicknameToFollow + '@' + domainToFollow + '.json'
|
nicknameToFollow + '@' + domainToFollow + '.json'
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actor = loadJson(actorFilename)
|
actor = load_json(actorFilename)
|
||||||
if actor:
|
if actor:
|
||||||
if actor.get('manuallyApprovesFollowers'):
|
if actor.get('manuallyApprovesFollowers'):
|
||||||
manuallyApproveFollows = actor['manuallyApprovesFollowers']
|
manuallyApproveFollows = actor['manuallyApprovesFollowers']
|
||||||
|
@ -800,7 +800,7 @@ def followedAccountRejects(session, base_dir: str, http_prefix: str,
|
||||||
followActivityfilename = \
|
followActivityfilename = \
|
||||||
acct_dir(base_dir, nicknameToFollow, domainToFollow) + '/requests/' + \
|
acct_dir(base_dir, nicknameToFollow, domainToFollow) + '/requests/' + \
|
||||||
nickname + '@' + domain + '.follow'
|
nickname + '@' + domain + '.follow'
|
||||||
followJson = loadJson(followActivityfilename)
|
followJson = load_json(followActivityfilename)
|
||||||
if not followJson:
|
if not followJson:
|
||||||
print('No follow request json was found for ' +
|
print('No follow request json was found for ' +
|
||||||
followActivityfilename)
|
followActivityfilename)
|
||||||
|
@ -1435,7 +1435,7 @@ def followerApprovalActive(base_dir: str, nickname: str, domain: str) -> bool:
|
||||||
manuallyApprovesFollowers = False
|
manuallyApprovesFollowers = False
|
||||||
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if actor_json.get('manuallyApprovesFollowers'):
|
if actor_json.get('manuallyApprovesFollowers'):
|
||||||
manuallyApprovesFollowers = \
|
manuallyApprovesFollowers = \
|
||||||
|
|
10
happening.py
10
happening.py
|
@ -13,7 +13,7 @@ from datetime import datetime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from utils import isPublicPost
|
from utils import isPublicPost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
|
@ -210,7 +210,7 @@ def getTodaysEvents(base_dir: str, nickname: str, domain: str,
|
||||||
recreateEventsFile = True
|
recreateEventsFile = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not _isHappeningPost(post_json_object):
|
if not _isHappeningPost(post_json_object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ def dayEventsCheck(base_dir: str, nickname: str, domain: str,
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not _isHappeningPost(post_json_object):
|
if not _isHappeningPost(post_json_object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ def getThisWeeksEvents(base_dir: str, nickname: str, domain: str) -> {}:
|
||||||
recreateEventsFile = True
|
recreateEventsFile = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not _isHappeningPost(post_json_object):
|
if not _isHappeningPost(post_json_object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ def getCalendarEvents(base_dir: str, nickname: str, domain: str,
|
||||||
recreateEventsFile = True
|
recreateEventsFile = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not _isHappeningPost(post_json_object):
|
if not _isHappeningPost(post_json_object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
30
inbox.py
30
inbox.py
|
@ -54,7 +54,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import deletePost
|
from utils import deletePost
|
||||||
from utils import removeModerationPostFromIndex
|
from utils import removeModerationPostFromIndex
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import undoLikesCollectionEntry
|
from utils import undoLikesCollectionEntry
|
||||||
from utils import undoReactionCollectionEntry
|
from utils import undoReactionCollectionEntry
|
||||||
|
@ -875,7 +875,7 @@ def _personReceiveUpdate(base_dir: str,
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(actorFilename):
|
if os.path.isfile(actorFilename):
|
||||||
existingPersonJson = loadJson(actorFilename)
|
existingPersonJson = load_json(actorFilename)
|
||||||
if existingPersonJson:
|
if existingPersonJson:
|
||||||
if existingPersonJson['publicKey']['publicKeyPem'] != \
|
if existingPersonJson['publicKey']['publicKeyPem'] != \
|
||||||
personJson['publicKey']['publicKeyPem']:
|
personJson['publicKey']['publicKeyPem']:
|
||||||
|
@ -916,7 +916,7 @@ def _receiveUpdateToQuestion(recentPostsCache: {}, message_json: {},
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return
|
return
|
||||||
# load the json for the question
|
# load the json for the question
|
||||||
post_json_object = loadJson(postFilename, 1)
|
post_json_object = load_json(postFilename, 1)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
if not post_json_object.get('actor'):
|
if not post_json_object.get('actor'):
|
||||||
|
@ -1059,7 +1059,7 @@ def _receiveLike(recentPostsCache: {},
|
||||||
postLikedId, likeActor,
|
postLikedId, likeActor,
|
||||||
handleName, domain, debug, None)
|
handleName, domain, debug, None)
|
||||||
# regenerate the html
|
# regenerate the html
|
||||||
likedPostJson = loadJson(postFilename, 0, 1)
|
likedPostJson = load_json(postFilename, 0, 1)
|
||||||
if likedPostJson:
|
if likedPostJson:
|
||||||
if likedPostJson.get('type'):
|
if likedPostJson.get('type'):
|
||||||
if likedPostJson['type'] == 'Announce' and \
|
if likedPostJson['type'] == 'Announce' and \
|
||||||
|
@ -1173,7 +1173,7 @@ def _receiveUndoLike(recentPostsCache: {},
|
||||||
undoLikesCollectionEntry(recentPostsCache, base_dir, postFilename,
|
undoLikesCollectionEntry(recentPostsCache, base_dir, postFilename,
|
||||||
postLikedId, likeActor, domain, debug, None)
|
postLikedId, likeActor, domain, debug, None)
|
||||||
# regenerate the html
|
# regenerate the html
|
||||||
likedPostJson = loadJson(postFilename, 0, 1)
|
likedPostJson = load_json(postFilename, 0, 1)
|
||||||
if likedPostJson:
|
if likedPostJson:
|
||||||
if likedPostJson.get('type'):
|
if likedPostJson.get('type'):
|
||||||
if likedPostJson['type'] == 'Announce' and \
|
if likedPostJson['type'] == 'Announce' and \
|
||||||
|
@ -1317,7 +1317,7 @@ def _receiveReaction(recentPostsCache: {},
|
||||||
postReactionId, reactionActor,
|
postReactionId, reactionActor,
|
||||||
handleName, domain, debug, None, emojiContent)
|
handleName, domain, debug, None, emojiContent)
|
||||||
# regenerate the html
|
# regenerate the html
|
||||||
reactionPostJson = loadJson(postFilename, 0, 1)
|
reactionPostJson = load_json(postFilename, 0, 1)
|
||||||
if reactionPostJson:
|
if reactionPostJson:
|
||||||
if reactionPostJson.get('type'):
|
if reactionPostJson.get('type'):
|
||||||
if reactionPostJson['type'] == 'Announce' and \
|
if reactionPostJson['type'] == 'Announce' and \
|
||||||
|
@ -1448,7 +1448,7 @@ def _receiveUndoReaction(recentPostsCache: {},
|
||||||
postReactionId, reactionActor, domain,
|
postReactionId, reactionActor, domain,
|
||||||
debug, None, emojiContent)
|
debug, None, emojiContent)
|
||||||
# regenerate the html
|
# regenerate the html
|
||||||
reactionPostJson = loadJson(postFilename, 0, 1)
|
reactionPostJson = load_json(postFilename, 0, 1)
|
||||||
if reactionPostJson:
|
if reactionPostJson:
|
||||||
if reactionPostJson.get('type'):
|
if reactionPostJson.get('type'):
|
||||||
if reactionPostJson['type'] == 'Announce' and \
|
if reactionPostJson['type'] == 'Announce' and \
|
||||||
|
@ -1576,7 +1576,7 @@ def _receiveBookmark(recentPostsCache: {},
|
||||||
message_json['object']['url'],
|
message_json['object']['url'],
|
||||||
message_json['actor'], domain, debug)
|
message_json['actor'], domain, debug)
|
||||||
# regenerate the html
|
# regenerate the html
|
||||||
bookmarkedPostJson = loadJson(postFilename, 0, 1)
|
bookmarkedPostJson = load_json(postFilename, 0, 1)
|
||||||
if bookmarkedPostJson:
|
if bookmarkedPostJson:
|
||||||
if debug:
|
if debug:
|
||||||
cachedPostFilename = \
|
cachedPostFilename = \
|
||||||
|
@ -1689,7 +1689,7 @@ def _receiveUndoBookmark(recentPostsCache: {},
|
||||||
message_json['object']['url'],
|
message_json['object']['url'],
|
||||||
message_json['actor'], domain, debug)
|
message_json['actor'], domain, debug)
|
||||||
# regenerate the html
|
# regenerate the html
|
||||||
bookmarkedPostJson = loadJson(postFilename, 0, 1)
|
bookmarkedPostJson = load_json(postFilename, 0, 1)
|
||||||
if bookmarkedPostJson:
|
if bookmarkedPostJson:
|
||||||
if debug:
|
if debug:
|
||||||
cachedPostFilename = \
|
cachedPostFilename = \
|
||||||
|
@ -2068,7 +2068,7 @@ def _receiveUndoAnnounce(recentPostsCache: {},
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: announced/repeated post to be undone found in inbox')
|
print('DEBUG: announced/repeated post to be undone found in inbox')
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
if not post_json_object.get('type'):
|
if not post_json_object.get('type'):
|
||||||
if post_json_object['type'] != 'Announce':
|
if post_json_object['type'] != 'Announce':
|
||||||
|
@ -2107,7 +2107,7 @@ def jsonPostAllowsComments(post_json_object: {}) -> bool:
|
||||||
def _postAllowsComments(postFilename: str) -> bool:
|
def _postAllowsComments(postFilename: str) -> bool:
|
||||||
"""Returns true if the given post allows comments/replies
|
"""Returns true if the given post allows comments/replies
|
||||||
"""
|
"""
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return False
|
return False
|
||||||
return jsonPostAllowsComments(post_json_object)
|
return jsonPostAllowsComments(post_json_object)
|
||||||
|
@ -2367,7 +2367,7 @@ def _alreadyLiked(base_dir: str, nickname: str, domain: str,
|
||||||
locatePost(base_dir, nickname, domain, postUrl)
|
locatePost(base_dir, nickname, domain, postUrl)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return False
|
return False
|
||||||
post_json_object = loadJson(postFilename, 1)
|
post_json_object = load_json(postFilename, 1)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return False
|
return False
|
||||||
if not has_object_dict(post_json_object):
|
if not has_object_dict(post_json_object):
|
||||||
|
@ -2397,7 +2397,7 @@ def _alreadyReacted(base_dir: str, nickname: str, domain: str,
|
||||||
locatePost(base_dir, nickname, domain, postUrl)
|
locatePost(base_dir, nickname, domain, postUrl)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return False
|
return False
|
||||||
post_json_object = loadJson(postFilename, 1)
|
post_json_object = load_json(postFilename, 1)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return False
|
return False
|
||||||
if not has_object_dict(post_json_object):
|
if not has_object_dict(post_json_object):
|
||||||
|
@ -2608,7 +2608,7 @@ def _groupHandle(base_dir: str, handle: str) -> bool:
|
||||||
actorFile = base_dir + '/accounts/' + handle + '.json'
|
actorFile = base_dir + '/accounts/' + handle + '.json'
|
||||||
if not os.path.isfile(actorFile):
|
if not os.path.isfile(actorFile):
|
||||||
return False
|
return False
|
||||||
actor_json = loadJson(actorFile)
|
actor_json = load_json(actorFile)
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
return False
|
return False
|
||||||
return actor_json['type'] == 'Group'
|
return actor_json['type'] == 'Group'
|
||||||
|
@ -4176,7 +4176,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int,
|
||||||
print('Loading queue item ' + queueFilename)
|
print('Loading queue item ' + queueFilename)
|
||||||
|
|
||||||
# Load the queue json
|
# Load the queue json
|
||||||
queueJson = loadJson(queueFilename, 1)
|
queueJson = load_json(queueFilename, 1)
|
||||||
if not queueJson:
|
if not queueJson:
|
||||||
print('Queue: runInboxQueue failed to load inbox queue item ' +
|
print('Queue: runInboxQueue failed to load inbox queue item ' +
|
||||||
queueFilename)
|
queueFilename)
|
||||||
|
|
4
like.py
4
like.py
|
@ -24,7 +24,7 @@ from utils import locatePost
|
||||||
from utils import undoLikesCollectionEntry
|
from utils import undoLikesCollectionEntry
|
||||||
from utils import hasGroupType
|
from utils import hasGroupType
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import removePostFromCache
|
from utils import removePostFromCache
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
|
@ -418,7 +418,7 @@ def updateLikesCollection(recentPostsCache: {},
|
||||||
"""Updates the likes collection within a post
|
"""Updates the likes collection within a post
|
||||||
"""
|
"""
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import os
|
||||||
from follow import followedAccountAccepts
|
from follow import followedAccountAccepts
|
||||||
from follow import followedAccountRejects
|
from follow import followedAccountRejects
|
||||||
from follow import removeFromFollowRequests
|
from follow import removeFromFollowRequests
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import getPortFromDomain
|
from utils import getPortFromDomain
|
||||||
from utils import get_user_paths
|
from utils import get_user_paths
|
||||||
|
@ -190,7 +190,7 @@ def manualApproveFollowRequest(session, base_dir: str,
|
||||||
followActivityfilename = \
|
followActivityfilename = \
|
||||||
requestsDir + '/' + handleOfFollowRequester + '.follow'
|
requestsDir + '/' + handleOfFollowRequester + '.follow'
|
||||||
if os.path.isfile(followActivityfilename):
|
if os.path.isfile(followActivityfilename):
|
||||||
followJson = loadJson(followActivityfilename)
|
followJson = load_json(followActivityfilename)
|
||||||
if followJson:
|
if followJson:
|
||||||
approveNickname = approveHandle.split('@')[0]
|
approveNickname = approveHandle.split('@')[0]
|
||||||
approveDomain = approveHandle.split('@')[1]
|
approveDomain = approveHandle.split('@')[1]
|
||||||
|
|
|
@ -8,7 +8,7 @@ __status__ = "Production"
|
||||||
__module_group__ = "API"
|
__module_group__ = "API"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from metadata import metaDataInstance
|
from metadata import metaDataInstance
|
||||||
|
@ -58,7 +58,7 @@ def _getMastoApiV1Account(base_dir: str, nickname: str, domain: str) -> {}:
|
||||||
accountFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
accountFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||||
if not os.path.isfile(accountFilename):
|
if not os.path.isfile(accountFilename):
|
||||||
return {}
|
return {}
|
||||||
accountJson = loadJson(accountFilename)
|
accountJson = load_json(accountFilename)
|
||||||
if not accountJson:
|
if not accountJson:
|
||||||
return {}
|
return {}
|
||||||
mastoAccountJson = {
|
mastoAccountJson = {
|
||||||
|
|
|
@ -9,7 +9,7 @@ __module_group__ = "Metadata"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import noOfAccounts
|
from utils import noOfAccounts
|
||||||
from utils import noOfActiveAccountsMonthly
|
from utils import noOfActiveAccountsMonthly
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ def metaDataInstance(showAccounts: bool,
|
||||||
if not os.path.isfile(adminActorFilename):
|
if not os.path.isfile(adminActorFilename):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
adminActor = loadJson(adminActorFilename, 0)
|
adminActor = load_json(adminActorFilename, 0)
|
||||||
if not adminActor:
|
if not adminActor:
|
||||||
print('WARN: json load exception metaDataInstance')
|
print('WARN: json load exception metaDataInstance')
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -28,7 +28,7 @@ from content import validHashTag
|
||||||
from utils import get_base_content_from_post
|
from utils import get_base_content_from_post
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import clearFromPostCaches
|
from utils import clearFromPostCaches
|
||||||
|
@ -810,7 +810,7 @@ def runNewswireDaemon(base_dir: str, httpd,
|
||||||
print('Newswire feeds not updated')
|
print('Newswire feeds not updated')
|
||||||
if os.path.isfile(newswireStateFilename):
|
if os.path.isfile(newswireStateFilename):
|
||||||
print('Loading newswire from file')
|
print('Loading newswire from file')
|
||||||
httpd.newswire = loadJson(newswireStateFilename)
|
httpd.newswire = load_json(newswireStateFilename)
|
||||||
|
|
||||||
print('Merging with previous newswire')
|
print('Merging with previous newswire')
|
||||||
_mergeWithPreviousNewswire(httpd.newswire, newNewswire)
|
_mergeWithPreviousNewswire(httpd.newswire, newNewswire)
|
||||||
|
|
|
@ -25,7 +25,7 @@ from utils import has_object_dict
|
||||||
from utils import firstParagraphFromString
|
from utils import firstParagraphFromString
|
||||||
from utils import isPublicPost
|
from utils import isPublicPost
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import isSuspended
|
from utils import isSuspended
|
||||||
from utils import containsInvalidChars
|
from utils import containsInvalidChars
|
||||||
|
@ -1053,14 +1053,14 @@ def _addAccountBlogsToNewswire(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
post_json_object = None
|
post_json_object = None
|
||||||
if fullPostFilename:
|
if fullPostFilename:
|
||||||
post_json_object = loadJson(fullPostFilename)
|
post_json_object = load_json(fullPostFilename)
|
||||||
if _isNewswireBlogPost(post_json_object):
|
if _isNewswireBlogPost(post_json_object):
|
||||||
published = post_json_object['object']['published']
|
published = post_json_object['object']['published']
|
||||||
published = published.replace('T', ' ')
|
published = published.replace('T', ' ')
|
||||||
published = published.replace('Z', '+00:00')
|
published = published.replace('Z', '+00:00')
|
||||||
votes = []
|
votes = []
|
||||||
if os.path.isfile(fullPostFilename + '.votes'):
|
if os.path.isfile(fullPostFilename + '.votes'):
|
||||||
votes = loadJson(fullPostFilename + '.votes')
|
votes = load_json(fullPostFilename + '.votes')
|
||||||
content = \
|
content = \
|
||||||
get_base_content_from_post(post_json_object,
|
get_base_content_from_post(post_json_object,
|
||||||
system_language)
|
system_language)
|
||||||
|
|
|
@ -25,7 +25,7 @@ from utils import removeIdEnding
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import dangerousMarkup
|
from utils import dangerousMarkup
|
||||||
from utils import is_featured_writer
|
from utils import is_featured_writer
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
|
@ -123,7 +123,7 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
print('actorFilename not found: ' + actorFilename)
|
print('actorFilename not found: ' + actorFilename)
|
||||||
return
|
return
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
return
|
return
|
||||||
actorChanged = False
|
actorChanged = False
|
||||||
|
|
12
person.py
12
person.py
|
@ -46,7 +46,7 @@ from utils import removeDomainPort
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import validNickname
|
from utils import validNickname
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import setConfigParam
|
from utils import setConfigParam
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
|
@ -145,7 +145,7 @@ def setProfileImage(base_dir: str, http_prefix: str,
|
||||||
iconFilename = iconFilenameBase + '.svg'
|
iconFilename = iconFilenameBase + '.svg'
|
||||||
profileFilename = base_dir + '/accounts/' + handle + '/' + iconFilename
|
profileFilename = base_dir + '/accounts/' + handle + '/' + iconFilename
|
||||||
|
|
||||||
personJson = loadJson(personFilename)
|
personJson = load_json(personFilename)
|
||||||
if personJson:
|
if personJson:
|
||||||
personJson[iconFilenameBase]['mediaType'] = mediaType
|
personJson[iconFilenameBase]['mediaType'] = mediaType
|
||||||
personJson[iconFilenameBase]['url'] = \
|
personJson[iconFilenameBase]['url'] = \
|
||||||
|
@ -732,7 +732,7 @@ def personUpgradeActor(base_dir: str, personJson: {},
|
||||||
print('WARN: actor file not found ' + filename)
|
print('WARN: actor file not found ' + filename)
|
||||||
return
|
return
|
||||||
if not personJson:
|
if not personJson:
|
||||||
personJson = loadJson(filename)
|
personJson = load_json(filename)
|
||||||
|
|
||||||
# add a speaker endpoint
|
# add a speaker endpoint
|
||||||
if not personJson.get('tts'):
|
if not personJson.get('tts'):
|
||||||
|
@ -890,7 +890,7 @@ def personLookup(domain: str, path: str, base_dir: str) -> {}:
|
||||||
filename = base_dir + '/accounts/' + handle + '.json'
|
filename = base_dir + '/accounts/' + handle + '.json'
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
return None
|
return None
|
||||||
personJson = loadJson(filename)
|
personJson = load_json(filename)
|
||||||
if not isSharedInbox:
|
if not isSharedInbox:
|
||||||
personUpgradeActor(base_dir, personJson, handle, filename)
|
personUpgradeActor(base_dir, personJson, handle, filename)
|
||||||
# if not personJson:
|
# if not personJson:
|
||||||
|
@ -1009,7 +1009,7 @@ def setDisplayNickname(base_dir: str, nickname: str, domain: str,
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
personJson = loadJson(filename)
|
personJson = load_json(filename)
|
||||||
if not personJson:
|
if not personJson:
|
||||||
return False
|
return False
|
||||||
personJson['name'] = displayName
|
personJson['name'] = displayName
|
||||||
|
@ -1027,7 +1027,7 @@ def setBio(base_dir: str, nickname: str, domain: str, bio: str) -> bool:
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
personJson = loadJson(filename)
|
personJson = load_json(filename)
|
||||||
if not personJson:
|
if not personJson:
|
||||||
return False
|
return False
|
||||||
if not personJson.get('summary'):
|
if not personJson.get('summary'):
|
||||||
|
|
20
posts.py
20
posts.py
|
@ -59,7 +59,7 @@ from utils import getDomainFromActor
|
||||||
from utils import deletePost
|
from utils import deletePost
|
||||||
from utils import validNickname
|
from utils import validNickname
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import locateNewsVotes
|
from utils import locateNewsVotes
|
||||||
|
@ -1052,7 +1052,7 @@ def _createPostCWFromReply(base_dir: str, nickname: str, domain: str,
|
||||||
replyPostFilename = \
|
replyPostFilename = \
|
||||||
locatePost(base_dir, nickname, domain, inReplyTo)
|
locatePost(base_dir, nickname, domain, inReplyTo)
|
||||||
if replyPostFilename:
|
if replyPostFilename:
|
||||||
replyToJson = loadJson(replyPostFilename)
|
replyToJson = load_json(replyPostFilename)
|
||||||
if replyToJson:
|
if replyToJson:
|
||||||
if replyToJson.get('object'):
|
if replyToJson.get('object'):
|
||||||
if replyToJson['object'].get('sensitive'):
|
if replyToJson['object'].get('sensitive'):
|
||||||
|
@ -3447,7 +3447,7 @@ def createModeration(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
postFilename = \
|
postFilename = \
|
||||||
boxDir + '/' + postUrl.replace('/', '#') + '.json'
|
boxDir + '/' + postUrl.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(postFilename):
|
if os.path.isfile(postFilename):
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
boxItems['orderedItems'].append(post_json_object)
|
boxItems['orderedItems'].append(post_json_object)
|
||||||
|
|
||||||
|
@ -3635,7 +3635,7 @@ def _passedNewswireVoting(newswire_votes_threshold: int,
|
||||||
if not votesFilename:
|
if not votesFilename:
|
||||||
return True
|
return True
|
||||||
# load the votes file and count the votes
|
# load the votes file and count the votes
|
||||||
votesJson = loadJson(votesFilename, 0, 2)
|
votesJson = load_json(votesFilename, 0, 2)
|
||||||
if not votesJson:
|
if not votesJson:
|
||||||
return True
|
return True
|
||||||
if not positive_voting:
|
if not positive_voting:
|
||||||
|
@ -4450,7 +4450,7 @@ def populateRepliesJson(base_dir: str, nickname: str, domain: str,
|
||||||
if os.path.isfile(searchFilename):
|
if os.path.isfile(searchFilename):
|
||||||
if authorized or \
|
if authorized or \
|
||||||
pubStr in open(searchFilename).read():
|
pubStr in open(searchFilename).read():
|
||||||
post_json_object = loadJson(searchFilename)
|
post_json_object = load_json(searchFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
if post_json_object['object'].get('cc'):
|
if post_json_object['object'].get('cc'):
|
||||||
pjo = post_json_object
|
pjo = post_json_object
|
||||||
|
@ -4479,7 +4479,7 @@ def populateRepliesJson(base_dir: str, nickname: str, domain: str,
|
||||||
pubStr in open(searchFilename).read():
|
pubStr in open(searchFilename).read():
|
||||||
# get the json of the reply and append it to
|
# get the json of the reply and append it to
|
||||||
# the collection
|
# the collection
|
||||||
post_json_object = loadJson(searchFilename)
|
post_json_object = load_json(searchFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
if post_json_object['object'].get('cc'):
|
if post_json_object['object'].get('cc'):
|
||||||
pjo = post_json_object
|
pjo = post_json_object
|
||||||
|
@ -4549,7 +4549,7 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
|
||||||
if debug:
|
if debug:
|
||||||
print('Reading cached Announce content for ' +
|
print('Reading cached Announce content for ' +
|
||||||
post_json_object['object'])
|
post_json_object['object'])
|
||||||
post_json_object = loadJson(announceFilename)
|
post_json_object = load_json(announceFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
return post_json_object
|
return post_json_object
|
||||||
else:
|
else:
|
||||||
|
@ -5227,7 +5227,7 @@ def editedPostFilename(base_dir: str, nickname: str, domain: str,
|
||||||
locatePost(base_dir, nickname, domain, lastpostId, False)
|
locatePost(base_dir, nickname, domain, lastpostId, False)
|
||||||
if not lastpostFilename:
|
if not lastpostFilename:
|
||||||
return ''
|
return ''
|
||||||
lastpostJson = loadJson(lastpostFilename, 0)
|
lastpostJson = load_json(lastpostFilename, 0)
|
||||||
if not lastpostJson:
|
if not lastpostJson:
|
||||||
return ''
|
return ''
|
||||||
if not lastpostJson.get('type'):
|
if not lastpostJson.get('type'):
|
||||||
|
@ -5271,7 +5271,7 @@ def getOriginalPostFromAnnounceUrl(announceUrl: str, base_dir: str,
|
||||||
postFilename = locatePost(base_dir, nickname, domain, announceUrl)
|
postFilename = locatePost(base_dir, nickname, domain, announceUrl)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return None, None, None
|
return None, None, None
|
||||||
announcePostJson = loadJson(postFilename, 0, 1)
|
announcePostJson = load_json(postFilename, 0, 1)
|
||||||
if not announcePostJson:
|
if not announcePostJson:
|
||||||
return None, None, postFilename
|
return None, None, postFilename
|
||||||
if not announcePostJson.get('type'):
|
if not announcePostJson.get('type'):
|
||||||
|
@ -5288,7 +5288,7 @@ def getOriginalPostFromAnnounceUrl(announceUrl: str, base_dir: str,
|
||||||
origFilename = locatePost(base_dir, nickname, domain, origPostId)
|
origFilename = locatePost(base_dir, nickname, domain, origPostId)
|
||||||
if origFilename:
|
if origFilename:
|
||||||
# we have the original post
|
# we have the original post
|
||||||
origPostJson = loadJson(origFilename, 0, 1)
|
origPostJson = load_json(origFilename, 0, 1)
|
||||||
if origPostJson:
|
if origPostJson:
|
||||||
if has_object_dict(origPostJson):
|
if has_object_dict(origPostJson):
|
||||||
if origPostJson['object'].get('attributedTo'):
|
if origPostJson['object'].get('attributedTo'):
|
||||||
|
|
|
@ -9,7 +9,7 @@ __module_group__ = "ActivityPub"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ def questionUpdateVotes(base_dir: str, nickname: str, domain: str,
|
||||||
questionPostFilename = locatePost(base_dir, nickname, domain, inReplyTo)
|
questionPostFilename = locatePost(base_dir, nickname, domain, inReplyTo)
|
||||||
if not questionPostFilename:
|
if not questionPostFilename:
|
||||||
return None, None
|
return None, None
|
||||||
questionJson = loadJson(questionPostFilename)
|
questionJson = load_json(questionPostFilename)
|
||||||
if not questionJson:
|
if not questionJson:
|
||||||
return None, None
|
return None, None
|
||||||
if not has_object_dict(questionJson):
|
if not has_object_dict(questionJson):
|
||||||
|
|
|
@ -26,7 +26,7 @@ from utils import locatePost
|
||||||
from utils import undoReactionCollectionEntry
|
from utils import undoReactionCollectionEntry
|
||||||
from utils import hasGroupType
|
from utils import hasGroupType
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import removePostFromCache
|
from utils import removePostFromCache
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
|
@ -448,7 +448,7 @@ def updateReactionCollection(recentPostsCache: {},
|
||||||
"""Updates the reactions collection within a post
|
"""Updates the reactions collection within a post
|
||||||
"""
|
"""
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
6
roles.py
6
roles.py
|
@ -8,7 +8,7 @@ __status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
|
@ -31,7 +31,7 @@ def _clearRoleStatus(base_dir: str, role: str) -> None:
|
||||||
filename = os.path.join(base_dir + '/accounts/', filename)
|
filename = os.path.join(base_dir + '/accounts/', filename)
|
||||||
if '"' + role + '"' not in open(filename).read():
|
if '"' + role + '"' not in open(filename).read():
|
||||||
continue
|
continue
|
||||||
actor_json = loadJson(filename)
|
actor_json = load_json(filename)
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
continue
|
continue
|
||||||
rolesList = getActorRolesList(actor_json)
|
rolesList = getActorRolesList(actor_json)
|
||||||
|
@ -242,7 +242,7 @@ def setRole(base_dir: str, nickname: str, domain: str,
|
||||||
"artist": "artists.txt"
|
"artist": "artists.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if not actor_json.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -12,7 +12,7 @@ import time
|
||||||
import datetime
|
import datetime
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from outbox import postMessageToOutbox
|
from outbox import postMessageToOutbox
|
||||||
|
@ -73,7 +73,7 @@ def _updatePostSchedule(base_dir: str, handle: str, httpd,
|
||||||
indexLines.remove(line)
|
indexLines.remove(line)
|
||||||
continue
|
continue
|
||||||
# load post
|
# load post
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
print('WARN: schedule json not loaded')
|
print('WARN: schedule json not loaded')
|
||||||
indexLines.remove(line)
|
indexLines.remove(line)
|
||||||
|
|
28
shares.py
28
shares.py
|
@ -28,7 +28,7 @@ from utils import dateSecondsToString
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import validNickname
|
from utils import validNickname
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import get_image_extensions
|
from utils import get_image_extensions
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
|
@ -57,7 +57,7 @@ def _loadDfcIds(base_dir: str, system_language: str,
|
||||||
if not os.path.isfile(productTypesFilename):
|
if not os.path.isfile(productTypesFilename):
|
||||||
productTypesFilename = \
|
productTypesFilename = \
|
||||||
base_dir + '/ontology/' + productType + 'Types.json'
|
base_dir + '/ontology/' + productType + 'Types.json'
|
||||||
productTypes = loadJson(productTypesFilename)
|
productTypes = load_json(productTypesFilename)
|
||||||
if not productTypes:
|
if not productTypes:
|
||||||
print('Unable to load ontology: ' + productTypesFilename)
|
print('Unable to load ontology: ' + productTypesFilename)
|
||||||
return None
|
return None
|
||||||
|
@ -131,7 +131,7 @@ def removeSharedItem(base_dir: str, nickname: str, domain: str,
|
||||||
sharesFileType + '.json ' + sharesFilename)
|
sharesFileType + '.json ' + sharesFilename)
|
||||||
return
|
return
|
||||||
|
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
print('ERROR: remove shared item, ' +
|
print('ERROR: remove shared item, ' +
|
||||||
sharesFileType + '.json could not be loaded from ' +
|
sharesFileType + '.json could not be loaded from ' +
|
||||||
|
@ -320,7 +320,7 @@ def addShare(base_dir: str,
|
||||||
acct_dir(base_dir, nickname, domain) + '/' + sharesFileType + '.json'
|
acct_dir(base_dir, nickname, domain) + '/' + sharesFileType + '.json'
|
||||||
sharesJson = {}
|
sharesJson = {}
|
||||||
if os.path.isfile(sharesFilename):
|
if os.path.isfile(sharesFilename):
|
||||||
sharesJson = loadJson(sharesFilename, 1, 2)
|
sharesJson = load_json(sharesFilename, 1, 2)
|
||||||
|
|
||||||
duration = duration.lower()
|
duration = duration.lower()
|
||||||
published = int(time.time())
|
published = int(time.time())
|
||||||
|
@ -421,7 +421,7 @@ def _expireSharesForAccount(base_dir: str, nickname: str, domain: str,
|
||||||
base_dir + '/accounts/' + handle + '/' + sharesFileType + '.json'
|
base_dir + '/accounts/' + handle + '/' + sharesFileType + '.json'
|
||||||
if not os.path.isfile(sharesFilename):
|
if not os.path.isfile(sharesFilename):
|
||||||
return
|
return
|
||||||
sharesJson = loadJson(sharesFilename, 1, 2)
|
sharesJson = load_json(sharesFilename, 1, 2)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
return
|
return
|
||||||
curr_time = int(time.time())
|
curr_time = int(time.time())
|
||||||
|
@ -496,7 +496,7 @@ def getSharesFeedForPerson(base_dir: str,
|
||||||
if headerOnly:
|
if headerOnly:
|
||||||
noOfShares = 0
|
noOfShares = 0
|
||||||
if os.path.isfile(sharesFilename):
|
if os.path.isfile(sharesFilename):
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
if sharesJson:
|
if sharesJson:
|
||||||
noOfShares = len(sharesJson.items())
|
noOfShares = len(sharesJson.items())
|
||||||
idStr = local_actor_url(http_prefix, nickname, domain)
|
idStr = local_actor_url(http_prefix, nickname, domain)
|
||||||
|
@ -529,7 +529,7 @@ def getSharesFeedForPerson(base_dir: str,
|
||||||
pageCtr = 0
|
pageCtr = 0
|
||||||
totalCtr = 0
|
totalCtr = 0
|
||||||
|
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
if sharesJson:
|
if sharesJson:
|
||||||
for itemID, item in sharesJson.items():
|
for itemID, item in sharesJson.items():
|
||||||
pageCtr += 1
|
pageCtr += 1
|
||||||
|
@ -1197,7 +1197,7 @@ def sharesCatalogAccountEndpoint(base_dir: str, http_prefix: str,
|
||||||
if debug:
|
if debug:
|
||||||
print(sharesFileType + '.json file not found: ' + sharesFilename)
|
print(sharesFileType + '.json file not found: ' + sharesFilename)
|
||||||
return endpoint
|
return endpoint
|
||||||
sharesJson = loadJson(sharesFilename, 1, 2)
|
sharesJson = load_json(sharesFilename, 1, 2)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
if debug:
|
if debug:
|
||||||
print('Unable to load json for ' + sharesFilename)
|
print('Unable to load json for ' + sharesFilename)
|
||||||
|
@ -1291,7 +1291,7 @@ def sharesCatalogEndpoint(base_dir: str, http_prefix: str,
|
||||||
if not os.path.isfile(sharesFilename):
|
if not os.path.isfile(sharesFilename):
|
||||||
continue
|
continue
|
||||||
print('Test 78363 ' + sharesFilename)
|
print('Test 78363 ' + sharesFilename)
|
||||||
sharesJson = loadJson(sharesFilename, 1, 2)
|
sharesJson = load_json(sharesFilename, 1, 2)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1381,7 +1381,7 @@ def generateSharedItemFederationTokens(shared_items_federated_domains: [],
|
||||||
tokensFilename = \
|
tokensFilename = \
|
||||||
base_dir + '/accounts/sharedItemsFederationTokens.json'
|
base_dir + '/accounts/sharedItemsFederationTokens.json'
|
||||||
if os.path.isfile(tokensFilename):
|
if os.path.isfile(tokensFilename):
|
||||||
tokensJson = loadJson(tokensFilename, 1, 2)
|
tokensJson = load_json(tokensFilename, 1, 2)
|
||||||
if tokensJson is None:
|
if tokensJson is None:
|
||||||
tokensJson = {}
|
tokensJson = {}
|
||||||
|
|
||||||
|
@ -1414,7 +1414,7 @@ def updateSharedItemFederationToken(base_dir: str,
|
||||||
if os.path.isfile(tokensFilename):
|
if os.path.isfile(tokensFilename):
|
||||||
if debug:
|
if debug:
|
||||||
print('Update loading tokens for ' + tokenDomainFull)
|
print('Update loading tokens for ' + tokenDomainFull)
|
||||||
tokensJson = loadJson(tokensFilename, 1, 2)
|
tokensJson = load_json(tokensFilename, 1, 2)
|
||||||
if tokensJson is None:
|
if tokensJson is None:
|
||||||
tokensJson = {}
|
tokensJson = {}
|
||||||
updateRequired = False
|
updateRequired = False
|
||||||
|
@ -1472,7 +1472,7 @@ def createSharedItemFederationToken(base_dir: str,
|
||||||
tokensFilename = \
|
tokensFilename = \
|
||||||
base_dir + '/accounts/sharedItemsFederationTokens.json'
|
base_dir + '/accounts/sharedItemsFederationTokens.json'
|
||||||
if os.path.isfile(tokensFilename):
|
if os.path.isfile(tokensFilename):
|
||||||
tokensJson = loadJson(tokensFilename, 1, 2)
|
tokensJson = load_json(tokensFilename, 1, 2)
|
||||||
if tokensJson is None:
|
if tokensJson is None:
|
||||||
tokensJson = {}
|
tokensJson = {}
|
||||||
if force or not tokensJson.get(tokenDomainFull):
|
if force or not tokensJson.get(tokenDomainFull):
|
||||||
|
@ -1522,7 +1522,7 @@ def authorizeSharedItems(shared_items_federated_domains: [],
|
||||||
print('DEBUG: shared item federation tokens file missing ' +
|
print('DEBUG: shared item federation tokens file missing ' +
|
||||||
tokensFilename)
|
tokensFilename)
|
||||||
return False
|
return False
|
||||||
tokensJson = loadJson(tokensFilename, 1, 2)
|
tokensJson = load_json(tokensFilename, 1, 2)
|
||||||
if not tokensJson:
|
if not tokensJson:
|
||||||
return False
|
return False
|
||||||
if not tokensJson.get(callingDomainFull):
|
if not tokensJson.get(callingDomainFull):
|
||||||
|
@ -1736,7 +1736,7 @@ def runFederatedSharesDaemon(base_dir: str, httpd, http_prefix: str,
|
||||||
if not os.path.isfile(tokensFilename):
|
if not os.path.isfile(tokensFilename):
|
||||||
time.sleep(fileCheckIntervalSec)
|
time.sleep(fileCheckIntervalSec)
|
||||||
continue
|
continue
|
||||||
tokensJson = loadJson(tokensFilename, 1, 2)
|
tokensJson = load_json(tokensFilename, 1, 2)
|
||||||
if not tokensJson:
|
if not tokensJson:
|
||||||
time.sleep(fileCheckIntervalSec)
|
time.sleep(fileCheckIntervalSec)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -16,7 +16,7 @@ from utils import hasObjectString
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import getOccupationSkills
|
from utils import getOccupationSkills
|
||||||
from utils import setOccupationSkillsList
|
from utils import setOccupationSkillsList
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
@ -123,7 +123,7 @@ def setSkillLevel(base_dir: str, nickname: str, domain: str,
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
return setActorSkillLevel(actor_json,
|
return setActorSkillLevel(actor_json,
|
||||||
skill, skillLevelPercent)
|
skill, skillLevelPercent)
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ def getSkills(base_dir: str, nickname: str, domain: str) -> []:
|
||||||
if not os.path.isfile(actorFilename):
|
if not os.path.isfile(actorFilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if not actor_json.get('hasOccupation'):
|
if not actor_json.get('hasOccupation'):
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -20,7 +20,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import getGenderFromBio
|
from utils import getGenderFromBio
|
||||||
from utils import getDisplayName
|
from utils import getDisplayName
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import isPGPEncrypted
|
from utils import isPGPEncrypted
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
|
@ -362,7 +362,7 @@ def getSSMLbox(base_dir: str, path: str,
|
||||||
acct_dir(base_dir, nickname, domain) + '/speaker.json'
|
acct_dir(base_dir, nickname, domain) + '/speaker.json'
|
||||||
if not os.path.isfile(speakerFilename):
|
if not os.path.isfile(speakerFilename):
|
||||||
return None
|
return None
|
||||||
speakerJson = loadJson(speakerFilename)
|
speakerJson = load_json(speakerFilename)
|
||||||
if not speakerJson:
|
if not speakerJson:
|
||||||
return None
|
return None
|
||||||
gender = None
|
gender = None
|
||||||
|
|
36
tests.py
36
tests.py
|
@ -78,7 +78,7 @@ from utils import followPerson
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import copytree
|
from utils import copytree
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import getFollowersOfPerson
|
from utils import getFollowersOfPerson
|
||||||
|
@ -1251,7 +1251,7 @@ def testPostMessageBetweenServers(base_dir: str) -> None:
|
||||||
assert os.path.isdir(newsActorDir)
|
assert os.path.isdir(newsActorDir)
|
||||||
newsActorFile = newsActorDir + '.json'
|
newsActorFile = newsActorDir + '.json'
|
||||||
assert os.path.isfile(newsActorFile)
|
assert os.path.isfile(newsActorFile)
|
||||||
newsActorJson = loadJson(newsActorFile)
|
newsActorJson = load_json(newsActorFile)
|
||||||
assert newsActorJson
|
assert newsActorJson
|
||||||
assert newsActorJson.get("id")
|
assert newsActorJson.get("id")
|
||||||
# check the id of the news actor
|
# check the id of the news actor
|
||||||
|
@ -1277,7 +1277,7 @@ def testPostMessageBetweenServers(base_dir: str) -> None:
|
||||||
for name in os.listdir(inboxPath):
|
for name in os.listdir(inboxPath):
|
||||||
filename = os.path.join(inboxPath, name)
|
filename = os.path.join(inboxPath, name)
|
||||||
assert os.path.isfile(filename)
|
assert os.path.isfile(filename)
|
||||||
receivedJson = loadJson(filename, 0)
|
receivedJson = load_json(filename, 0)
|
||||||
if receivedJson:
|
if receivedJson:
|
||||||
pprint(receivedJson['object']['content'])
|
pprint(receivedJson['object']['content'])
|
||||||
assert receivedJson
|
assert receivedJson
|
||||||
|
@ -1339,7 +1339,7 @@ def testPostMessageBetweenServers(base_dir: str) -> None:
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
alicePostJson = loadJson(outboxPostFilename, 0)
|
alicePostJson = load_json(outboxPostFilename, 0)
|
||||||
if alicePostJson:
|
if alicePostJson:
|
||||||
pprint(alicePostJson)
|
pprint(alicePostJson)
|
||||||
|
|
||||||
|
@ -1361,7 +1361,7 @@ def testPostMessageBetweenServers(base_dir: str) -> None:
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
alicePostJson = loadJson(outboxPostFilename, 0)
|
alicePostJson = load_json(outboxPostFilename, 0)
|
||||||
if alicePostJson:
|
if alicePostJson:
|
||||||
pprint(alicePostJson)
|
pprint(alicePostJson)
|
||||||
|
|
||||||
|
@ -1879,7 +1879,7 @@ def testSharedItemsFederation(base_dir: str) -> None:
|
||||||
|
|
||||||
sharesFilename = bobDir + '/accounts/bob@' + bobDomain + '/shares.json'
|
sharesFilename = bobDir + '/accounts/bob@' + bobDomain + '/shares.json'
|
||||||
assert os.path.isfile(sharesFilename)
|
assert os.path.isfile(sharesFilename)
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
assert sharesJson
|
assert sharesJson
|
||||||
pprint(sharesJson)
|
pprint(sharesJson)
|
||||||
assert len(sharesJson.items()) == 3
|
assert len(sharesJson.items()) == 3
|
||||||
|
@ -1906,7 +1906,7 @@ def testSharedItemsFederation(base_dir: str) -> None:
|
||||||
aliceTokensFilename = \
|
aliceTokensFilename = \
|
||||||
aliceDir + '/accounts/sharedItemsFederationTokens.json'
|
aliceDir + '/accounts/sharedItemsFederationTokens.json'
|
||||||
assert os.path.isfile(aliceTokensFilename)
|
assert os.path.isfile(aliceTokensFilename)
|
||||||
aliceSharedItemFederationTokens = loadJson(aliceTokensFilename)
|
aliceSharedItemFederationTokens = load_json(aliceTokensFilename)
|
||||||
assert aliceSharedItemFederationTokens
|
assert aliceSharedItemFederationTokens
|
||||||
print('Alice shared item federation tokens:')
|
print('Alice shared item federation tokens:')
|
||||||
pprint(aliceSharedItemFederationTokens)
|
pprint(aliceSharedItemFederationTokens)
|
||||||
|
@ -1961,14 +1961,14 @@ def testSharedItemsFederation(base_dir: str) -> None:
|
||||||
bobDir + '/accounts/sharedItemsFederationTokens.json'
|
bobDir + '/accounts/sharedItemsFederationTokens.json'
|
||||||
assert os.path.isfile(aliceTokensFilename)
|
assert os.path.isfile(aliceTokensFilename)
|
||||||
assert os.path.isfile(bobTokensFilename)
|
assert os.path.isfile(bobTokensFilename)
|
||||||
aliceTokens = loadJson(aliceTokensFilename)
|
aliceTokens = load_json(aliceTokensFilename)
|
||||||
assert aliceTokens
|
assert aliceTokens
|
||||||
for hostStr, token in aliceTokens.items():
|
for hostStr, token in aliceTokens.items():
|
||||||
assert ':' in hostStr
|
assert ':' in hostStr
|
||||||
assert aliceTokens.get(aliceAddress)
|
assert aliceTokens.get(aliceAddress)
|
||||||
print('Alice tokens')
|
print('Alice tokens')
|
||||||
pprint(aliceTokens)
|
pprint(aliceTokens)
|
||||||
bobTokens = loadJson(bobTokensFilename)
|
bobTokens = load_json(bobTokensFilename)
|
||||||
assert bobTokens
|
assert bobTokens
|
||||||
for hostStr, token in bobTokens.items():
|
for hostStr, token in bobTokens.items():
|
||||||
assert ':' in hostStr
|
assert ':' in hostStr
|
||||||
|
@ -2402,7 +2402,7 @@ def testGroupFollow(base_dir: str) -> None:
|
||||||
for name in os.listdir(inboxPathBob):
|
for name in os.listdir(inboxPathBob):
|
||||||
filename = os.path.join(inboxPathBob, name)
|
filename = os.path.join(inboxPathBob, name)
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
receivedJson = loadJson(filename)
|
receivedJson = load_json(filename)
|
||||||
assert receivedJson
|
assert receivedJson
|
||||||
print('Received group post ' + receivedJson['id'])
|
print('Received group post ' + receivedJson['id'])
|
||||||
assert '/testgroup/statuses/' in receivedJson['id']
|
assert '/testgroup/statuses/' in receivedJson['id']
|
||||||
|
@ -2944,7 +2944,7 @@ def testClientToServer(base_dir: str):
|
||||||
statusNumber = name.split('#statuses#')[1].replace('.json', '')
|
statusNumber = name.split('#statuses#')[1].replace('.json', '')
|
||||||
statusNumber = int(statusNumber.replace('#activity', ''))
|
statusNumber = int(statusNumber.replace('#activity', ''))
|
||||||
outboxPostFilename = outboxPath + '/' + name
|
outboxPostFilename = outboxPath + '/' + name
|
||||||
post_json_object = loadJson(outboxPostFilename, 0)
|
post_json_object = load_json(outboxPostFilename, 0)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
outboxPostId = removeIdEnding(post_json_object['id'])
|
outboxPostId = removeIdEnding(post_json_object['id'])
|
||||||
assert outboxPostId
|
assert outboxPostId
|
||||||
|
@ -3474,7 +3474,7 @@ def _testJsonString() -> None:
|
||||||
"content": messageStr
|
"content": messageStr
|
||||||
}
|
}
|
||||||
assert save_json(testJson, filename)
|
assert save_json(testJson, filename)
|
||||||
receivedJson = loadJson(filename, 0)
|
receivedJson = load_json(filename, 0)
|
||||||
assert receivedJson
|
assert receivedJson
|
||||||
assert receivedJson['content'] == messageStr
|
assert receivedJson['content'] == messageStr
|
||||||
encodedStr = json.dumps(testJson, ensure_ascii=False)
|
encodedStr = json.dumps(testJson, ensure_ascii=False)
|
||||||
|
@ -3499,7 +3499,7 @@ def _testSaveLoadJson():
|
||||||
pass
|
pass
|
||||||
assert save_json(testJson, testFilename)
|
assert save_json(testJson, testFilename)
|
||||||
assert os.path.isfile(testFilename)
|
assert os.path.isfile(testFilename)
|
||||||
testLoadJson = loadJson(testFilename)
|
testLoadJson = load_json(testFilename)
|
||||||
assert(testLoadJson)
|
assert(testLoadJson)
|
||||||
assert testLoadJson.get('param1')
|
assert testLoadJson.get('param1')
|
||||||
assert testLoadJson.get('param2')
|
assert testLoadJson.get('param2')
|
||||||
|
@ -3880,7 +3880,7 @@ def _testTranslations(base_dir: str) -> None:
|
||||||
# load all translations into a dict
|
# load all translations into a dict
|
||||||
langDict = {}
|
langDict = {}
|
||||||
for lang in languagesStr:
|
for lang in languagesStr:
|
||||||
langJson = loadJson('translations/' + lang + '.json')
|
langJson = load_json('translations/' + lang + '.json')
|
||||||
if not langJson:
|
if not langJson:
|
||||||
print('Missing language file ' +
|
print('Missing language file ' +
|
||||||
'translations/' + lang + '.json')
|
'translations/' + lang + '.json')
|
||||||
|
@ -3888,7 +3888,7 @@ def _testTranslations(base_dir: str) -> None:
|
||||||
langDict[lang] = langJson
|
langDict[lang] = langJson
|
||||||
|
|
||||||
# load english translations
|
# load english translations
|
||||||
translationsJson = loadJson('translations/en.json')
|
translationsJson = load_json('translations/en.json')
|
||||||
# test each english string exists in the other language files
|
# test each english string exists in the other language files
|
||||||
for englishStr, translatedStr in translationsJson.items():
|
for englishStr, translatedStr in translationsJson.items():
|
||||||
for lang in languagesStr:
|
for lang in languagesStr:
|
||||||
|
@ -5019,7 +5019,7 @@ def _testEmojiImages():
|
||||||
print('testEmojiImages')
|
print('testEmojiImages')
|
||||||
emojiFilename = 'emoji/default_emoji.json'
|
emojiFilename = 'emoji/default_emoji.json'
|
||||||
assert os.path.isfile(emojiFilename)
|
assert os.path.isfile(emojiFilename)
|
||||||
emojiJson = loadJson(emojiFilename)
|
emojiJson = load_json(emojiFilename)
|
||||||
assert emojiJson
|
assert emojiJson
|
||||||
for emojiName, emojiImage in emojiJson.items():
|
for emojiName, emojiImage in emojiJson.items():
|
||||||
emojiImageFilename = 'emoji/' + emojiImage + '.png'
|
emojiImageFilename = 'emoji/' + emojiImage + '.png'
|
||||||
|
@ -5154,7 +5154,7 @@ def testUpdateActor(base_dir: str):
|
||||||
|
|
||||||
# load alice actor
|
# load alice actor
|
||||||
print('Loading actor: ' + actorFilename)
|
print('Loading actor: ' + actorFilename)
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
assert actor_json
|
assert actor_json
|
||||||
if len(actor_json['attachment']) == 0:
|
if len(actor_json['attachment']) == 0:
|
||||||
print("actor_json['attachment'] has no contents")
|
print("actor_json['attachment'] has no contents")
|
||||||
|
@ -5716,7 +5716,7 @@ def _translateOntology(base_dir: str) -> None:
|
||||||
filename = base_dir + '/ontology/' + oType + 'Types.json'
|
filename = base_dir + '/ontology/' + oType + 'Types.json'
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
continue
|
continue
|
||||||
ontologyJson = loadJson(filename)
|
ontologyJson = load_json(filename)
|
||||||
if not ontologyJson:
|
if not ontologyJson:
|
||||||
continue
|
continue
|
||||||
index = -1
|
index = -1
|
||||||
|
|
20
theme.py
20
theme.py
|
@ -9,7 +9,7 @@ __module_group__ = "Web Interface"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import get_image_extensions
|
from utils import get_image_extensions
|
||||||
from utils import copytree
|
from utils import copytree
|
||||||
|
@ -167,7 +167,7 @@ def _setThemeInConfig(base_dir: str, name: str) -> bool:
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
if not os.path.isfile(config_filename):
|
if not os.path.isfile(config_filename):
|
||||||
return False
|
return False
|
||||||
configJson = loadJson(config_filename, 0)
|
configJson = load_json(config_filename, 0)
|
||||||
if not configJson:
|
if not configJson:
|
||||||
return False
|
return False
|
||||||
configJson['theme'] = name
|
configJson['theme'] = name
|
||||||
|
@ -180,7 +180,7 @@ def _setNewswirePublishAsIcon(base_dir: str, useIcon: bool) -> bool:
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
if not os.path.isfile(config_filename):
|
if not os.path.isfile(config_filename):
|
||||||
return False
|
return False
|
||||||
configJson = loadJson(config_filename, 0)
|
configJson = load_json(config_filename, 0)
|
||||||
if not configJson:
|
if not configJson:
|
||||||
return False
|
return False
|
||||||
configJson['show_publish_as_icon'] = useIcon
|
configJson['show_publish_as_icon'] = useIcon
|
||||||
|
@ -194,7 +194,7 @@ def _setIconsAsButtons(base_dir: str, useButtons: bool) -> bool:
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
if not os.path.isfile(config_filename):
|
if not os.path.isfile(config_filename):
|
||||||
return False
|
return False
|
||||||
configJson = loadJson(config_filename, 0)
|
configJson = load_json(config_filename, 0)
|
||||||
if not configJson:
|
if not configJson:
|
||||||
return False
|
return False
|
||||||
configJson['icons_as_buttons'] = useButtons
|
configJson['icons_as_buttons'] = useButtons
|
||||||
|
@ -207,7 +207,7 @@ def _setRssIconAtTop(base_dir: str, atTop: bool) -> bool:
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
if not os.path.isfile(config_filename):
|
if not os.path.isfile(config_filename):
|
||||||
return False
|
return False
|
||||||
configJson = loadJson(config_filename, 0)
|
configJson = load_json(config_filename, 0)
|
||||||
if not configJson:
|
if not configJson:
|
||||||
return False
|
return False
|
||||||
configJson['rss_icon_at_top'] = atTop
|
configJson['rss_icon_at_top'] = atTop
|
||||||
|
@ -221,7 +221,7 @@ def _setPublishButtonAtTop(base_dir: str, atTop: bool) -> bool:
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
if not os.path.isfile(config_filename):
|
if not os.path.isfile(config_filename):
|
||||||
return False
|
return False
|
||||||
configJson = loadJson(config_filename, 0)
|
configJson = load_json(config_filename, 0)
|
||||||
if not configJson:
|
if not configJson:
|
||||||
return False
|
return False
|
||||||
configJson['publish_button_at_top'] = atTop
|
configJson['publish_button_at_top'] = atTop
|
||||||
|
@ -235,7 +235,7 @@ def _setFullWidthTimelineButtonHeader(base_dir: str, fullWidth: bool) -> bool:
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
if not os.path.isfile(config_filename):
|
if not os.path.isfile(config_filename):
|
||||||
return False
|
return False
|
||||||
configJson = loadJson(config_filename, 0)
|
configJson = load_json(config_filename, 0)
|
||||||
if not configJson:
|
if not configJson:
|
||||||
return False
|
return False
|
||||||
configJson['full_width_tl_button_header'] = fullWidth
|
configJson['full_width_tl_button_header'] = fullWidth
|
||||||
|
@ -247,7 +247,7 @@ def getTheme(base_dir: str) -> str:
|
||||||
"""
|
"""
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
if os.path.isfile(config_filename):
|
if os.path.isfile(config_filename):
|
||||||
configJson = loadJson(config_filename, 0)
|
configJson = load_json(config_filename, 0)
|
||||||
if configJson:
|
if configJson:
|
||||||
if configJson.get('theme'):
|
if configJson.get('theme'):
|
||||||
return configJson['theme']
|
return configJson['theme']
|
||||||
|
@ -520,14 +520,14 @@ def _readVariablesFile(base_dir: str, theme_name: str,
|
||||||
allow_local_network_access: bool) -> None:
|
allow_local_network_access: bool) -> None:
|
||||||
"""Reads variables from a file in the theme directory
|
"""Reads variables from a file in the theme directory
|
||||||
"""
|
"""
|
||||||
themeParams = loadJson(variablesFile, 0)
|
themeParams = load_json(variablesFile, 0)
|
||||||
if not themeParams:
|
if not themeParams:
|
||||||
return
|
return
|
||||||
|
|
||||||
# set custom theme parameters
|
# set custom theme parameters
|
||||||
customVariablesFile = base_dir + '/accounts/theme.json'
|
customVariablesFile = base_dir + '/accounts/theme.json'
|
||||||
if os.path.isfile(customVariablesFile):
|
if os.path.isfile(customVariablesFile):
|
||||||
customThemeParams = loadJson(customVariablesFile, 0)
|
customThemeParams = load_json(customVariablesFile, 0)
|
||||||
if customThemeParams:
|
if customThemeParams:
|
||||||
for variableName, value in customThemeParams.items():
|
for variableName, value in customThemeParams.items():
|
||||||
themeParams[variableName] = value
|
themeParams[variableName] = value
|
||||||
|
|
38
utils.py
38
utils.py
|
@ -512,7 +512,7 @@ def setConfigParam(base_dir: str, variableName: str, variableValue) -> None:
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
configJson = {}
|
configJson = {}
|
||||||
if os.path.isfile(config_filename):
|
if os.path.isfile(config_filename):
|
||||||
configJson = loadJson(config_filename)
|
configJson = load_json(config_filename)
|
||||||
configJson[variableName] = variableValue
|
configJson[variableName] = variableValue
|
||||||
save_json(configJson, config_filename)
|
save_json(configJson, config_filename)
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ def get_config_param(base_dir: str, variableName: str):
|
||||||
"""
|
"""
|
||||||
_create_config(base_dir)
|
_create_config(base_dir)
|
||||||
config_filename = base_dir + '/config.json'
|
config_filename = base_dir + '/config.json'
|
||||||
configJson = loadJson(config_filename)
|
configJson = load_json(config_filename)
|
||||||
if configJson:
|
if configJson:
|
||||||
if variableName in configJson:
|
if variableName in configJson:
|
||||||
return configJson[variableName]
|
return configJson[variableName]
|
||||||
|
@ -654,14 +654,14 @@ def removeAvatarFromCache(base_dir: str, actorStr: str) -> None:
|
||||||
'unable to delete cached avatar ' + str(avatarFilename))
|
'unable to delete cached avatar ' + str(avatarFilename))
|
||||||
|
|
||||||
|
|
||||||
def save_json(jsonObject: {}, filename: str) -> bool:
|
def save_json(json_object: {}, filename: str) -> bool:
|
||||||
"""Saves json to a file
|
"""Saves json to a file
|
||||||
"""
|
"""
|
||||||
tries = 0
|
tries = 0
|
||||||
while tries < 5:
|
while tries < 5:
|
||||||
try:
|
try:
|
||||||
with open(filename, 'w+') as fp:
|
with open(filename, 'w+') as fp:
|
||||||
fp.write(json.dumps(jsonObject))
|
fp.write(json.dumps(json_object))
|
||||||
return True
|
return True
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: save_json ' + str(tries))
|
print('EX: save_json ' + str(tries))
|
||||||
|
@ -670,7 +670,7 @@ def save_json(jsonObject: {}, filename: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def loadJson(filename: str, delaySec: int = 2, maxTries: int = 5) -> {}:
|
def load_json(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
|
||||||
|
@ -682,15 +682,15 @@ def loadJson(filename: str, delaySec: int = 2, maxTries: int = 5) -> {}:
|
||||||
jsonObject = json.loads(data)
|
jsonObject = json.loads(data)
|
||||||
break
|
break
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('EX: loadJson exception ' + str(filename))
|
print('EX: load_json exception ' + str(filename))
|
||||||
if delaySec > 0:
|
if delaySec > 0:
|
||||||
time.sleep(delaySec)
|
time.sleep(delaySec)
|
||||||
tries += 1
|
tries += 1
|
||||||
return jsonObject
|
return jsonObject
|
||||||
|
|
||||||
|
|
||||||
def loadJsonOnionify(filename: str, domain: str, onion_domain: str,
|
def load_json_onionify(filename: str, domain: str, onion_domain: str,
|
||||||
delaySec: int = 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
|
||||||
"""
|
"""
|
||||||
|
@ -707,7 +707,7 @@ def loadJsonOnionify(filename: str, domain: str, onion_domain: str,
|
||||||
jsonObject = json.loads(data)
|
jsonObject = json.loads(data)
|
||||||
break
|
break
|
||||||
except BaseException:
|
except BaseException:
|
||||||
print('EX: loadJsonOnionify exception ' + str(filename))
|
print('EX: load_json_onionify exception ' + str(filename))
|
||||||
if delaySec > 0:
|
if delaySec > 0:
|
||||||
time.sleep(delaySec)
|
time.sleep(delaySec)
|
||||||
tries += 1
|
tries += 1
|
||||||
|
@ -921,7 +921,7 @@ def getDisplayName(base_dir: str, actor: str, person_cache: {}) -> str:
|
||||||
cachedActorFilename = \
|
cachedActorFilename = \
|
||||||
base_dir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
base_dir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
||||||
if os.path.isfile(cachedActorFilename):
|
if os.path.isfile(cachedActorFilename):
|
||||||
actor_json = loadJson(cachedActorFilename, 1)
|
actor_json = load_json(cachedActorFilename, 1)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if actor_json.get('name'):
|
if actor_json.get('name'):
|
||||||
nameFound = actor_json['name']
|
nameFound = actor_json['name']
|
||||||
|
@ -978,7 +978,7 @@ def getGenderFromBio(base_dir: str, actor: str, person_cache: {},
|
||||||
cachedActorFilename = \
|
cachedActorFilename = \
|
||||||
base_dir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
base_dir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
|
||||||
if os.path.isfile(cachedActorFilename):
|
if os.path.isfile(cachedActorFilename):
|
||||||
actor_json = loadJson(cachedActorFilename, 1)
|
actor_json = load_json(cachedActorFilename, 1)
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
return defaultGender
|
return defaultGender
|
||||||
# is gender defined as a profile tag?
|
# is gender defined as a profile tag?
|
||||||
|
@ -1430,7 +1430,7 @@ def canReplyTo(base_dir: str, nickname: str, domain: str,
|
||||||
postFilename = locatePost(base_dir, nickname, domain, postUrl)
|
postFilename = locatePost(base_dir, nickname, domain, postUrl)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return False
|
return False
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return False
|
return False
|
||||||
published = _getPublishedDate(post_json_object)
|
published = _getPublishedDate(post_json_object)
|
||||||
|
@ -1716,7 +1716,7 @@ def deletePost(base_dir: str, http_prefix: str,
|
||||||
debug: bool, recentPostsCache: {}) -> None:
|
debug: bool, recentPostsCache: {}) -> None:
|
||||||
"""Recursively deletes a post and its replies and attachments
|
"""Recursively deletes a post and its replies and attachments
|
||||||
"""
|
"""
|
||||||
post_json_object = loadJson(postFilename, 1)
|
post_json_object = load_json(postFilename, 1)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
# remove any replies
|
# remove any replies
|
||||||
_deletePostRemoveReplies(base_dir, nickname, domain,
|
_deletePostRemoveReplies(base_dir, nickname, domain,
|
||||||
|
@ -1949,7 +1949,7 @@ def isPublicPostFromUrl(base_dir: str, nickname: str, domain: str,
|
||||||
postFilename = locatePost(base_dir, nickname, domain, postUrl)
|
postFilename = locatePost(base_dir, nickname, domain, postUrl)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return False
|
return False
|
||||||
post_json_object = loadJson(postFilename, 1)
|
post_json_object = load_json(postFilename, 1)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return False
|
return False
|
||||||
return isPublicPost(post_json_object)
|
return isPublicPost(post_json_object)
|
||||||
|
@ -2214,7 +2214,7 @@ def undoLikesCollectionEntry(recentPostsCache: {},
|
||||||
"""Undoes a like for a particular actor
|
"""Undoes a like for a particular actor
|
||||||
"""
|
"""
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
# remove any cached version of this post so that the
|
# remove any cached version of this post so that the
|
||||||
|
@ -2279,7 +2279,7 @@ def undoReactionCollectionEntry(recentPostsCache: {},
|
||||||
"""Undoes an emoji reaction for a particular actor
|
"""Undoes an emoji reaction for a particular actor
|
||||||
"""
|
"""
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
# remove any cached version of this post so that the
|
# remove any cached version of this post so that the
|
||||||
|
@ -2344,7 +2344,7 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
|
||||||
collection has no relation to shared items in shares.py. It's
|
collection has no relation to shared items in shares.py. It's
|
||||||
shares of posts, not shares of physical objects.
|
shares of posts, not shares of physical objects.
|
||||||
"""
|
"""
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
# remove any cached version of this announce so that the announce
|
# remove any cached version of this announce so that the announce
|
||||||
|
@ -2412,7 +2412,7 @@ def updateAnnounceCollection(recentPostsCache: {},
|
||||||
same as shared items within shares.py
|
same as shared items within shares.py
|
||||||
It's shares of posts, not shares of physical objects.
|
It's shares of posts, not shares of physical objects.
|
||||||
"""
|
"""
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return
|
return
|
||||||
# remove any cached version of this announce so that the announce
|
# remove any cached version of this announce so that the announce
|
||||||
|
@ -2698,7 +2698,7 @@ def loadTranslationsFromFile(base_dir: str, language: str) -> ({}, str):
|
||||||
system_language = 'en'
|
system_language = 'en'
|
||||||
translationsFile = base_dir + '/translations/' + \
|
translationsFile = base_dir + '/translations/' + \
|
||||||
system_language + '.json'
|
system_language + '.json'
|
||||||
return loadJson(translationsFile), system_language
|
return load_json(translationsFile), system_language
|
||||||
|
|
||||||
|
|
||||||
def dmAllowedFromDomain(base_dir: str,
|
def dmAllowedFromDomain(base_dir: str,
|
||||||
|
|
|
@ -9,7 +9,7 @@ __module_group__ = "Accessibility"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
|
@ -29,7 +29,7 @@ def loadAccessKeysForAccounts(base_dir: str, keyShortcuts: {},
|
||||||
if not os.path.isfile(accessKeysFilename):
|
if not os.path.isfile(accessKeysFilename):
|
||||||
continue
|
continue
|
||||||
nickname = acct.split('@')[0]
|
nickname = acct.split('@')[0]
|
||||||
accessKeys = loadJson(accessKeysFilename)
|
accessKeys = load_json(accessKeysFilename)
|
||||||
if accessKeys:
|
if accessKeys:
|
||||||
keyShortcuts[nickname] = accessKeysTemplate.copy()
|
keyShortcuts[nickname] = accessKeysTemplate.copy()
|
||||||
for variableName, key in accessKeysTemplate.items():
|
for variableName, key in accessKeysTemplate.items():
|
||||||
|
@ -49,7 +49,7 @@ def htmlAccessKeys(cssCache: {}, base_dir: str,
|
||||||
accessKeysFilename = \
|
accessKeysFilename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/accessKeys.json'
|
acct_dir(base_dir, nickname, domain) + '/accessKeys.json'
|
||||||
if os.path.isfile(accessKeysFilename):
|
if os.path.isfile(accessKeysFilename):
|
||||||
accessKeysFromFile = loadJson(accessKeysFilename)
|
accessKeysFromFile = load_json(accessKeysFilename)
|
||||||
if accessKeysFromFile:
|
if accessKeysFromFile:
|
||||||
accessKeys = accessKeysFromFile
|
accessKeys = accessKeysFromFile
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from utils import get_config_param
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import weekDayOfMonthStart
|
from utils import weekDayOfMonthStart
|
||||||
from utils import getAltPath
|
from utils import getAltPath
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
|
@ -47,7 +47,7 @@ def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, base_dir: str,
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from utils import getFavFilenameFromUrl
|
||||||
from utils import get_base_content_from_post
|
from utils import get_base_content_from_post
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import votesOnNewswireItem
|
from utils import votesOnNewswireItem
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import is_editor
|
from utils import is_editor
|
||||||
|
@ -662,7 +662,7 @@ def htmlEditNewsPost(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
postFilename = locatePost(base_dir, nickname, domain, postUrl)
|
postFilename = locatePost(base_dir, nickname, domain, postUrl)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return ''
|
return ''
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ from utils import get_full_domain
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import getAltPath
|
from utils import getAltPath
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
@ -51,7 +51,7 @@ def htmlConfirmDelete(cssCache: {},
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, base_dir: str,
|
||||||
if not os.path.isfile(sharesFile):
|
if not os.path.isfile(sharesFile):
|
||||||
print('ERROR: no ' + sharesFileType + ' file ' + sharesFile)
|
print('ERROR: no ' + sharesFileType + ' file ' + sharesFile)
|
||||||
return None
|
return None
|
||||||
sharesJson = loadJson(sharesFile)
|
sharesJson = load_json(sharesFile)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
print('ERROR: unable to load ' + sharesFileType + '.json')
|
print('ERROR: unable to load ' + sharesFileType + '.json')
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -12,7 +12,7 @@ from utils import is_artist
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import is_editor
|
from utils import is_editor
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
|
@ -322,7 +322,7 @@ def htmlModerationInfo(cssCache: {}, translate: {},
|
||||||
for acct in accounts:
|
for acct in accounts:
|
||||||
acctNickname = acct.split('@')[0]
|
acctNickname = acct.split('@')[0]
|
||||||
accountDir = os.path.join(base_dir + '/accounts', acct)
|
accountDir = os.path.join(base_dir + '/accounts', acct)
|
||||||
actor_json = loadJson(accountDir + '.json')
|
actor_json = load_json(accountDir + '.json')
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
continue
|
continue
|
||||||
actor = actor_json['id']
|
actor = actor_json['id']
|
||||||
|
|
|
@ -38,7 +38,7 @@ from utils import get_config_param
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import is_editor
|
from utils import is_editor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import getCachedPostDirectory
|
from utils import getCachedPostDirectory
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
from utils import getProtocolPrefixes
|
from utils import getProtocolPrefixes
|
||||||
|
@ -2083,7 +2083,7 @@ def htmlIndividualPost(cssCache: {},
|
||||||
post_json_object['object']['inReplyTo'])
|
post_json_object['object']['inReplyTo'])
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
break
|
break
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
postStr = \
|
postStr = \
|
||||||
individualPostAsHtml(signing_priv_key_pem,
|
individualPostAsHtml(signing_priv_key_pem,
|
||||||
|
@ -2248,7 +2248,7 @@ def htmlEmojiReactionPicker(cssCache: {},
|
||||||
reactionsFilename = base_dir + '/emoji/reactions.json'
|
reactionsFilename = base_dir + '/emoji/reactions.json'
|
||||||
if not os.path.isfile(reactionsFilename):
|
if not os.path.isfile(reactionsFilename):
|
||||||
reactionsFilename = base_dir + '/emoji/default_reactions.json'
|
reactionsFilename = base_dir + '/emoji/default_reactions.json'
|
||||||
reactionsJson = loadJson(reactionsFilename)
|
reactionsJson = load_json(reactionsFilename)
|
||||||
emojiPicksStr = ''
|
emojiPicksStr = ''
|
||||||
baseUrl = '/users/' + nickname
|
baseUrl = '/users/' + nickname
|
||||||
postId = removeIdEnding(post_json_object['id'])
|
postId = removeIdEnding(post_json_object['id'])
|
||||||
|
|
|
@ -22,7 +22,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import isSystemAccount
|
from utils import isSystemAccount
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import getImageFormats
|
from utils import getImageFormats
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
@ -2126,7 +2126,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
ssbAddress = blogAddress = toxAddress = jamiAddress = ''
|
ssbAddress = blogAddress = toxAddress = jamiAddress = ''
|
||||||
cwtchAddress = briarAddress = manuallyApprovesFollowers = ''
|
cwtchAddress = briarAddress = manuallyApprovesFollowers = ''
|
||||||
|
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if actor_json.get('movedTo'):
|
if actor_json.get('movedTo'):
|
||||||
movedTo = actor_json['movedTo']
|
movedTo = actor_json['movedTo']
|
||||||
|
|
|
@ -16,7 +16,7 @@ from utils import isAccountDir
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import is_editor
|
from utils import is_editor
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
|
@ -76,10 +76,10 @@ def htmlSearchEmoji(cssCache: {}, translate: {},
|
||||||
emojiForm += htmlFooter()
|
emojiForm += htmlFooter()
|
||||||
return emojiForm
|
return emojiForm
|
||||||
|
|
||||||
emojiJson = loadJson(emojiLookupFilename)
|
emojiJson = load_json(emojiLookupFilename)
|
||||||
if emojiJson:
|
if emojiJson:
|
||||||
if os.path.isfile(customEmojiLookupFilename):
|
if os.path.isfile(customEmojiLookupFilename):
|
||||||
customEmojiJson = loadJson(customEmojiLookupFilename)
|
customEmojiJson = load_json(customEmojiLookupFilename)
|
||||||
if customEmojiJson:
|
if customEmojiJson:
|
||||||
emojiJson = dict(emojiJson, **customEmojiJson)
|
emojiJson = dict(emojiJson, **customEmojiJson)
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
if not os.path.isfile(sharesFilename):
|
if not os.path.isfile(sharesFilename):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
if federatedDomain not in shared_items_federated_domains:
|
if federatedDomain not in shared_items_federated_domains:
|
||||||
continue
|
continue
|
||||||
sharesFilename = catalogsDir + '/' + f
|
sharesFilename = catalogsDir + '/' + f
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ def htmlSkillsSearch(actor: str,
|
||||||
if not isAccountDir(f):
|
if not isAccountDir(f):
|
||||||
continue
|
continue
|
||||||
actorFilename = os.path.join(subdir, f)
|
actorFilename = os.path.join(subdir, f)
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if actor_json.get('id') and \
|
if actor_json.get('id') and \
|
||||||
noOfActorSkills(actor_json) > 0 and \
|
noOfActorSkills(actor_json) > 0 and \
|
||||||
|
@ -510,7 +510,7 @@ def htmlSkillsSearch(actor: str,
|
||||||
if not isAccountDir(f):
|
if not isAccountDir(f):
|
||||||
continue
|
continue
|
||||||
actorFilename = os.path.join(subdir, f)
|
actorFilename = os.path.join(subdir, f)
|
||||||
cachedActorJson = loadJson(actorFilename)
|
cachedActorJson = load_json(actorFilename)
|
||||||
if cachedActorJson:
|
if cachedActorJson:
|
||||||
if cachedActorJson.get('actor'):
|
if cachedActorJson.get('actor'):
|
||||||
actor_json = cachedActorJson['actor']
|
actor_json = cachedActorJson['actor']
|
||||||
|
@ -666,7 +666,7 @@ def htmlHistorySearch(cssCache: {}, translate: {}, base_dir: str,
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
index += 1
|
index += 1
|
||||||
continue
|
continue
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
index += 1
|
index += 1
|
||||||
continue
|
continue
|
||||||
|
@ -835,7 +835,7 @@ def htmlHashtagSearch(cssCache: {},
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
index += 1
|
index += 1
|
||||||
continue
|
continue
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
index += 1
|
index += 1
|
||||||
continue
|
continue
|
||||||
|
@ -962,7 +962,7 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
|
||||||
if index >= maxFeedLength:
|
if index >= maxFeedLength:
|
||||||
break
|
break
|
||||||
continue
|
continue
|
||||||
post_json_object = loadJson(postFilename)
|
post_json_object = load_json(postFilename)
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
if not isPublicPost(post_json_object):
|
if not isPublicPost(post_json_object):
|
||||||
index += 1
|
index += 1
|
||||||
|
|
|
@ -8,7 +8,7 @@ __status__ = "Production"
|
||||||
__module_group__ = "Web Interface"
|
__module_group__ = "Web Interface"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
|
@ -175,12 +175,12 @@ def htmlThemeDesigner(cssCache: {}, base_dir: str,
|
||||||
themeFilename = base_dir + '/theme/' + theme_name + '/theme.json'
|
themeFilename = base_dir + '/theme/' + theme_name + '/theme.json'
|
||||||
themeJson = {}
|
themeJson = {}
|
||||||
if os.path.isfile(themeFilename):
|
if os.path.isfile(themeFilename):
|
||||||
themeJson = loadJson(themeFilename)
|
themeJson = load_json(themeFilename)
|
||||||
|
|
||||||
# set custom theme parameters
|
# set custom theme parameters
|
||||||
customVariablesFile = base_dir + '/accounts/theme.json'
|
customVariablesFile = base_dir + '/accounts/theme.json'
|
||||||
if os.path.isfile(customVariablesFile):
|
if os.path.isfile(customVariablesFile):
|
||||||
customThemeParams = loadJson(customVariablesFile, 0)
|
customThemeParams = load_json(customVariablesFile, 0)
|
||||||
if customThemeParams:
|
if customThemeParams:
|
||||||
for variableName, value in customThemeParams.items():
|
for variableName, value in customThemeParams.items():
|
||||||
themeJson[variableName] = value
|
themeJson[variableName] = value
|
||||||
|
|
|
@ -14,7 +14,7 @@ from session import getJson
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import getProtocolPrefixes
|
from utils import getProtocolPrefixes
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
@ -362,7 +362,7 @@ def sharesTimelineJson(actor: str, pageNumber: int, itemsPerPage: int,
|
||||||
sharesFilename = accountDir + '/' + sharesFileType + '.json'
|
sharesFilename = accountDir + '/' + sharesFileType + '.json'
|
||||||
if not os.path.isfile(sharesFilename):
|
if not os.path.isfile(sharesFilename):
|
||||||
continue
|
continue
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
continue
|
continue
|
||||||
accountNickname = handle.split('@')[0]
|
accountNickname = handle.split('@')[0]
|
||||||
|
@ -399,7 +399,7 @@ def sharesTimelineJson(actor: str, pageNumber: int, itemsPerPage: int,
|
||||||
if federatedDomain not in shared_items_federated_domains:
|
if federatedDomain not in shared_items_federated_domains:
|
||||||
continue
|
continue
|
||||||
sharesFilename = catalogsDir + '/' + f
|
sharesFilename = catalogsDir + '/' + f
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
continue
|
continue
|
||||||
ctr = 0
|
ctr = 0
|
||||||
|
@ -1514,7 +1514,7 @@ def htmlShowShare(base_dir: str, domain: str, nickname: str,
|
||||||
sharesFileType + '.json'
|
sharesFileType + '.json'
|
||||||
if not os.path.isfile(sharesFilename):
|
if not os.path.isfile(sharesFilename):
|
||||||
return None
|
return None
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
else:
|
else:
|
||||||
# federated shared item
|
# federated shared item
|
||||||
if sharesFileType == 'shares':
|
if sharesFileType == 'shares':
|
||||||
|
@ -1533,7 +1533,7 @@ def htmlShowShare(base_dir: str, domain: str, nickname: str,
|
||||||
if federatedDomain not in shared_items_federated_domains:
|
if federatedDomain not in shared_items_federated_domains:
|
||||||
continue
|
continue
|
||||||
sharesFilename = catalogsDir + '/' + f
|
sharesFilename = catalogsDir + '/' + f
|
||||||
sharesJson = loadJson(sharesFilename)
|
sharesJson = load_json(sharesFilename)
|
||||||
if not sharesJson:
|
if not sharesJson:
|
||||||
continue
|
continue
|
||||||
if sharesJson.get(itemID):
|
if sharesJson.get(itemID):
|
||||||
|
|
|
@ -10,7 +10,7 @@ __module_group__ = "Onboarding"
|
||||||
import os
|
import os
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from utils import removeHtml
|
from utils import removeHtml
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import get_image_extensions
|
from utils import get_image_extensions
|
||||||
from utils import getImageFormats
|
from utils import getImageFormats
|
||||||
|
@ -100,7 +100,7 @@ def htmlWelcomeProfile(base_dir: str, nickname: str, domain: str,
|
||||||
profileForm += '</center>\n'
|
profileForm += '</center>\n'
|
||||||
|
|
||||||
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
displayNickname = actor_json['name']
|
displayNickname = actor_json['name']
|
||||||
profileForm += '<div class="container">\n'
|
profileForm += '<div class="container">\n'
|
||||||
profileForm += \
|
profileForm += \
|
||||||
|
|
14
webfinger.py
14
webfinger.py
|
@ -13,8 +13,8 @@ from session import getJson
|
||||||
from cache import storeWebfingerInCache
|
from cache import storeWebfingerInCache
|
||||||
from cache import getWebfingerFromCache
|
from cache import getWebfingerFromCache
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import loadJson
|
from utils import load_json
|
||||||
from utils import loadJsonOnionify
|
from utils import load_json_onionify
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import getProtocolPrefixes
|
from utils import getProtocolPrefixes
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
|
@ -270,10 +270,10 @@ def webfingerLookup(path: str, base_dir: str,
|
||||||
print('DEBUG: WEBFINGER filename not found ' + filename)
|
print('DEBUG: WEBFINGER filename not found ' + filename)
|
||||||
return None
|
return None
|
||||||
if not onionify:
|
if not onionify:
|
||||||
wfJson = loadJson(filename)
|
wfJson = load_json(filename)
|
||||||
else:
|
else:
|
||||||
print('Webfinger request for onionified ' + handle)
|
print('Webfinger request for onionified ' + handle)
|
||||||
wfJson = loadJsonOnionify(filename, domain, onion_domain)
|
wfJson = load_json_onionify(filename, domain, onion_domain)
|
||||||
if not wfJson:
|
if not wfJson:
|
||||||
wfJson = {"nickname": "unknown"}
|
wfJson = {"nickname": "unknown"}
|
||||||
return wfJson
|
return wfJson
|
||||||
|
@ -435,14 +435,14 @@ def webfingerUpdate(base_dir: str, nickname: str, domain: str,
|
||||||
handle = handle.replace(onion_domain, domain)
|
handle = handle.replace(onion_domain, domain)
|
||||||
onionify = True
|
onionify = True
|
||||||
if not onionify:
|
if not onionify:
|
||||||
wfJson = loadJson(filename)
|
wfJson = load_json(filename)
|
||||||
else:
|
else:
|
||||||
wfJson = loadJsonOnionify(filename, domain, onion_domain)
|
wfJson = load_json_onionify(filename, domain, onion_domain)
|
||||||
if not wfJson:
|
if not wfJson:
|
||||||
return
|
return
|
||||||
|
|
||||||
actorFilename = base_dir + '/accounts/' + handle + '.json'
|
actorFilename = base_dir + '/accounts/' + handle + '.json'
|
||||||
actor_json = loadJson(actorFilename)
|
actor_json = load_json(actorFilename)
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue