コード例 #1
0
ファイル: pcommand.py プロジェクト: imayushsaini/ballistica
def gen_python_init_module() -> None:
    """Generate a basic __init__.py."""
    import os
    from efro.terminal import Clr
    from batools.project import project_centric_path
    if len(sys.argv) != 3:
        raise Exception('Expected an outfile arg.')
    outfilename = sys.argv[2]
    os.makedirs(os.path.dirname(outfilename), exist_ok=True)
    prettypath = project_centric_path(projroot=str(PROJROOT), path=outfilename)
    print(f'Meta-building {Clr.BLD}{prettypath}{Clr.RST}')
    with open(outfilename, 'w', encoding='utf-8') as outfile:
        outfile.write('# Released under the MIT License.'
                      ' See LICENSE for details.\n'
                      '#\n')
コード例 #2
0
def generate(projroot: str, infilename: str, outfilename: str) -> None:
    """Main script entry point."""
    from batools.project import project_centric_path

    out = (get_public_license('python') +
           f'\n"""Enum vals generated by {__name__}; do not edit by hand."""'
           f'\n\nfrom enum import Enum\n')

    out += _gen_enums(infilename)

    path = project_centric_path(projroot=projroot, path=outfilename)
    print(f'Meta-building {Clr.BLD}{path}{Clr.RST}')
    os.makedirs(os.path.dirname(outfilename), exist_ok=True)
    with open(outfilename, 'w', encoding='utf-8') as outfile:
        outfile.write(out)