From 264747d7f808d839840c6a6b8d3f98e69c6e6dea Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 25 Mar 2021 12:39:10 +0000 Subject: [PATCH] Split profile function --- desktop_client.py | 62 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/desktop_client.py b/desktop_client.py index 8f3f0ce40..293bf5a0c 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -758,6 +758,39 @@ def _readLocalBoxPost(session, nickname: str, domain: str, return postJsonObject +def _showActor(baseDir: str, actorJson: {}, translate: {}, + systemLanguage: str, screenreader: str, espeak) -> None: + """ + """ + actor = actorJson['id'] + actorNickname = getNicknameFromActor(actor) + actorDomain, actorPort = getDomainFromActor(actor) + actorDomainFull = getFullDomain(actorDomain, actorPort) + handle = '@' + actorNickname + '@' + actorDomainFull + + sayStr = handle + _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + print(actor) + if actorJson.get('movedTo'): + sayStr = 'Moved to ' + actorJson['movedTo'] + _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + if actorJson.get('alsoKnownAs'): + alsoKnownAsStr = '' + ctr = 0 + for altActor in actorJson['alsoKnownAs']: + if ctr > 0: + alsoKnownAsStr += ', ' + ctr += 1 + alsoKnownAsStr += altActor + + sayStr = 'Also known as ' + alsoKnownAsStr + _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + if actorJson.get('summary'): + sayStr = removeHtml(actorJson['summary']) + sayStr2 = speakableText(baseDir, sayStr, translate) + _sayCommand(sayStr, sayStr2, screenreader, systemLanguage, espeak) + + def _showProfile(session, nickname: str, domain: str, httpPrefix: str, baseDir: str, boxName: str, pageNumber: int, index: int, boxJson: {}, @@ -796,33 +829,8 @@ def _showProfile(session, nickname: str, domain: str, isHttp = True actorJson = getActorJson(actor, isHttp, False, False, True) - actor = actorJson['id'] - actorNickname = getNicknameFromActor(actor) - actorDomain, actorPort = getDomainFromActor(actor) - actorDomainFull = getFullDomain(actorDomain, actorPort) - handle = '@' + actorNickname + '@' + actorDomainFull - - sayStr = handle - _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) - print(actor) - if actorJson.get('movedTo'): - sayStr = 'Moved to ' + actorJson['movedTo'] - _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) - if actorJson.get('alsoKnownAs'): - alsoKnownAsStr = '' - ctr = 0 - for altActor in actorJson['alsoKnownAs']: - if ctr > 0: - alsoKnownAsStr += ', ' - ctr += 1 - alsoKnownAsStr += altActor - - sayStr = 'Also known as ' + alsoKnownAsStr - _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) - if actorJson.get('summary'): - sayStr = removeHtml(actorJson['summary']) - sayStr2 = speakableText(baseDir, sayStr, translate) - _sayCommand(sayStr, sayStr2, screenreader, systemLanguage, espeak) + _showActor(baseDir, actorJson, translate, + systemLanguage, screenreader, espeak) return actorJson