def parse_arg_uncommon_race(filename, output, book): struct = parse_universal(filename, output, book) struct = stat_block_pass(struct, book) struct = quote_pass(struct) struct = entity_pass(struct) struct = arg_restructure(struct, book) race = arg_race_pass(struct, 'uncommon_race') write_race(output, book, race)
def parse_races(filename, output, book): struct = parse_universal(filename, output, book) #struct = entity_pass(struct) for race in struct['sections']: race_pass(race) racial_trait_pass(race) for race in struct['sections']: write_race(output, book, race)
def parse_skills(filename, output, book): skill = parse_universal(filename, output, book) # skill = entity_pass(skill) skill_pass(skill) print "%s: %s" % (skill["source"], skill["name"]) filename = create_skill_filename(output, book, skill) fp = open(filename, "w") json.dump(skill, fp, indent=4) fp.close()
def parse_races(filename, output, book): struct = parse_universal(filename, output, book) struct = stat_block_pass(struct, book) struct = quote_pass(struct) struct = entity_pass(struct) for race in struct['sections']: race_pass(race) racial_trait_pass(race) for race in struct['sections']: write_race(output, book, race)
def parse_skills(filename, output, book): skill = parse_universal(filename, output, book) skill = quote_pass(skill) skill = entity_pass(skill) skill_pass(skill) print "%s: %s" %(skill['source'], skill['name']) filename = create_skill_filename(output, book, skill) fp = open(filename, 'w') json.dump(skill, fp, indent=4) fp.close()
def parse_rules(filename, output, book, title): basename = os.path.basename(filename) rules = parse_universal(filename, output, book) rules = stat_block_pass(rules, book) rules = structure_pass(rules, basename, book) if not basename in ['glossary.html']: rules = ability_pass(rules) rules = title_pass(rules, book, title) if not basename in ['ranger.html', 'universalMonsterRules.html', 'buildingAndModifyingConstructs.html', 'spellbooks.html']: rules = abbrev_pass(rules) print_struct(rules) print "%s: %s" %(rules['source'], rules['name']) write_rules(output, rules, book, title)
def parse_spell_lists(filename, output, book): struct = parse_universal(filename, output, book) #entity_pass(struct) rules, spell_lists = spell_list_structure_pass(struct, os.path.basename(filename)) spell_lists = spell_list_name_pass(spell_lists) for spell_list in spell_lists: sl = spell_pass(spell_list) print "%s: %s" %(sl['source'], sl['name']) filename = create_spell_list_filename(output, book, sl) fp = open(filename, 'w') json.dump(sl, fp, indent=4) fp.close() if rules: write_rules(output, rules, book, "spell_lists")
def exec_main(parser): (options, args) = parser.parse_args() title = False if hasattr(options, 'title'): title = True if not options.output: sys.stderr.write("-o/--output required") sys.exit(1) if not os.path.exists(options.output): sys.stderr.write("-o/--output points to a directory that does not exist") sys.exit(1) if not os.path.isdir(options.output): sys.stderr.write("-o/--output points to a file, it must point to a directory") sys.exit(1) if not options.book: sys.stderr.write("-b/--book required") sys.exit(1) for arg in args: if title: parse_universal(arg, options.output, options.book, options.title) else: parse_universal(arg, options.output, options.book)
def parse_spell_lists(filename, output, book): struct = parse_universal(filename, output, book) struct = quote_pass(struct) struct = entity_pass(struct) rules, spell_lists = spell_list_structure_pass(struct, os.path.basename(filename)) spell_lists = spell_list_name_pass(spell_lists) for spell_list in spell_lists: sl = spell_pass(spell_list) print "%s: %s" %(sl['source'], sl['name']) filename = create_spell_list_filename(output, book, sl) fp = open(filename, 'w') json.dump(sl, fp, indent=4) fp.close() if rules: write_rules(output, rules, book, "spell_lists")
def parse_rules(filename, output, book, title, no_sb=False): basename = os.path.basename(filename) rules = parse_universal(filename, output, book) if basename in ["druid.html"]: rules = ultimate_magic_structure_pass(rules, basename, book) rules = stat_block_pass(rules, book, no_sb=no_sb) rules = structure_pass(rules, basename, book) if not basename in ['glossary.html']: rules = ability_pass(rules) rules = title_pass(rules, book, title) rules = quote_pass(rules) rules = entity_pass(rules) if not basename in ['ranger.html', 'universalMonsterRules.html', 'buildingAndModifyingConstructs.html', 'spellbooks.html', 'rings.html', 'massCombat.html']: rules = abbrev_pass(rules) print_struct(rules) print "%s: %s" %(rules['source'], rules['name']) write_rules(output, rules, book, title)
def parse_rules(filename, output, book, title, no_sb=False): basename = os.path.basename(filename) rules = parse_universal(filename, output, book) rules = stat_block_pass(rules, book, no_sb=no_sb) rules = structure_pass(rules, basename, book) if not basename in ['glossary.html']: rules = ability_pass(rules) rules = title_pass(rules, book, title) rules = quote_pass(rules) rules = entity_pass(rules) if not basename in [ 'ranger.html', 'universalMonsterRules.html', 'buildingAndModifyingConstructs.html', 'spellbooks.html' ]: rules = abbrev_pass(rules) print_struct(rules) print "%s: %s" % (rules['source'], rules['name']) write_rules(output, rules, book, title)
def parse_creature(filename, output, book): basename = os.path.basename(filename) struct = parse_universal(filename, output, book, max_title=4) struct = stat_block_pass(struct, book) struct = animal_companion_pass(struct) struct = rule_pass(struct) struct = ability_pass(struct) struct = familiar_pass(struct, basename) struct = monster_race_pass(struct) struct = collapse_pass(struct) currrules = [] if struct['type'] == 'section': struct['name'] = struct['sections'][0]['name'] struct['name'] = struct['name'].split(",")[0] write_creature(output, book, struct) elif struct['type'] == 'creature': write_creature(output, book, struct) else: raise Exception("Uh Oh")
def parse_spell(filename, output, book): struct = parse_universal(filename, output, book, max_title=4) struct = stat_block_pass(struct, book) struct = heading_pass(struct) #struct = entity_pass(struct) struct = ability_pass(struct) if struct['type'] == 'section': if struct.has_key('name'): write_rules(output, struct, book, struct['name']) else: parent_pass_in_file(struct) for spell in struct['sections']: misc_fix_pass(spell) cap_pass(spell) write_spell(output, book, spell) else: parent_pass_out_of_file(struct) misc_fix_pass(struct) cap_pass(struct) write_spell(output, book, struct)
def parse_feats(filename, output, book): struct = parse_universal(filename, output, book) #struct = entity_pass(struct) rules, feats = adjust_feat_structure_pass(struct, os.path.basename(filename)) for feat in feats: feat_pass(feat) ability_pass(feat) section_naming_pass(feat) if rules['name'] == 'Monster Feats': monster_feat_pass(feat) for feat in feats: print "%s: %s" %(feat['source'], feat['name']) filename = create_feat_filename(output, book, feat) fp = open(filename, 'w') json.dump(feat, fp, indent=4) fp.close() if rules: write_rules(output, rules, book, "feats")
def parse_spell(filename, output, book): struct = parse_universal(filename, output, book, max_title=4) struct = stat_block_pass(struct, book) struct = heading_pass(struct) struct = quote_pass(struct) struct = entity_pass(struct) struct = ability_pass(struct) if struct['type'] == 'section': if struct.has_key('name'): write_rules(output, struct, book, struct['name']) else: parent_pass_in_file(struct) for spell in struct['sections']: misc_fix_pass(spell) cap_pass(spell) write_spell(output, book, spell) else: parent_pass_out_of_file(struct) misc_fix_pass(struct) cap_pass(struct) write_spell(output, book, struct)
def parse_feats(filename, output, book): struct = parse_universal(filename, output, book) struct = quote_pass(struct) struct = entity_pass(struct) rules, feats = adjust_feat_structure_pass(struct, os.path.basename(filename)) for feat in feats: feat_pass(feat) ability_pass(feat) section_naming_pass(feat) prerequisite_pass(feat) if rules["name"] == "Monster Feats": monster_feat_pass(feat) for feat in feats: print "%s: %s" % (feat["source"], feat["name"]) filename = create_feat_filename(output, book, feat) fp = open(filename, "w") json.dump(feat, fp, indent=4) fp.close() if rules: write_rules(output, rules, book, "feats")
def parse_creature(filename, output, book): basename = os.path.basename(filename) struct = parse_universal(filename, output, book, max_title=4) struct = stat_block_pass(struct, book) struct = animal_companion_pass(struct) struct = rule_pass(struct) struct = ability_pass(struct) struct = familiar_pass(struct, basename) struct = monster_race_pass(struct) struct = collapse_pass(struct) struct = quote_pass(struct) struct = entity_pass(struct) currrules = [] if struct['type'] == 'section': if not struct.has_key('name'): struct['name'] = struct['sections'][0]['name'] struct['name'] = struct['name'].split(",")[0] write_creature(output, book, struct) elif struct['type'] == 'creature': write_creature(output, book, struct) else: raise Exception("Uh Oh")
def parse_feats(filename, output, book): struct = parse_universal(filename, output, book) struct = quote_pass(struct) struct = entity_pass(struct) rules, feats = adjust_feat_structure_pass(struct, os.path.basename(filename)) for feat in feats: feat_pass(feat) ability_pass(feat) section_naming_pass(feat) if rules['name'] == 'Monster Feats': monster_feat_pass(feat) for feat in feats: print "%s: %s" % (feat['source'], feat['name']) filename = create_feat_filename(output, book, feat) fp = open(filename, 'w') json.dump(feat, fp, indent=4) fp.close() if rules: write_rules(output, rules, book, "feats")
def first_pass(filename, output, book): struct = parse_universal(filename, output, book) return struct