mirror of https://gitlab.com/bashrc2/epicyon
Split camelcase display names for speaker clarity
parent
15c5280c95
commit
30e11be0b0
|
@ -12,6 +12,7 @@ import random
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from auth import createBasicAuthHeader
|
from auth import createBasicAuthHeader
|
||||||
from session import getJson
|
from session import getJson
|
||||||
|
from utils import camelCaseSplit
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getGenderFromBio
|
from utils import getGenderFromBio
|
||||||
|
@ -378,6 +379,7 @@ def updateSpeaker(baseDir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
speakerName = _removeEmojiFromText(speakerName)
|
speakerName = _removeEmojiFromText(speakerName)
|
||||||
speakerName = speakerName.replace('_', ' ')
|
speakerName = speakerName.replace('_', ' ')
|
||||||
|
speakerName = camelCaseSplit(speakerName)
|
||||||
gender = getGenderFromBio(baseDir, postJsonObject['actor'],
|
gender = getGenderFromBio(baseDir, postJsonObject['actor'],
|
||||||
personCache, translate)
|
personCache, translate)
|
||||||
if announcingActor:
|
if announcingActor:
|
||||||
|
|
11
tests.py
11
tests.py
|
@ -34,6 +34,7 @@ from follow import clearFollows
|
||||||
from follow import clearFollowers
|
from follow import clearFollowers
|
||||||
from follow import sendFollowRequestViaServer
|
from follow import sendFollowRequestViaServer
|
||||||
from follow import sendUnfollowRequestViaServer
|
from follow import sendUnfollowRequestViaServer
|
||||||
|
from utils import camelCaseSplit
|
||||||
from utils import decodedHost
|
from utils import decodedHost
|
||||||
from utils import getFullDomain
|
from utils import getFullDomain
|
||||||
from utils import validNickname
|
from utils import validNickname
|
||||||
|
@ -3389,9 +3390,19 @@ def testSpeakerReplaceLinks():
|
||||||
assert 'Web link support.torproject.org' in result
|
assert 'Web link support.torproject.org' in result
|
||||||
|
|
||||||
|
|
||||||
|
def testCamelCaseSplit():
|
||||||
|
print('testCamelCaseSplit')
|
||||||
|
testStr = 'ThisIsCamelCase'
|
||||||
|
assert camelCaseSplit(testStr) == 'This Is Camel Case'
|
||||||
|
|
||||||
|
testStr = 'Notcamelcase test'
|
||||||
|
assert camelCaseSplit(testStr) == 'Notcamelcase test'
|
||||||
|
|
||||||
|
|
||||||
def runAllTests():
|
def runAllTests():
|
||||||
print('Running tests...')
|
print('Running tests...')
|
||||||
testFunctions()
|
testFunctions()
|
||||||
|
testCamelCaseSplit()
|
||||||
testSpeakerReplaceLinks()
|
testSpeakerReplaceLinks()
|
||||||
testExtractTextFieldsInPOST()
|
testExtractTextFieldsInPOST()
|
||||||
testMarkdownToHtml()
|
testMarkdownToHtml()
|
||||||
|
|
14
utils.py
14
utils.py
|
@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -2020,3 +2021,16 @@ def isRecentPost(postJsonObject: {}, maxDays=3) -> bool:
|
||||||
if publishedDaysSinceEpoch < recently:
|
if publishedDaysSinceEpoch < recently:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def camelCaseSplit(text: str) -> str:
|
||||||
|
""" Splits CamelCase into "Camel Case"
|
||||||
|
"""
|
||||||
|
matches = re.finditer('.+?(?:(?<=[a-z])(?=[A-Z])|' +
|
||||||
|
'(?<=[A-Z])(?=[A-Z][a-z])|$)', text)
|
||||||
|
if not matches:
|
||||||
|
return text
|
||||||
|
resultStr = ''
|
||||||
|
for word in matches:
|
||||||
|
resultStr += word.group(0) + ' '
|
||||||
|
return resultStr.strip()
|
||||||
|
|
Loading…
Reference in New Issue