Skip to content
Snippets Groups Projects
Select Git revision
  • 4ce5f27bddbd8d765d62dcbc1f6d846019a87c45
  • master default protected
2 results

main.py

Blame
  • main.py 1.53 KiB
    #!/usr/bin/env python3
    import os, sys
    import shutil
    import argparse
    import pathlib
    
    import jk_web.main
    import tempfile
    
    from . import formatitko_commands as fc
    formatitko_commands = {k:v for k, v in fc.formatitko_commands.items()}
    
    formatitko_commands["head"] = lambda element, context, processor: []
    formatitko_commands["tail"] = lambda element, context, processor: []
    formatitko_commands["table_of_contents"] = lambda element, context, processor: []
    
    d = pathlib.Path("/".join(__file__.split("/")[:-1]))
    
    web = jk_web.main.web
    copy_file = web.copy_file
    Page = web.Page
    relative_link = web.relative_link
    S = web.S
    timer = web.timer
    
    
    base_page = jk_web.main.base_page
    
    
    
    
    with web.Module("bakalarka") as module_bakalarka, web.ctx.add_out_path_prefix("bakalarka/"):
        bakalarka_pdf = web.ctx.out_path_prefix + "bakalarka.pdf"
        web_index = web.Mpage(d,
                              "index",
                              bibliography=d/"sample.bib",
                              page_builder=base_page,
                              source_code_module=(lambda: ...).__module__,
                              commands=formatitko_commands,
                              custom_pdf=bakalarka_pdf,
                              )
        web_index.higher_page = jk_web.main.web_projects
    
        @web.add_job(web.PRIORITY_WRITE)
        def gen_bakalarka_pdf():
            tmpdirname = tempfile.mkdtemp(dir=web.build_dir)
            from .bakalarka import main
            main(pathlib.Path(tmpdirname), False)
            print(web.copy_file(None, bakalarka_pdf, tmpdirname+"/bakalarka.pdf", add_out_path_prefix=False))