def main(argv): magic_item_name = raw_input("Magic item name: ") filename = "../magic-item-templates/" + magic_item_name + ".json" fileExists = os.path.isfile(filename) override = False if fileExists is True: override = raw_input("Magic item " + magic_item_name + " exists. Override? (y/n): ") if not utils.validYes(override): return file = open(filename, "w") #... magicItemTypes = getType() magicItem = { "NAME": magic_item_name, "TYPE": magicItemTypes['magic_item_type'], "SUBTYPES_INCLUDED": magicItemTypes['magic_item_subtypes_included'], "SUBTYPES_EXCLUDED": magicItemTypes['magic_item_subtypes_excluded'], "RARITY": getRarity(), "ATTUNEMENT": getAttunement(), "DESCRIPTION": getDescription() } #json.dump(magicItem, file, sort_keys=True, inde) utils.jsonToFile(magicItem, file)
def main(argv): creature_name = raw_input("Creature Name: ") filename = "../monster-data-dev/monster-templates/" + creature_name + "-template.json" fileExists = os.path.isfile(filename) override = False if fileExists is True: override = raw_input("Template for " + creature_name + " exists. Override? (y/n): ") if not utils.validYes(override): return file = open(filename, "w") content = { "NAME" : creature_name, "MONSTER_TYPE": getMonsterType(), "SIZE": getSize(), "RACE": getRace(), "ALIGNMENT": getAlignment(), "HIT DICE" : rollHealth(), "ARMOR" : getArmor(), "SPEED" : getSpeed(), "SAVING_THROWS": getSavingThrows(), "SKILLS" : getSkills(), "STATS" : getStats(), "DAMAGE_VULNERABILITIES": getDamageVulnerabilities(), "DAMAGE_RESISTANCES": getDamageResistances(), "DAMAGE_IMMUNITIES": getDamageImmunities(), "CONDITION_IMMUNITIES": getConditionImmunities(), "SENSES": getSenses(), "LANGUAGES": getLanguages(), "CHALLENGE_XP": getChallenge(), "PASSIVES": getPassives(), "ACTIONS": getActions(), "LEGENDARY": getLegendary(), "REACTIONS": getReactions() } #json.dump(content, file, sort_keys=True, indent=4, separators=(',', ': ')) utils.jsonToFile(content, file)
#TODO: #name comflicts between users? status, message = "bad", "The project name '%s' is already taken" % project_name print status, message else: os.mkdir(project_dir) os.mkdir("%s/%s" % (project_dir, GlobalConfig.SYMLNK_GENOMES)) #setup directory for uploaded tables os.mkdir(src_table_dir) #TODO #add the new project:assembly mapping to file pamfile = "../lib/project_assembly_mapping.json" jsn = utils.fileToJson(pamfile) jsn[project_name] = assembly utils.jsonToFile(jsn, pamfile) print "altered pamfile" #fmap = open... #lines = fmap.readlines() #lines[-1] = "%s : %s" % (project_name,assembly) #lines.append('}') #fmap.close() #add permissions perm_file = "../lib/permissions.json" jperms = utils.fileToJson(perm_file) jperms[user_name][project_name] = True utils.jsonToFile(jperms, perm_file) print "altered perms"
print fields if is_registering == 'true': #add permissions passwd_file = "../lib/passwds.json" perm_file = "../lib/permissions.json" jperms = utils.fileToJson(perm_file) jpasswds = utils.fileToJson(passwd_file) if user_name in jpasswds: status, message = "bad", "A user by the name '%s' already exists" % user_name else: m = hashlib.md5() m.update(passwd) jpasswds[user_name] = m.hexdigest() utils.jsonToFile(jpasswds, passwd_file) jperms[user_name] = {} utils.jsonToFile(jperms, perm_file) #user dir in DONOR_DIR os.mkdir("%s/%s" % (GlobalConfig.DONOR_DIR, user_name)) #user dir in uploader os.mkdir("/home/uploader/%s" % user_name) else: bad_combo = "Bad user/pass combo" print "logging in..." jpasswds = utils.fileToJson("../lib/passwds.json") if user_name in jpasswds:
#TODO: #name comflicts between users? status,message = "bad","The project name '%s' is already taken" % project_name print status,message else : os.mkdir( project_dir ) os.mkdir( "%s/%s" % (project_dir, GlobalConfig.SYMLNK_GENOMES) ) #setup directory for uploaded tables os.mkdir( src_table_dir ) #TODO #add the new project:assembly mapping to file pamfile = "../lib/project_assembly_mapping.json" jsn = utils.fileToJson(pamfile) jsn[project_name] = assembly utils.jsonToFile(jsn,pamfile) print "altered pamfile" #fmap = open... #lines = fmap.readlines() #lines[-1] = "%s : %s" % (project_name,assembly) #lines.append('}') #fmap.close() #add permissions perm_file = "../lib/permissions.json" jperms = utils.fileToJson( perm_file ) jperms[user_name][project_name] = True utils.jsonToFile( jperms, perm_file ) print "altered perms"
print fields if is_registering == 'true' : #add permissions passwd_file = "../lib/passwds.json" perm_file = "../lib/permissions.json" jperms = utils.fileToJson( perm_file ) jpasswds = utils.fileToJson( passwd_file ) if user_name in jpasswds : status,message = "bad","A user by the name '%s' already exists" % user_name else : m = hashlib.md5() m.update(passwd) jpasswds[user_name] = m.hexdigest() utils.jsonToFile( jpasswds, passwd_file ) jperms[user_name] = {} utils.jsonToFile( jperms, perm_file ) #user dir in DONOR_DIR os.mkdir( "%s/%s" % (GlobalConfig.DONOR_DIR, user_name) ) #user dir in uploader os.mkdir( "/home/uploader/%s" % user_name) else : bad_combo = "Bad user/pass combo" print "logging in..." jpasswds = utils.fileToJson( "../lib/passwds.json" ) if user_name in jpasswds :