Build an (static) app with a directory structure, which can be served by a local http server !!! note This outputs compressed assets into the dir as well, may be an issue if self-hosting Args: blocks: The `Blocks` object or a list of Blocks name: The name of the app
(
blocks: BlocksT,
name: str = "Report",
dest: t.Optional[NPath] = None,
formatting: t.Optional[Formatting] = None,
overwrite: bool = False,
)
| 31 | ################################################################################ |
| 32 | # exported public API |
| 33 | def build_report( |
| 34 | blocks: BlocksT, |
| 35 | name: str = "Report", |
| 36 | dest: t.Optional[NPath] = None, |
| 37 | formatting: t.Optional[Formatting] = None, |
| 38 | overwrite: bool = False, |
| 39 | ) -> None: |
| 40 | """Build an (static) app with a directory structure, which can be served by a local http server |
| 41 | |
| 42 | !!! note |
| 43 | This outputs compressed assets into the dir as well, may be an issue if self-hosting |
| 44 | |
| 45 | Args: |
| 46 | blocks: The `Blocks` object or a list of Blocks |
| 47 | name: The name of the app directory to be created |
| 48 | dest: File path to store the app directory |
| 49 | formatting: Sets the basic app styling |
| 50 | overwrite: Replace existing app with the same name and destination if already exists (default: False) |
| 51 | """ |
| 52 | # TODO(product) - unknown if we should keep this... |
| 53 | |
| 54 | # build the dest dir |
| 55 | app_dir: Path = Path(dest or os.getcwd()) / name |
| 56 | app_exists = app_dir.is_dir() |
| 57 | |
| 58 | if app_exists and overwrite: |
| 59 | rmtree(app_dir) |
| 60 | elif app_exists and not overwrite: |
| 61 | raise DPClientError(f"Report exists at given path {str(app_dir)} -- set `overwrite=True` to allow overwrite") |
| 62 | |
| 63 | assets_dir = app_dir / "assets" |
| 64 | assets_dir.mkdir(parents=True) |
| 65 | |
| 66 | # write the app html and assets |
| 67 | s = ViewState(blocks=Blocks.wrap_blocks(blocks), file_entry_klass=GzipTmpFileEntry, dir_path=assets_dir) |
| 68 | _: str = ( |
| 69 | Pipeline(s) |
| 70 | .pipe(PreProcessView(is_finalised=True)) |
| 71 | .pipe(ConvertXML()) |
| 72 | .pipe(ExportHTMLFileAssets(app_dir=app_dir, name=name, formatting=formatting)) |
| 73 | .result |
| 74 | ) |
| 75 | |
| 76 | |
| 77 | def save_report( |
nothing calls this directly
no test coverage detected