Coverage for cli.py: 47%

34 statements  

« prev     ^ index     » next       coverage.py v7.7.0, created at 2025-03-20 20:51 +0100

1from pathlib import Path 

2 

3import click 

4 

5from nastranio.readers.gmsh.study import Study 

6 

7 

8@click.command() 

9@click.argument("meshfile", type=click.Path(exists=True)) 

10@click.argument("params", type=click.Path(exists=True)) 

11@click.option("--overwrite/--no-overwrite", default=False) 

12def study(meshfile, params, overwrite): 

13 study = Study(meshfile, autobuild=False) 

14 study.load_user_params(params) 

15 study.build() 

16 study.run(exist_ok=overwrite) 

17 

18 

19@click.group() 

20@click.pass_context 

21def main(ctx): 

22 ctx.ensure_object(dict) 

23 

24 

25@main.command() 

26@click.argument("meshfile", type=click.Path(exists=True)) 

27@click.option("-p", "params", type=click.Path(exists=True), default=None) 

28@click.option("-o", "output", type=click.Path(exists=False), default=None) 

29def msh2nas(meshfile, params, output): 

30 meshfile = Path(meshfile) 

31 study = Study(meshfile, autobuild=False) 

32 if params is not None: 

33 params = Path(params) 

34 study.load_user_params(params) 

35 study.build() 

36 if output is not None: 

37 output = Path(output) 

38 if output.suffix in (".nas", ".dat", ".bulk"): 

39 study.to_nastran(target=output) 

40 elif output.suffix in (".msh", ".mesh"): 

41 study.reg.mesh.to_gmsh(filename=output) 

42 study.run()