Skip to content

Commit

Permalink
Handle unspecified metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrost-mo committed Nov 21, 2023
1 parent f4211b4 commit 1879890
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/CSET/operators/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
def _make_plot_html_page(plot_filename: str) -> None:
"""Create a HTML page to display a plot image."""
meta = get_recipe_metadata()
title = meta["title"]
description = MarkdownIt().render(meta["description"])
title = meta.get("title", "Untitled")
description = MarkdownIt().render(meta.get("description", ""))

# Template stylesheet so we don't have to escape the {}.
stylesheet = """body {
Expand Down Expand Up @@ -148,7 +148,7 @@ def spatial_contour_plot(
If cube isn't a Cube.
"""
if not filename:
filename = slugify(get_recipe_metadata()["title"])
filename = slugify(get_recipe_metadata().get("title", "Untitled"))
filename = Path(filename).with_suffix(".svg")
cube = _check_single_cube(cube)
qplt.contourf(cube)
Expand Down Expand Up @@ -188,7 +188,7 @@ def postage_stamp_contour_plot(
If cube isn't a Cube.
"""
if not filename:
filename = slugify(get_recipe_metadata()["title"])
filename = slugify(get_recipe_metadata().get("title", "Untitled"))
filename = Path(filename).with_suffix(".svg")

# Validate input is in the right form.
Expand Down Expand Up @@ -247,5 +247,5 @@ def time_series_contour_plot(
If cube isn't a Cube.
"""
if not filename:
filename = slugify(get_recipe_metadata()["title"])
filename = slugify(get_recipe_metadata().get("title", "Untitled"))
raise NotImplementedError
2 changes: 1 addition & 1 deletion src/CSET/operators/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def write_cube_to_nc(
The inputted cube(list) (so further operations can be applied)
"""
if not filename:
filename = slugify(get_recipe_metadata()["title"])
filename = slugify(get_recipe_metadata().get("title", "Untitled"))
# Ensure that output filename is a Path with a .nc suffix
filename = Path(filename).with_suffix(".nc")
# Save the file as nc compliant (iris should handle this)
Expand Down

0 comments on commit 1879890

Please sign in to comment.