def construct_rule_path(output, book, section, path): full = "/".join([char_replace(p) for p in path]) typedir = os.path.abspath(output + "/" + char_replace(book) + "/" + full) if not os.path.exists(typedir): os.makedirs(typedir) typefile = typedir + "/" + char_replace(section["name"]) + ".json" if os.path.exists(typefile): sys.stderr.write("File %s already exists\n" % typefile) # raise Exception("File %s already exists" % typefile) return typefile
def construct_rule_path(output, book, section, path): full = "/".join([char_replace(p) for p in path]) typedir = os.path.abspath(output + "/" + char_replace(book) + "/" + full) if not os.path.exists(typedir): os.makedirs(typedir) typefile = typedir + "/" + char_replace(section['name']) + ".json" if os.path.exists(typefile): sys.stderr.write("File %s already exists\n" % typefile) #raise Exception("File %s already exists" % typefile) return typefile
def construct_type_path(output, book, section): typedir = os.path.abspath(output + "/" + char_replace(book) + "/" + char_replace(section["type"])) if section.has_key("subtype"): typedir += "/" + section["subtype"] if not os.path.exists(typedir): os.makedirs(typedir) typefile = typedir + "/" + char_replace(section["name"]) + ".json" if os.path.exists(typefile): sys.stderr.write("File %s already exists\n" % typefile) # raise Exception("File %s already exists" % typefile) return typefile
def construct_type_path(output, book, section): typedir = os.path.abspath(output + "/" + char_replace(book) + "/" + char_replace(section['type'])) if section.has_key('subtype'): typedir += "/" + section['subtype'] if not os.path.exists(typedir): os.makedirs(typedir) typefile = typedir + "/" + char_replace(section['name']) + ".json" if os.path.exists(typefile): sys.stderr.write("File %s already exists\n" % typefile) #raise Exception("File %s already exists" % typefile) return typefile
def create_skill_filename(output, book, skill): title = char_replace(book) + "/skills/" + char_replace(skill["name"]) return os.path.abspath(output + "/" + title + ".json")
def create_race_filename(output, book, race): title = char_replace(book) + "/races/" + char_replace(race['name']) return os.path.abspath(output + "/" + title + ".json")
def create_spell_list_filename(output, book, spell_list): title = char_replace(book) + "/spell_lists/" + char_replace(spell_list['class']) + "-" + unicode(spell_list['level']) return os.path.abspath(output + "/" + title + ".json")
def create_class_filename(output, book, cl): title = char_replace(book) + "/classes/" + char_replace(cl['name']) return os.path.abspath(output + "/" + title + ".json")
def create_feat_filename(output, book, feat): title = char_replace(book) + "/feats/" + char_replace(feat['name']) return os.path.abspath(output + "/" + title + ".json")
def create_creature_filename(output, book, creature): title = char_replace(book) + "/creatures/" + char_replace(creature['name']) return os.path.abspath(output + "/" + title + ".json")
def create_spell_filename(output, book, spell): title = char_replace(book) + "/spells/" + char_replace(spell['name']) return os.path.abspath(output + "/" + title + ".json")
def create_rules_filename(output, book, filename): title = char_replace(book) + "/rules/" + char_replace(filename) return os.path.abspath(output + "/" + title + ".json")
def generate_extension_output_file_name(output_dir, book, fn): return os.path.join( os.path.abspath(output_dir), char_replace(book), 'extensions', fn)
def generate_extension_file_name(output_dir, book): return os.path.join(os.path.abspath(output_dir), char_replace(book), 'extension.json')