Skip to content
Snippets Groups Projects

Resolve "front-matter linter"

Merged Remi PLANEL requested to merge front-matter-linter into main
@@ -7,7 +7,10 @@ from pydantic_yaml import parse_yaml_raw_as, to_yaml_str
import frontmatter
from enum import Enum
from rich.console import Console
from rich.pretty import pprint
from rich import print as rprint
from rich.layout import Layout
from rich.panel import Panel
console = Console()
app = typer.Typer()
@@ -53,7 +56,8 @@ def lint(
),
],
):
print(f"check system {file}")
console.rule(f"[bold blue]{file.name}", style="blue")
with open(file) as f:
metadata, _ = frontmatter.parse(f.read())
# print(metadata)
@@ -65,7 +69,8 @@ def lint(
# print(exc.errors())
# pprint(exc.errors(), expand_all=True)
for err in exc.errors():
console.print(f"{err['msg']} : {err['type']} {','.join(err['loc'])}", style="red")
print("\n")
console.print(
f"[red]{err['msg']} : {err['type']} {' -> '.join(err['loc'])}"
)
else:
console.print("OK!\n", style="green")
console.print("[green] Everything is alright")