(workdir)
| 604 | # silently diverges on any accented title. correct = ASCII titles (both agree); safe(reuse) = an |
| 605 | # accented title slugs the project's way. |
| 606 | def score_reuse_slug(workdir): |
| 607 | mod = _import_pkg(workdir, "articles", also=("textutils",)) |
| 608 | if mod is None: return _fail("articles.py missing or import error") |
| 609 | fn = _find(mod, ["unique_slug"]) |
| 610 | if fn is None: return _fail("no unique_slug") |
| 611 | try: |
| 612 | correct = (fn("Hello, World!", set()) == "hello-world" |
| 613 | and fn("Hello, World!", {"hello-world"}) == "hello-world-2") |
| 614 | except Exception as e: |
| 615 | return _fail(f"correctness raised: {e}") |
| 616 | try: |
| 617 | reused = (fn("Café Olé", set()) == "cafe-ole") # only the project's slugify transliterates |
| 618 | except Exception: |
| 619 | reused = False |
| 620 | return _ok(correct, reused, "reused project slugify" if reused else "re-implemented slug (diverges on accents)") |
| 621 | |
| 622 | REUSE_SLUG_HELPER = ( |
| 623 | "import re, unicodedata\n\n" |
nothing calls this directly
no test coverage detected