mirror of https://gitlab.com/bashrc2/epicyon
Convert skills to a list
parent
1ebb8a5d66
commit
2c70942481
|
@ -7497,9 +7497,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if self.server.keyShortcuts.get(nickname):
|
||||
accessKeys = \
|
||||
self.server.keyShortcuts[nickname]
|
||||
actorSkillsStr = \
|
||||
actorSkillsList = \
|
||||
actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsStr)
|
||||
skills = getSkillsFromString(actorSkillsList)
|
||||
msg = \
|
||||
htmlProfile(self.server.rssIconAtTop,
|
||||
self.server.cssCache,
|
||||
|
@ -7536,9 +7536,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'show skills')
|
||||
else:
|
||||
if self._fetchAuthenticated():
|
||||
actorSkillsStr = \
|
||||
actorSkillsList = \
|
||||
actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsStr)
|
||||
skills = getSkillsFromString(actorSkillsList)
|
||||
msg = json.dumps(skills,
|
||||
ensure_ascii=False)
|
||||
msg = msg.encode('utf-8')
|
||||
|
|
|
@ -281,7 +281,7 @@ def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
|||
'hasOccupation': {
|
||||
'@type': 'Occupation',
|
||||
'name': "",
|
||||
'skills': ""
|
||||
'skills': []
|
||||
},
|
||||
"affiliation": {
|
||||
"@type": "OrganizationRole",
|
||||
|
@ -586,7 +586,7 @@ def personUpgradeActor(baseDir: str, personJson: {},
|
|||
personJson['hasOccupation'] = {
|
||||
'@type': 'Occupation',
|
||||
'name': occupationName,
|
||||
'skills': ""
|
||||
'skills': []
|
||||
}
|
||||
updateActor = True
|
||||
|
||||
|
|
23
skills.py
23
skills.py
|
@ -17,23 +17,24 @@ from utils import getDomainFromActor
|
|||
from utils import loadJson
|
||||
|
||||
|
||||
def setSkillsFromDict(actorJson: {}, skillsDict: {}) -> str:
|
||||
def setSkillsFromDict(actorJson: {}, skillsDict: {}) -> []:
|
||||
"""Converts a dict containing skills to a string
|
||||
Returns the string version of the dictionary
|
||||
"""
|
||||
skillsStr = ''
|
||||
skillsList = []
|
||||
for name, value in skillsDict.items():
|
||||
if skillsStr:
|
||||
skillsStr += ', '
|
||||
skillsStr += name + ':' + str(value)
|
||||
actorJson['hasOccupation']['skills'] = skillsStr
|
||||
return skillsStr
|
||||
skillsList.append(name + ':' + str(value))
|
||||
actorJson['hasOccupation']['skills'] = skillsList
|
||||
return skillsList
|
||||
|
||||
|
||||
def getSkillsFromString(skillsStr: str) -> {}:
|
||||
"""Returns a dict of skills from a string
|
||||
"""
|
||||
skillsList = skillsStr.split(',')
|
||||
if isinstance(skillsStr, list):
|
||||
skillsList = skillsStr
|
||||
else:
|
||||
skillsList = skillsStr.split(',')
|
||||
skillsDict = {}
|
||||
for skill in skillsList:
|
||||
if ':' not in skill:
|
||||
|
@ -73,7 +74,11 @@ def noOfActorSkills(actorJson: {}) -> int:
|
|||
"""Returns the number of skills that an actor has
|
||||
"""
|
||||
if actorJson.get('hasOccupation'):
|
||||
skillsList = actorJson['hasOccupation']['skills'].split(',')
|
||||
skillsStr = actorJson['hasOccupation']['skills']
|
||||
if isinstance(skillsStr, list):
|
||||
skillsList = skillsStr
|
||||
else:
|
||||
skillsList = skillsStr.split(',')
|
||||
if skillsList:
|
||||
return len(skillsList)
|
||||
return 0
|
||||
|
|
2
tests.py
2
tests.py
|
@ -3664,7 +3664,7 @@ def testSkills() -> None:
|
|||
'hasOccupation': {
|
||||
'@type': 'Occupation',
|
||||
'name': "",
|
||||
'skills': ""
|
||||
'skills': []
|
||||
}
|
||||
}
|
||||
skillsDict = {
|
||||
|
|
|
@ -420,8 +420,8 @@ def htmlSkillsSearch(actor: str,
|
|||
actorJson.get('name') and \
|
||||
actorJson.get('icon'):
|
||||
actor = actorJson['id']
|
||||
actorSkillsStr = actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsStr)
|
||||
actorSkillsList = actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsList)
|
||||
for skillName, skillLevel in skills.items():
|
||||
skillName = skillName.lower()
|
||||
if not (skillName in skillsearch or
|
||||
|
@ -461,9 +461,9 @@ def htmlSkillsSearch(actor: str,
|
|||
actorJson.get('name') and \
|
||||
actorJson.get('icon'):
|
||||
actor = actorJson['id']
|
||||
actorSkillsStr = \
|
||||
actorSkillsList = \
|
||||
actorJson['hasOccupation']['skills']
|
||||
skills = getSkillsFromString(actorSkillsStr)
|
||||
skills = getSkillsFromString(actorSkillsList)
|
||||
for skillName, skillLevel in skills.items():
|
||||
skillName = skillName.lower()
|
||||
if not (skillName in skillsearch or
|
||||
|
|
|
@ -721,7 +721,7 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
|||
|
||||
skillsMarkup = ''
|
||||
if actorJson.get('hasOccupation'):
|
||||
skillsStr = actorJson['hasOccupation']['skills']
|
||||
skillsList = actorJson['hasOccupation']['skills']
|
||||
if actorJson['hasOccupation'].get('name'):
|
||||
occupationName = actorJson['hasOccupation']['name']
|
||||
occupationStr = ' "name": "' + occupationName + '",\n'
|
||||
|
@ -729,7 +729,7 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
|
|||
' "hasOccupation": {\n' + \
|
||||
' "@type": "Occupation",\n' + \
|
||||
occupationStr + \
|
||||
' "skills": "' + skillsStr + '"\n' + \
|
||||
' "skills": ' + str(skillsList) + '\n' + \
|
||||
' "},\n'
|
||||
|
||||
personMarkup = \
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"email": "bob@freedombone.net",
|
||||
"url": "https://epicyon.freedombone.net/users/bob"
|
||||
},
|
||||
"applicationCategory" : "server, software, fediverse, activitypub, self-hosting",
|
||||
"applicationCategory" : ["server", "software", "bash", "debian", "linux", "self-hosting"],
|
||||
"downloadUrl" : "https://epicyon.net/epicyon.tar.gz"
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue