Commandline options for setting roles and skills

master
Bob Mottram 2019-07-14 14:07:54 +01:00
parent 21fbfa3b3b
commit 796f9d6ac5
2 changed files with 40 additions and 1 deletions

View File

@ -173,6 +173,14 @@ parser.add_argument("-c","--client", type=str2bool, nargs='?', \
help="Use as an ActivityPub client")
parser.add_argument('--maxreplies', dest='maxReplies', type=int,default=64, \
help='Maximum number of replies to a post')
parser.add_argument('--role', dest='role', type=str,default=None, \
help='Set a role for a person')
parser.add_argument('--organization','--project', dest='project', type=str,default=None, \
help='Set a project for a person')
parser.add_argument('--skill', dest='skill', type=str,default=None, \
help='Set a skill for a person')
parser.add_argument('--level', dest='skillLevelPercent', type=int,default=None, \
help='Set a skill level for a person as a percentage, or zero to remove')
args = parser.parse_args()
debug=False
@ -527,7 +535,35 @@ if args.backgroundImage:
else:
print('Background image was not added for '+args.nickname)
sys.exit()
if args.project:
if not nickname:
print('No nickname given')
sys.exit()
if args.role.lower()=='none' or \
args.role.lower()=='remove' or \
args.role.lower()=='delete':
args.role=None
if args.role:
if setRole(baseDir,nickname,domain,args.project,args.role):
print('Role within '+args.project+' set to '+args.role)
else:
if setRole(baseDir,nickname,domain,args.project,None):
print('Left '+args.project)
sys.exit()
if args.skill:
if args.skillLevelPercent==0:
args.skillLevelPercent=None
if args.skillLevelPercent:
if setSkillLevel(baseDir,nickname,domain,args.skill,args.skillLevelPercent):
print('Skill level for '+args.skill+' set to '+str(args.skillLevelPercent)+'%')
else:
if setSkillLevel(baseDir,nickname,domain,args.skill,args.skillLevelPercent):
print('Skill '+args.skill+' removed')
sys.exit()
if federationList:
print('Federating with: '+str(federationList))

View File

@ -11,6 +11,7 @@ import commentjson
import os
import fileinput
import subprocess
from pprint import pprint
from pathlib import Path
from Crypto.PublicKey import RSA
from shutil import copyfile
@ -97,6 +98,8 @@ def setSkillLevel(baseDir: str,nickname: str,domain: str, \
return False
with open(actorFilename, 'r') as fp:
actorJson=commentjson.load(fp)
if not actorJson.get('skills'):
actorJson['skills']={}
if skillLevelPercent>0:
actorJson['skills'][skill]=skillLevelPercent
else: