~charles/dotfiles

da3653b962f2edf572e07e7664a9fed84ebd5ae3 — Charles A. Daniels 1 year, 9 months ago 96b40f6
zettle: print paths with invalid frontmatter instead of crashing
1 files changed, 6 insertions(+), 1 deletions(-)

M modules/zettle/zettle.py
M modules/zettle/zettle.py => modules/zettle/zettle.py +6 -1
@@ 130,7 130,12 @@ def extract_frontmatter(path):
            if in_frontmatter:
                frontmatter_raw += line + "\n"

    frontmatter = yaml.safe_load(frontmatter_raw)
    frontmatter = None
    try:
        frontmatter = yaml.safe_load(frontmatter_raw)
    except Exception as e:
        sys.stderr.write("Failed to load frontmatter from path: '{}': {}\n".format(path, e))

    if frontmatter is None:
        frontmatter = {}
    return frontmatter