Extra architecture graphs

main
Bob Mottram 2021-06-26 15:21:24 +01:00
parent 0ae0208260
commit c37f3ac004
22 changed files with 74 additions and 65 deletions

View File

@ -7,7 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
__module_group__ = "ActivityPub" __module_group__ = "ActivityPub"
from domainhandler import removeDomainPort from utils import removeDomainPort
from utils import hasObjectDict from utils import hasObjectDict
from utils import removeIdEnding from utils import removeIdEnding
from utils import hasUsersPath from utils import hasUsersPath

View File

@ -11,7 +11,7 @@ import os
import json import json
import time import time
from datetime import datetime from datetime import datetime
from domainhandler import removeDomainPort from utils import removeDomainPort
from utils import hasObjectDict from utils import hasObjectDict
from utils import isAccountDir from utils import isAccountDir
from utils import getCachedPostFilename from utils import getCachedPostFilename

View File

@ -11,7 +11,7 @@ import os
from pprint import pprint from pprint import pprint
from webfinger import webfingerHandle from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from domainhandler import removeDomainPort from utils import removeDomainPort
from utils import hasUsersPath from utils import hasUsersPath
from utils import getFullDomain from utils import getFullDomain
from utils import removeIdEnding from utils import removeIdEnding

View File

@ -11,7 +11,7 @@ import os
import email.parser import email.parser
import urllib.parse import urllib.parse
from shutil import copyfile from shutil import copyfile
from domainhandler import removeDomainPort from utils import removeDomainPort
from utils import isValidLanguage from utils import isValidLanguage
from utils import getImageExtensions from utils import getImageExtensions
from utils import loadJson from utils import loadJson

View File

@ -9,7 +9,7 @@ __module_group__ = "ActivityPub"
import os import os
from datetime import datetime from datetime import datetime
from domainhandler import removeDomainPort from utils import removeDomainPort
from utils import hasUsersPath from utils import hasUsersPath
from utils import getFullDomain from utils import getFullDomain
from utils import removeIdEnding from utils import removeIdEnding

View File

@ -1,32 +0,0 @@
__filename__ = "domainhandler.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Core"
def removeDomainPort(domain: str) -> str:
"""If the domain has a port appended then remove it
eg. mydomain.com:80 becomes mydomain.com
"""
if ':' in domain:
if domain.startswith('did:'):
return domain
domain = domain.split(':')[0]
return domain
def getPortFromDomain(domain: str) -> int:
"""If the domain has a port number appended then return it
eg. mydomain.com:80 returns 80
"""
if ':' in domain:
if domain.startswith('did:'):
return None
portStr = domain.split(':')[1]
if portStr.isdigit():
return int(portStr)
return None

View File

@ -61,8 +61,8 @@ from tests import testUpdateActor
from tests import runAllTests from tests import runAllTests
from auth import storeBasicCredentials from auth import storeBasicCredentials
from auth import createPassword from auth import createPassword
from domainhandler import removeDomainPort from utils import removeDomainPort
from domainhandler import getPortFromDomain from utils import getPortFromDomain
from utils import hasUsersPath from utils import hasUsersPath
from utils import getFullDomain from utils import getFullDomain
from utils import setConfigParam from utils import setConfigParam

View File

@ -9,7 +9,7 @@ __module_group__ = "ActivityPub"
from pprint import pprint from pprint import pprint
import os import os
from domainhandler import removeDomainPort from utils import removeDomainPort
from utils import hasObjectDict from utils import hasObjectDict
from utils import hasUsersPath from utils import hasUsersPath
from utils import getFullDomain from utils import getFullDomain

View File

