Пример #1
0
def test_round_trip(make_db, tmpdir):
    repo = make_db
    os.chdir(repo)
    subprocess.check_call(["touch", "myfile.tex"], cwd=tmpdir)
    db = load_db()
    db.add_file(db["projects"]["Cyclus"], "myfile", os.path.join(tmpdir, "myfile.tex"))
    ret = db.get_file_path(db["projects"]["Cyclus"], "myfile")
    assert ret == os.path.join(repo, "myfile.tex")
Пример #2
0
def prep_figure():
    # Make latex file with some jinja2 in it
    text = r"""
    \include{ {{-get_file_path(db['groups']['ergs'], 'hello')-}}}"""
    with open("figure.tex", "w") as f:
        f.write(text)
    # make file to be loaded
    os.makedirs("fig", exist_ok=True)
    with open("fig/hello.txt", "w") as f:
        f.write("hello world")
    # load the db and register the file
    db = load_db()
    print(db.get_file_path(db["groups"]["ergs"], "hello"))
    if not db.get_file_path(db["groups"]["ergs"], "hello"):
        db.add_file(db["groups"]["ergs"], "hello", "fig/hello.txt")