示例#1
0
def main(*, jobs: int = 1) -> None:
    basedir = pathlib.Path.cwd()
    config = load_render_config(basedir=basedir)
    logger.info('load verification status...')
    marker = onlinejudge_verify.marker.get_verification_marker(jobs=jobs)

    # configure
    logger.info('collect source code statistics...')
    source_code_stats = configure.generate_source_code_stats(basedir=basedir, marker=marker)
    logger.info('list markdown files...')
    markdown_paths = configure.find_markdown_paths(basedir=basedir)
    logger.info('list rendering jobs...')
    excluded_paths = list(map(pathlib.Path, config.config_yml.get('exclude', [])))
    source_code_stats = configure.apply_exclude_list_to_stats(excluded_paths=excluded_paths, source_code_stats=source_code_stats)
    markdown_paths = configure.apply_exclude_list_to_paths(markdown_paths, excluded_paths=excluded_paths)
    render_jobs = configure.convert_to_page_render_jobs(source_code_stats=source_code_stats, markdown_paths=markdown_paths, site_render_config=config)

    # make build
    logger.info('render %s files...', len(render_jobs))
    rendered_pages = build.render_pages(page_render_jobs=render_jobs, source_code_stats=source_code_stats, site_render_config=config)
    logger.info('list static files...')
    static_files = build.load_static_files(site_render_config=config)

    # make install
    logger.info('writing %s files...', len(rendered_pages))
    for path, content in rendered_pages.items():
        path.parent.mkdir(parents=True, exist_ok=True)
        with open(path, 'wb') as fh:
            fh.write(content)
    logger.info('writing %s static files...', len(static_files))
    for path, content in static_files.items():
        path.parent.mkdir(parents=True, exist_ok=True)
        with open(path, 'wb') as fh:
            fh.write(content)
示例#2
0
def print_stats_json(*, jobs: int = 1) -> None:
    basedir = pathlib.Path.cwd()
    logger.info('load verification status...')
    marker = onlinejudge_verify.marker.get_verification_marker(jobs=jobs)

    logger.info('collect source code statistics...')
    source_code_stats = configure.generate_source_code_stats(basedir=basedir, marker=marker)
    logger.info('dump to json...')
    data = build.render_source_code_stats(source_code_stats=source_code_stats, basedir=basedir)
    print(json.dumps(data))