"""Extraction unique : kanban.html -> DOCS/kanban/ + kanban-template.html.
Une carte = un fichier, un « fait recemment » = un fichier. Ensuite kanban.html
est regenere par build_kanban.py et ne s'edite plus a la main.
"""
import io
import json
import os
import re
import unicodedata
DOCS = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SRC = os.path.join(DOCS, "kanban.html")
KANBAN = os.path.join(DOCS, "kanban")
CARDS_DIR = os.path.join(KANBAN, "cards")
DONE_DIR = os.path.join(KANBAN, "done")
BOARD_OUT = os.path.join(KANBAN, "board.json")
TPL_OUT = os.path.join(DOCS, "kanban-template.html")
def write(path, text):
io.open(path, "w", encoding="utf-8", newline="\n").write(text)
def slug(text, maxlen=45):
text = re.sub(r"<[^>]+>", "", text)
text = unicodedata.normalize("NFKD", text).encode("ascii", "ignore").decode()
text = re.sub(r"[^a-zA-Z0-9]+", "-", text).strip("-").lower()
return text[:maxlen].rstrip("-") or "sans-titre"
html = io.open(SRC, encoding="utf-8", newline="").read()
masthead = re.search(r'
(.*?)
", masthead, re.S)] stamp = re.search(r'%s
" % p.strip() for p in re.findall(r"(.*?)
", inner, re.S)) write( os.path.join(CARDS_DIR, dirname, "%03d-%s.md" % (rank * 10, slug(card_title))), "---\n" + "\n".join(front) + "\n---\n" + body + "\n", ) n_cards += 1 columns.append( {"dir": dirname, "title": title, "stripe": stripe, "statClass": stat_class.get(title, ""), "comment": comment} ) done_section = html[done_start : html.index("(.*?)
", done_section, re.S).group(1).strip(), }, } write(BOARD_OUT, json.dumps(board_meta, ensure_ascii=False, indent=2) + "\n") template = ( html[: html.index('