Ajout d'un script d'horodatage des fiches, affichage des fiches récement modifiées sur la page d'accueil
This commit is contained in:
@@ -5,7 +5,7 @@ import re
|
||||
import sys
|
||||
import tomllib
|
||||
import unicodedata
|
||||
from datetime import date
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -93,13 +93,22 @@ def require_string(
|
||||
validator.error(path, f"{key} doit être une chaîne non vide")
|
||||
|
||||
|
||||
def require_date(
|
||||
def require_timestamp(
|
||||
metadata: dict[str, Any],
|
||||
key: str,
|
||||
path: Path,
|
||||
validator: Validator,
|
||||
*,
|
||||
optional: bool = False,
|
||||
) -> None:
|
||||
if not isinstance(metadata.get("date"), date):
|
||||
validator.error(path, "date doit être une date TOML valide")
|
||||
value = metadata.get(key)
|
||||
if optional and value is None:
|
||||
return
|
||||
if not isinstance(value, datetime) or value.tzinfo is None or value.utcoffset() is None:
|
||||
validator.error(
|
||||
path,
|
||||
f"{key} doit être un horodatage TOML avec fuseau horaire",
|
||||
)
|
||||
|
||||
|
||||
def check_structure(
|
||||
@@ -130,7 +139,8 @@ def check_structure(
|
||||
|
||||
require_string(metadata, "title", path, validator)
|
||||
if section:
|
||||
require_date(metadata, path, validator)
|
||||
require_timestamp(metadata, "date", path, validator)
|
||||
require_timestamp(metadata, "updated", path, validator, optional=True)
|
||||
return section, False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user