@@ -327,21 +327,6 @@ def _fig_to_webp_base64(fig) -> str:
327327 return base64 .b64encode (buffer .getvalue ()).decode ("ascii" )
328328
329329
330- def _load_empty_nf (catalog_path ) -> "npd.NestedFrame | None" :
331- """Reads the common metadata parquet file from a catalog directory and returns it as a nested pd"""
332- if (p := get_common_metadata_pointer (catalog_path )).exists ():
333- return read_parquet_file_to_pandas (p )
334- return None
335-
336-
337- def _load_template (jinja2_template : str | None , default_name : str ) -> jinja2 .Template :
338- """Loads a Jinja2 temlate and returns it ready to call .read(). Also allows custom Jinja2 templates."""
339- env = jinja2 .Environment (undefined = jinja2 .StrictUndefined )
340- if jinja2_template is None :
341- jinja2_template = importlib .resources .read_text (templates , default_name )
342- return env .from_string (jinja2_template )
343-
344-
345330def generate_summary (
346331 catalog ,
347332 * ,
@@ -361,20 +346,24 @@ def generate_summary(
361346 md_tmpl , html_tmpl = "index_md_template.jinja2" , "index_html_template.jinja2"
362347 else :
363348 md_tmpl , html_tmpl = "catalog_md_template.jinja2" , "catalog_html_template.jinja2"
349+ env = jinja2 .Environment (undefined = jinja2 .StrictUndefined )
364350 match fmt :
365351 case "markdown" :
366- template = _load_template ( jinja2_template , md_tmpl )
352+ tmpl_str = jinja2_template or importlib . resources . read_text ( templates , md_tmpl )
367353 case "html" :
368- template = _load_template ( jinja2_template , html_tmpl )
354+ tmpl_str = jinja2_template or importlib . resources . read_text ( templates , html_tmpl )
369355 case _:
370356 raise ValueError (f"Unsupported format: { fmt !r} . Expected 'markdown' or 'html'." )
357+ template = env .from_string (tmpl_str )
371358
372359 is_collection = isinstance (catalog , CatalogCollection )
373360 inner = catalog .main_catalog if is_collection else catalog
374361 cat_props = inner .catalog_info
375362 catalog_path = catalog .main_catalog_dir if is_collection else catalog .catalog_path
376363
377- empty_nf = _load_empty_nf (catalog_path )
364+ empty_nf = (
365+ read_parquet_file_to_pandas (p ) if (p := get_common_metadata_pointer (catalog_path )).exists () else None
366+ )
378367 column_table = _gen_column_table (inner , empty_nf )
379368 col_props = catalog .collection_properties if is_collection else None
380369 needs_sky = not isinstance (catalog , (MarginCatalog , IndexCatalog ))
0 commit comments