@ -8,7 +8,18 @@ __status__ = "Production"
__module_group__ = "Calendar" __module_group__ = "Calendar"
import os import os
from domainhandler import removeDomainPort
def _portDomainRemove(domain: str) -> str:
"""If the domain has a port appended then remove it
eg. mydomain.com:80 becomes mydomain.com
same as removeDomainPort in utils.py
"""
if ':' in domain:
if domain.startswith('did:'):
return domain
domain = domain.split(':')[0]
return domain
def receivingCalendarEvents(baseDir: str, nickname: str, domain: str, def receivingCalendarEvents(baseDir: str, nickname: str, domain: str,
@ -44,7 +55,7 @@ def _receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
indicating whether to receive calendar events from that account indicating whether to receive calendar events from that account
""" """
# check that a following file exists # check that a following file exists
domain = removeDomainPort(domain) domain = _portDomainRemove(domain)
followingFilename = baseDir + '/accounts/' + \ followingFilename = baseDir + '/accounts/' + \
nickname + '@' + domain + '/following.txt' nickname + '@' + domain + '/following.txt'
if not os.path.isfile(followingFilename): if not os.path.isfile(followingFilename):

View File

@ -13,8 +13,8 @@ import datetime
import time import time
import random import random
from linked_data_sig import verifyJsonSignature from linked_data_sig import verifyJsonSignature
from domainhandler import removeDomainPort from utils import removeDomainPort
from domainhandler import getPortFromDomain from utils import getPortFromDomain
from utils import hasObjectDict from utils import hasObjectDict
from utils import dmAllowedFromDomain from utils import dmAllowedFromDomain
from utils import isRecentPost from utils import isRecentPost

View File

@ -7,7 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
__module_group__ = "ActivityPub" __module_group__ = "ActivityPub"
from domainhandler import removeDomainPort from utils import removeDomainPort
from utils import hasObjectDict from utils import hasObjectDict
from utils import hasUsersPath from utils import hasUsersPath
from utils import getFullDomain from utils import getFullDomain

View File

@ -12,8 +12,8 @@ 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 loadJson
from domainhandler import removeDomainPort from utils import removeDomainPort
from domainhandler import getPortFromDomain from utils import getPortFromDomain
def manualDenyFollowRequest(session, baseDir: str, def manualDenyFollowRequest(session, baseDir: str,

View File

@ -38,7 +38,7 @@ from roles import setRole
from roles import setRolesFromList from roles import setRolesFromList
from roles import getActorRolesList from roles import getActorRolesList
from media import processMetaData from media import processMetaData
from domainhandler import removeDomainPort from utils import removeDomainPort
from utils import getStatusNumber from utils import getStatusNumber
from utils import getFullDomain from utils import getFullDomain
from utils import validNickname from utils import validNickname

View File

@ -32,8 +32,8 @@ from session import postImage
from webfinger import webfingerHandle from webfinger import webfingerHandle
from httpsig import createSignedHeader from httpsig import createSignedHeader
from siteactive import siteIsActive from siteactive import siteIsActive
from domainhandler import removeDomainPort from utils import removeDomainPort
from domainhandler import getPortFromDomain from utils import getPortFromDomain
from utils import hasObjectDict from utils import hasObjectDict
from utils import rejectPostId from utils import rejectPostId
from utils import removeInvalidChars from utils import removeInvalidChars

View File

@ -11,7 +11,7 @@ import os
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
from utils import getStatusNumber from utils import getStatusNumber
from domainhandler import removeDomainPort from utils import removeDomainPort
def _clearRoleStatus(baseDir: str, role: str) -> None: def _clearRoleStatus(baseDir: str, role: str) -> None:

View File

@ -20,7 +20,7 @@ from utils import loadJson
from utils import saveJson from utils import saveJson
from utils import getImageExtensions from utils import getImageExtensions
from utils import hasObjectDict from utils import hasObjectDict
from domainhandler import removeDomainPort from utils import removeDomainPort
from media import processMetaData from media import processMetaData

View File

@ -2900,6 +2900,7 @@ def _moduleInGroups(modName: str, includeGroups: [], modGroups: {}) -> bool:
def _diagramGroups(includeGroups: [], def _diagramGroups(includeGroups: [],
excludeExtraModules: [],
modules: {}, modGroups: {}, modules: {}, modGroups: {},
maxModuleCalls: int) -> None: maxModuleCalls: int) -> None:
"""Draws a dot diagram containing only the given module groups """Draws a dot diagram containing only the given module groups
@ -2907,9 +2908,10 @@ def _diagramGroups(includeGroups: [],
callGraphStr = 'digraph EpicyonGroups {\n\n' callGraphStr = 'digraph EpicyonGroups {\n\n'
callGraphStr += ' graph [fontsize=10 fontname="Verdana" compound=true];\n' callGraphStr += ' graph [fontsize=10 fontname="Verdana" compound=true];\n'
callGraphStr += ' node [fontsize=10 fontname="Verdana"];\n\n' callGraphStr += ' node [fontsize=10 fontname="Verdana"];\n\n'
excludeModulesFromDiagram = ( excludeModulesFromDiagram = [
'setup', 'tests', '__init__' 'setup', 'tests', '__init__'
) ]
excludeModulesFromDiagram += excludeExtraModules
# colors of modules nodes # colors of modules nodes
for modName, modProperties in modules.items(): for modName, modProperties in modules.items():
if modName in excludeModulesFromDiagram: if modName in excludeModulesFromDiagram:
@ -3223,15 +3225,21 @@ def _testFunctions():
modules[modName]['calls'] = [modCall] modules[modName]['calls'] = [modCall]
lineCtr += 1 lineCtr += 1
_diagramGroups(['Commandline Interface', 'ActivityPub', 'Core'], _diagramGroups(['Commandline Interface', 'ActivityPub'], ['utils'],
modules, modGroups, maxModuleCalls) modules, modGroups, maxModuleCalls)
_diagramGroups(['Timeline', 'Core'], _diagramGroups(['Commandline Interface', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls) modules, modGroups, maxModuleCalls)
_diagramGroups(['Web Interface', 'Core'], _diagramGroups(['Timeline', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls) modules, modGroups, maxModuleCalls)
_diagramGroups(['Web Interface Columns', 'Core'], _diagramGroups(['Web Interface', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls) modules, modGroups, maxModuleCalls)
_diagramGroups(['Core'], _diagramGroups(['Web Interface Columns', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['Core'], [],
modules, modGroups, maxModuleCalls)
_diagramGroups(['ActivityPub'], [],
modules, modGroups, maxModuleCalls)
_diagramGroups(['ActivityPub', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls) modules, modGroups, maxModuleCalls)
callGraphStr = 'digraph Epicyon {\n\n' callGraphStr = 'digraph Epicyon {\n\n'

View File

@ -16,8 +16,6 @@ import json
import idna import idna
import locale import locale
from pprint import pprint from pprint import pprint
from domainhandler import removeDomainPort
from domainhandler import getPortFromDomain
from followingCalendar import addPersonToCalendar from followingCalendar import addPersonToCalendar
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives import hashes
@ -2453,3 +2451,27 @@ def getActorPropertyUrl(actorJson: {}, propertyName: str) -> str:
continue continue
return propertyValue['value'] return propertyValue['value']
return '' return ''
def removeDomainPort(domain: str) -> str:
"""If the domain has a port appended then remove it
eg. mydomain.com:80 becomes mydomain.com
"""
if ':' in domain:
if domain.startswith('did:'):
return domain
domain = domain.split(':')[0]
return domain
def getPortFromDomain(domain: str) -> int:
"""If the domain has a port number appended then return it
eg. mydomain.com:80 returns 80
"""
if ':' in domain:
if domain.startswith('did:'):
return None
portStr = domain.split(':')[1]
if portStr.isdigit():
return int(portStr)
return None

View File

@ -19,7 +19,7 @@ from utils import locatePost
from utils import loadJson from utils import loadJson
from utils import weekDayOfMonthStart from utils import weekDayOfMonthStart
from utils import getAltPath from utils import getAltPath
from domainhandler import removeDomainPort from utils import removeDomainPort
from happening import getTodaysEvents from happening import getTodaysEvents
from happening import getCalendarEvents from happening import getCalendarEvents
from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlHeaderWithExternalStyle

View File

@ -11,7 +11,7 @@ import os
from utils import getConfigParam from utils import getConfigParam
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import isEditor from utils import isEditor
from domainhandler import removeDomainPort from utils import removeDomainPort
from webapp_utils import sharesTimelineJson from webapp_utils import sharesTimelineJson
from webapp_utils import htmlPostSeparator from webapp_utils import htmlPostSeparator
from webapp_utils import getLeftImageFile from webapp_utils import getLeftImageFile

View File

@ -17,7 +17,7 @@ from utils import votesOnNewswireItem
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import isEditor from utils import isEditor
from utils import getConfigParam from utils import getConfigParam
from domainhandler import removeDomainPort from utils import removeDomainPort
from posts import isModerator from posts import isModerator
from webapp_utils import getRightImageFile from webapp_utils import getRightImageFile
from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlHeaderWithExternalStyle

View File

@ -17,7 +17,7 @@ from utils import loadJson
from utils import loadJsonOnionify from utils import loadJsonOnionify
from utils import saveJson from utils import saveJson
from utils import getProtocolPrefixes from utils import getProtocolPrefixes
from domainhandler import removeDomainPort from utils import removeDomainPort
def _parseHandle(handle: str) -> (str, str): def _parseHandle(handle: str) -> (str, str):