Пример #1
0
def do_write(session: engine.Session, filename: str):
    """
    Writes a whole proof to a file with the provided name; if the file already exists program will append to it.

    Arguments:
        - filename [str]
    """
    proof = session.gettree()
    if os.path.exists(filename):
        with open(filename, 'ab') as f:
            f.write('\n---\n')
            f.writelines([(i + '\n').encode('utf-8') for i in proof])
        return f"Proof appended to {filename}"
    else:
        with open(filename, 'wb') as f:
            f.writelines([(i + '\n').encode('utf-8') for i in proof])
        return f"Proof saved as {filename}"
Пример #2
0
def do_get_tree(session: engine.Session) -> str:
    """Returns the proof in the form of a tree"""
    try:
        return "\n".join(session.gettree())
    except engine.EngineError as e:
        return str(e)