def get_sections(r): path = os.path.join(r.args["path"], "sequence.txt") logger.info("Load from %s", path) try: with open(path, "r") as f: sections = madmagia.sequence.parse([unicode(ln, "utf-8") for ln in f.readlines()], False)[0] return [_dump_section(s) for s in sections] except madmagia.sequence.ParseError, e: logger.exception(e) logger.error("Error at line %d", e.linenum)
def save_sequences(r): path = os.path.join(r.form["path"], "sequence.txt") logger.info("Save to %s", path) with open(path, "w") as f: [_write_section(f, s) for s in json.loads(r.form["sections"])]