from invoke import task from pathlib import Path ROOT = Path(__file__).parent PB_ROOT = ROOT / "pb" # @task # def clean(c, docs=False, bytecode=False, extra=""): # patterns = ["build"] # if docs: # patterns.append("docs/_build") # if bytecode: # patterns.append("**/*.pyc") # if extra: # patterns.append(extra) # for pattern in patterns: # c.run("rm -rf {}".format(pattern)) @task( help={ "target": "Target gRPC licent code to generate.", } ) def gen(c, target="types"): """ Generate gRPC client code. """ outDir = "gen/types" paths = Path(PB_ROOT).glob('**/*.proto') for path in paths: # because path is object not string pathStr = str(path) print("Generating f or", pathStr) c.run( "npx proto-loader-gen-types --includeComments --grpcLib @grpc/grpc-js -I pb -O {} {}" .format(outDir, pathStr) )