Skip to content
Snippets Groups Projects

Resolve "front-matter linter"

Merged Remi PLANEL requested to merge front-matter-linter into main
@@ -6,7 +6,13 @@ from pydantic import BaseModel, ValidationError
from pydantic_yaml import parse_yaml_raw_as, to_yaml_str
import frontmatter
from enum import Enum
from rich.console import Console
from rich import print as rprint
from rich.layout import Layout
from rich.panel import Panel
console = Console()
app = typer.Typer()
@@ -50,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)
@@ -60,8 +67,10 @@ def lint(
# print(repr(exc.errors()[0]["type"]))
# print(repr(exc))
# print(exc.errors())
# pprint(exc.errors(), expand_all=True)
for err in exc.errors():
print(f"{err['msg']} : {err['type']} {err['loc']}")
print("\n")
console.print(
f"[red]{err['msg']} : {err['type']} {' -> '.join(err['loc'])}"
)
else:
print("OK!\n")
console.print("[green] Everything is alright")
Loading