mirror of https://gitlab.com/bashrc2/epicyon
Change function name
parent
2306d8d393
commit
ef5b5d7869
|
@ -98,7 +98,7 @@ from follow import getFollowingFeed
|
|||
from follow import sendFollowRequest
|
||||
from follow import unfollowAccount
|
||||
from follow import createInitialLastSeen
|
||||
from skills import getSkillsFromString
|
||||
from skills import getSkillsFromList
|
||||
from skills import noOfActorSkills
|
||||
from skills import actorHasSkill
|
||||
from skills import actorSkillValue
|
||||
|
@ -7500,7 +7500,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.keyShortcuts[nickname]
|
||||
actorSkillsList = \
|
||||
actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsList)
|
||||
skills = getSkillsFromList(actorSkillsList)
|
||||
msg = \
|
||||
htmlProfile(self.server.rssIconAtTop,
|
||||
self.server.cssCache,
|
||||
|
@ -7539,7 +7539,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if self._fetchAuthenticated():
|
||||
actorSkillsList = \
|
||||
actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsList)
|
||||
skills = getSkillsFromList(actorSkillsList)
|
||||
msg = json.dumps(skills,
|
||||
ensure_ascii=False)
|
||||
msg = msg.encode('utf-8')
|
||||
|
|
20
skills.py
20
skills.py
|
@ -28,15 +28,15 @@ def setSkillsFromDict(actorJson: {}, skillsDict: {}) -> []:
|
|||
return skillsList
|
||||
|
||||
|
||||
def getSkillsFromString(skillsStr: str) -> {}:
|
||||
"""Returns a dict of skills from a string
|
||||
def getSkillsFromList(skillsList: []) -> {}:
|
||||
"""Returns a dict of skills from a list
|
||||
"""
|
||||
if isinstance(skillsStr, list):
|
||||
skillsList = skillsStr
|
||||
if isinstance(skillsList, list):
|
||||
skillsList2 = skillsList
|
||||
else:
|
||||
skillsList = skillsStr.split(',')
|
||||
skillsList2 = skillsList.split(',')
|
||||
skillsDict = {}
|
||||
for skill in skillsList:
|
||||
for skill in skillsList2:
|
||||
if ':' not in skill:
|
||||
continue
|
||||
name = skill.split(':')[0].strip().lower()
|
||||
|
@ -51,7 +51,7 @@ def actorHasSkill(actorJson: {}, skillName: str) -> bool:
|
|||
"""Returns true if the actor has the given skill
|
||||
"""
|
||||
skillsDict = \
|
||||
getSkillsFromString(actorJson['hasOccupation']['skills'])
|
||||
getSkillsFromList(actorJson['hasOccupation']['skills'])
|
||||
if not skillsDict:
|
||||
return False
|
||||
return skillsDict.get(skillName.lower())
|
||||
|
@ -61,7 +61,7 @@ def actorSkillValue(actorJson: {}, skillName: str) -> int:
|
|||
"""Returns The skill level from an actor
|
||||
"""
|
||||
skillsDict = \
|
||||
getSkillsFromString(actorJson['hasOccupation']['skills'])
|
||||
getSkillsFromList(actorJson['hasOccupation']['skills'])
|
||||
if not skillsDict:
|
||||
return 0
|
||||
skillName = skillName.lower()
|
||||
|
@ -101,7 +101,7 @@ def setActorSkillLevel(actorJson: {},
|
|||
'skills': ''
|
||||
}
|
||||
skillsDict = \
|
||||
getSkillsFromString(actorJson['hasOccupation']['skills'])
|
||||
getSkillsFromList(actorJson['hasOccupation']['skills'])
|
||||
if skillLevelPercent > 0:
|
||||
skillsDict[skill] = skillLevelPercent
|
||||
else:
|
||||
|
@ -138,7 +138,7 @@ def getSkills(baseDir: str, nickname: str, domain: str) -> []:
|
|||
if actorJson:
|
||||
if not actorJson.get('hasOccupation'):
|
||||
return None
|
||||
return getSkillsFromString(actorJson['hasOccupation']['skills'])
|
||||
return getSkillsFromList(actorJson['hasOccupation']['skills'])
|
||||
return None
|
||||
|
||||
|
||||
|
|
4
tests.py
4
tests.py
|
@ -68,7 +68,7 @@ from person import setBio
|
|||
# from person import generateRSAKey
|
||||
from skills import setSkillLevel
|
||||
from skills import setSkillsFromDict
|
||||
from skills import getSkillsFromString
|
||||
from skills import getSkillsFromList
|
||||
from roles import setRolesFromList
|
||||
from roles import getRolesFromString
|
||||
from roles import setRole
|
||||
|
@ -3673,7 +3673,7 @@ def testSkills() -> None:
|
|||
}
|
||||
setSkillsFromDict(actorJson, skillsDict)
|
||||
assert actorJson['hasOccupation']['skills']
|
||||
skillsDict = getSkillsFromString(actorJson['hasOccupation']['skills'])
|
||||
skillsDict = getSkillsFromList(actorJson['hasOccupation']['skills'])
|
||||
assert skillsDict.get('bakery')
|
||||
assert skillsDict.get('gardening')
|
||||
assert skillsDict['bakery'] == 40
|
||||
|
|
|
@ -21,7 +21,7 @@ from utils import isPublicPost
|
|||
from utils import firstParagraphFromString
|
||||
from utils import searchBoxPosts
|
||||
from skills import noOfActorSkills
|
||||
from skills import getSkillsFromString
|
||||
from skills import getSkillsFromList
|
||||
from categories import getHashtagCategory
|
||||
from feeds import rss2TagHeader
|
||||
from feeds import rss2TagFooter
|
||||
|
@ -421,7 +421,7 @@ def htmlSkillsSearch(actor: str,
|
|||
actorJson.get('icon'):
|
||||
actor = actorJson['id']
|
||||
actorSkillsList = actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsList)
|
||||
skills = getSkillsFromList(actorSkillsList)
|
||||
for skillName, skillLevel in skills.items():
|
||||
skillName = skillName.lower()
|
||||
if not (skillName in skillsearch or
|
||||
|
@ -463,7 +463,7 @@ def htmlSkillsSearch(actor: str,
|
|||
actor = actorJson['id']
|
||||
actorSkillsList = \
|
||||
actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsList)
|
||||
skills = getSkillsFromList(actorSkillsList)
|
||||
for skillName, skillLevel in skills.items():
|
||||
skillName = skillName.lower()
|
||||
if not (skillName in skillsearch or
|
||||
|
|
Loading…
Reference in New Issue