@kinti/a11y-toolkit 5.29.0 → 5.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y_toolkit/a11yact.py +17 -8
- package/a11y_toolkit/a11yaudit.py +220 -77
- package/a11y_toolkit/a11ybudget.py +21 -1
- package/a11y_toolkit/a11ycorpus.py +8 -1
- package/a11y_toolkit/a11ycrit.py +72 -0
- package/a11y_toolkit/a11ydiff.py +24 -11
- package/a11y_toolkit/a11ydisprove.py +27 -4
- package/a11y_toolkit/a11ydocx.py +28 -4
- package/a11y_toolkit/a11ydom.py +582 -369
- package/a11y_toolkit/a11yengines.py +19 -6
- package/a11y_toolkit/a11yevidence.py +34 -11
- package/a11y_toolkit/a11yfingerprints.py +8 -5
- package/a11y_toolkit/a11yfix.py +21 -2
- package/a11y_toolkit/a11yinit.py +24 -5
- package/a11y_toolkit/a11yjourney.py +7 -0
- package/a11y_toolkit/a11yledger.py +9 -0
- package/a11y_toolkit/a11ylocate.py +7 -1
- package/a11y_toolkit/a11yopenacr.py +16 -1
- package/a11y_toolkit/a11ypatterns.py +133 -43
- package/a11y_toolkit/a11ypdf.py +26 -5
- package/a11y_toolkit/a11ysarif.py +10 -2
- package/a11y_toolkit/a11yscope.py +19 -0
- package/a11y_toolkit/a11yscroll.py +48 -23
- package/a11y_toolkit/a11ytrace.py +6 -8
- package/a11y_toolkit/a11yvpat.py +11 -1
- package/a11y_toolkit/a11yvtt.py +33 -3
- package/a11y_toolkit/arialive.js +17 -7
- package/a11y_toolkit/contrast.py +12 -5
- package/a11y_toolkit/locales/_template.json +9 -3
- package/a11y_toolkit/locales/en.json +8 -0
- package/a11y_toolkit/locales/es.json +8 -0
- package/a11y_toolkit/server.py +35 -11
- package/lib/_bootstrap.py +36 -0
- package/lib/runner.cjs +12 -4
- package/package.json +1 -1
package/a11y_toolkit/a11yact.py
CHANGED
|
@@ -97,13 +97,22 @@ def act_ids(signal):
|
|
|
97
97
|
def earl(report, url=None):
|
|
98
98
|
"""Informe de auditoría → EARL 1.0 JSON-LD (solo hallazgos con mapeo ACT)."""
|
|
99
99
|
assertions = []
|
|
100
|
-
# site crawls anidan en reports[]
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
# site crawls anidan en reports[]: cada hallazgo pertenece a SU página —
|
|
101
|
+
# aplanar sin más atribuía el fallo de /gallery a la PORTADA (revisión
|
|
102
|
+
# externa, 3ª pasada). Se conserva el par (hallazgo, url de su página).
|
|
103
|
+
pares = []
|
|
104
|
+
if isinstance(report, dict):
|
|
105
|
+
_hls = report.get('findings')
|
|
106
|
+
# precedencia como a11yevidence: findings top-level NO VACÍOS son las
|
|
107
|
+
# copias re-verificadas; una lista vacía es «sin hallazgos propios» y
|
|
108
|
+
# los de las páginas anidadas siguen siendo del crawl
|
|
109
|
+
if isinstance(_hls, list) and _hls:
|
|
110
|
+
pares = [(h, url or report.get('url', '')) for h in _hls]
|
|
111
|
+
elif isinstance(report.get('reports'), list):
|
|
112
|
+
pares = [(h, (sub.get('url') or url or report.get('url', '')))
|
|
113
|
+
for sub in report['reports'] if isinstance(sub, dict)
|
|
114
|
+
for h in sub.get('findings', []) if isinstance(h, dict)]
|
|
115
|
+
for h, _subj in pares:
|
|
107
116
|
if not isinstance(h, dict):
|
|
108
117
|
continue
|
|
109
118
|
if h.get('status') in _NOT_DEAD or h.get('disprover_status') in _NOT_DEAD:
|
|
@@ -116,7 +125,7 @@ def earl(report, url=None):
|
|
|
116
125
|
assertions.append({
|
|
117
126
|
'@type': 'earl:Assertion',
|
|
118
127
|
'earl:subject': {'@type': 'earl:TestSubject',
|
|
119
|
-
'url':
|
|
128
|
+
'url': _subj},
|
|
120
129
|
'earl:test': {'@type': 'earl:TestCase',
|
|
121
130
|
'url': _ACT_URL.format(rid=rid),
|
|
122
131
|
'title': name},
|
|
@@ -357,7 +357,7 @@ _SKIP_TEXT = re.compile(
|
|
|
357
357
|
r'skip|jump to|saltar|ir al contenido|ir para o conte[uú]do|passer au contenu', re.I)
|
|
358
358
|
|
|
359
359
|
# encabezados cortos legítimos (acrónimos y términos técnicos): «FAQ», «API»…
|
|
360
|
-
_SHORT_HEADINGS = {'FAQ', 'API', 'CSS', 'APP', 'MAP', 'EN', 'DE', 'ES', 'PT', 'FR',
|
|
360
|
+
_SHORT_HEADINGS = {'FAQ', 'API', 'CSS', 'SVG', 'APP', 'MAP', 'EN', 'DE', 'ES', 'PT', 'FR',
|
|
361
361
|
'IT', 'UI', 'UX', 'ID', 'TV', 'HR', 'PR', 'AI', 'PC', 'OK', '3D',
|
|
362
362
|
'IOS', 'OS', 'GB', 'MB', 'KB', 'PDF', 'RSS', 'URL', 'WWW', 'XML',
|
|
363
363
|
'HTTP', 'FAQS', 'BLOG', 'HOME', 'INICIO', 'NOTAS', 'AGENDA'}
|
|
@@ -483,6 +483,8 @@ class _Auditor(HTMLParser):
|
|
|
483
483
|
self.controls_raw = [] # (kind, attrs, texto, [nombres imgs internas], hidden)
|
|
484
484
|
self.headings_raw = [] # (nivel, attrs, texto, hidden)
|
|
485
485
|
self.fields_raw = [] # (tag, kind, attrs, dentro_de_label, hidden)
|
|
486
|
+
self._fields_in_label = [] # campos que el <label> ABIERTO envuelve
|
|
487
|
+
self._wrap_label_text = {} # id(attrs del campo) → texto de su label envolvente
|
|
486
488
|
self._heading_attrs = {}
|
|
487
489
|
self.videos = 0
|
|
488
490
|
self.videos_with_captions = 0
|
|
@@ -520,7 +522,10 @@ class _Auditor(HTMLParser):
|
|
|
520
522
|
self.heading_role_removed = [] # h1-h6 con rol que sustituye al de heading
|
|
521
523
|
self.text_spacing_important = [] # 1.4.12: spacing !important inline (ACT 24afc2/78fd32/9e45ec)
|
|
522
524
|
self.links = {} # nombre normalizado → set de hrefs
|
|
525
|
+
self.links_elems = {} # entry_key → primeros elems (marcas 2.4.4)
|
|
523
526
|
self.generics = 0
|
|
527
|
+
self.generic_link_elems = [] # marcas 2.4.4
|
|
528
|
+
self._label_elem_stack = [] # elem por <label> abierto (marcas 3.3.2)
|
|
524
529
|
self.labels_for_dups = {} # id → n labels (los >1, varios)
|
|
525
530
|
self._label_for_stack = [] # valor `for` de cada <label> abierto (None = envolvente)
|
|
526
531
|
self._label_text_for = {} # id del for → texto del label (decisión post-parse)
|
|
@@ -528,7 +533,10 @@ class _Auditor(HTMLParser):
|
|
|
528
533
|
self._list_depth = 0
|
|
529
534
|
self._li_depth = 0
|
|
530
535
|
self._bad_list = 0
|
|
531
|
-
self.label_no_name = [] # (texto visible,
|
|
536
|
+
self.label_no_name = [] # (texto visible, nombre efectivo) 2.5.3
|
|
537
|
+
self.label_no_name_elems = [] # marcas 2.5.3
|
|
538
|
+
self.label_in_name_raw = [] # (visible, aria-label, ids labelledby, attrs) — crudo, POST-parse decide
|
|
539
|
+
self.orphan_label_elems = [] # marcas 3.3.2
|
|
532
540
|
self.lang_parts_invalid = [] # lang inválidos en elementos no-html
|
|
533
541
|
self.down_events = [] # onmousedown/ontouchstart/onpointerdown
|
|
534
542
|
self.captchas = [] # detección 3.3.8 — SOLO en contexto de autenticación
|
|
@@ -537,7 +545,7 @@ class _Auditor(HTMLParser):
|
|
|
537
545
|
self._required_pend = [] # (tag, attrs) required: decide post-parse con el label
|
|
538
546
|
self.mobiles = [] # marquee/blink/inline infinite animation (2.2.2)
|
|
539
547
|
self._landmark_ids = set() # ids de landmarks: objetivos válidos de skip link
|
|
540
|
-
self.nav_hrefs =
|
|
548
|
+
self.nav_hrefs = [] # hrefs inside <nav> EN ORDEN (3.2.3 juzga el ORDEN relativo)
|
|
541
549
|
self.help_hrefs = set() # help/contact links (site-level 3.2.6 signature)
|
|
542
550
|
self.images_of_text = []
|
|
543
551
|
self.vague_headings = []
|
|
@@ -560,6 +568,7 @@ class _Auditor(HTMLParser):
|
|
|
560
568
|
self._group_role_depth = 0 # <div role=group/radiogroup> abierto (con nombre)
|
|
561
569
|
self.has_search = False
|
|
562
570
|
self.has_sitemap = False
|
|
571
|
+
self.has_index = False # índice/TOC/relacionados: vía 2.4.5 (4ª pasada)
|
|
563
572
|
self.gestures = [] # touchmove/drag handlers (2.5.1)
|
|
564
573
|
self.focus_blur = [] # onfocus="blur()": foco robado (2.1.1)
|
|
565
574
|
self.focus_blur_elems = []
|
|
@@ -577,52 +586,29 @@ class _Auditor(HTMLParser):
|
|
|
577
586
|
return
|
|
578
587
|
self._ctrl.pop()
|
|
579
588
|
a = c['attrs']
|
|
580
|
-
|
|
589
|
+
# nombre desde el texto VISIBLE (4ª pasada): el crudo incluía texto
|
|
590
|
+
# con display:none/visibility:hidden que accname excluye. .sr-only
|
|
591
|
+
# (clip) sigue contando: está en el árbol de accesibilidad; y el
|
|
592
|
+
# <title> de un svg interno entra por su canal (alternativo, no
|
|
593
|
+
# renderizado, PERO sí nombre)
|
|
594
|
+
text = ' '.join(x for x in (
|
|
595
|
+
''.join(c.get('text_visible', [])).strip(),
|
|
596
|
+
' '.join(c.get('text_alt', [])).strip()) if x)
|
|
581
597
|
# decisión de nombre POST-parse: los ids de un aria-labelledby pueden
|
|
582
598
|
# declararse después del control; se registra todo en crudo
|
|
583
599
|
self.controls_raw.append((c.get('kind') or tag, a, text, c.get('img_attrs', []),
|
|
584
600
|
c.get('hidden', False)))
|
|
585
|
-
# 2.5.3 label in name —
|
|
586
|
-
#
|
|
587
|
-
#
|
|
588
|
-
#
|
|
589
|
-
#
|
|
590
|
-
#
|
|
591
|
-
# concatenación DOM fiel: sin espacios artificiales — los del DOM ya
|
|
592
|
-
# vienen en los propios nodos de texto (2ee8b8: «W C A G» ≠ «ACT»)
|
|
601
|
+
# 2.5.3 label in name — el VEREDICTO se decide POST-parse (los ids de
|
|
602
|
+
# aria-labelledby pueden declararse después del control). Aquí solo se
|
|
603
|
+
# registra lo crudo; el algoritmo vive abajo, sobre el nombre EFECTIVO
|
|
604
|
+
# por precedencia accname (revisión externa, 4ª pasada: comparar
|
|
605
|
+
# contra aria-label penalizaba controles nombrados por labelledby y
|
|
606
|
+
# aprobaba el caso inverso)
|
|
593
607
|
_vis = ''.join(c.get('text_visible', [])).strip()
|
|
594
608
|
_al = (a.get('aria-label') or '').strip()
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
r"font-family\s*:[^;}]*?(Material[+ ]Icons|Font Awesome|glyphicon|icomoon|feather)"
|
|
599
|
-
r"|@font-face[^}]*?(Material[+ ]Icons|Font Awesome|glyphicon|icomoon|feather)",
|
|
600
|
-
self._styles_text, re.I)) or bool(re.search(
|
|
601
|
-
r'fonts\.googleapis\.com/icon|/material-icons|font-?awesome|/icomoon',
|
|
602
|
-
' '.join(getattr(self, '_icon_links', [])), re.I))
|
|
603
|
-
# página con fuente-icono: el «texto» del control puede ser un glifo
|
|
604
|
-
# no verbal (ligadura Material «shopping_cart») — exento en CUALQUIER
|
|
605
|
-
# control (enlaces-icono incluidos), no solo <button>
|
|
606
|
-
if not _icon_font and _vis and _al:
|
|
607
|
-
def _lin_words(txt):
|
|
608
|
-
txt = re.sub(r'\([^)]*\)', ' ', txt)
|
|
609
|
-
# la puntuación se ELIMINA sin partir palabras («11×3=33» →
|
|
610
|
-
# «1133»: una sola palabra) — algoritmo 2.5.3
|
|
611
|
-
return [w for w in re.sub(r'[^\w\s]|_', '', txt.lower()).split() if w]
|
|
612
|
-
_vp, _ap2 = _lin_words(_vis), _lin_words(_al)
|
|
613
|
-
_mismatch = False
|
|
614
|
-
if _vp and _ap2:
|
|
615
|
-
if len(_vp) == 1 and len(_vp[0]) <= 2 and _vp[0].isalpha():
|
|
616
|
-
_mismatch = False # letra-símbolo única (X): texto no verbal
|
|
617
|
-
else:
|
|
618
|
-
# RODAJA CONTIGUA EXACTA: «discover it» no cabe en
|
|
619
|
-
# «discover italy» (it ≠ italy); «download specification»
|
|
620
|
-
# no cabe en «download the specification»; «you how are»
|
|
621
|
-
# no en «how are you» aunque estén todas las palabras
|
|
622
|
-
_mismatch = not any(_ap2[i:i + len(_vp)] == _vp
|
|
623
|
-
for i in range(len(_ap2) - len(_vp) + 1))
|
|
624
|
-
if _mismatch:
|
|
625
|
-
self.label_no_name.append((_vis[:40], _al[:60]))
|
|
609
|
+
_lb_ids = (a.get('aria-labelledby') or '').split()
|
|
610
|
+
if _vis and (_al or _lb_ids) and len(self.label_in_name_raw) < 30:
|
|
611
|
+
self.label_in_name_raw.append((_vis[:80], _al[:120], _lb_ids[:6], a))
|
|
626
612
|
if tag == 'a' and not c.get('hidden'):
|
|
627
613
|
if (a.get('target') or '').lower() == '_blank':
|
|
628
614
|
self.blank_total += 1
|
|
@@ -645,8 +631,13 @@ class _Auditor(HTMLParser):
|
|
|
645
631
|
if name and href:
|
|
646
632
|
entry_key = ' '.join(name.lower().split())[:60]
|
|
647
633
|
self.links.setdefault(entry_key, set()).add(href)
|
|
634
|
+
_le_list = self.links_elems.setdefault(entry_key, [])
|
|
635
|
+
if len(_le_list) < 5:
|
|
636
|
+
_le_list.append(a)
|
|
648
637
|
if entry_key in _GENERIC_TEXT:
|
|
649
638
|
self.generics += 1
|
|
639
|
+
if len(self.generic_link_elems) < 5:
|
|
640
|
+
self.generic_link_elems.append(a)
|
|
650
641
|
|
|
651
642
|
def _field_note(self):
|
|
652
643
|
"""El elemento que acaba de abrirse es un campo: marca su <label> ancestro."""
|
|
@@ -692,6 +683,16 @@ class _Auditor(HTMLParser):
|
|
|
692
683
|
# ruta determinista del elemento (kernel de anotación): nth-of-type
|
|
693
684
|
# SIEMPRE (los id duplicados no pueden romper la ruta) y los void no
|
|
694
685
|
# abren pila (no tienen handle_endtag)
|
|
686
|
+
# tbody IMPLÍCITO bajo <table>: el navegador normaliza <table><tr>
|
|
687
|
+
# insertando <tbody>; sin reflejarlo, las rutas nth-of-type que
|
|
688
|
+
# cruzan la mesa no resuelven en el DOM real (Chromium: table>tr
|
|
689
|
+
# casa CERO elementos — revisión externa 2026-11-22). Se abre igual
|
|
690
|
+
# que un tag normal y </table> lo cierra con el resto de la pila.
|
|
691
|
+
if tag == 'tr' and self._path_stack and self._path_stack[-1][0] == 'table':
|
|
692
|
+
_parent_tb = self._path_stack[-1]
|
|
693
|
+
_parent_tb[2]['tbody'] = _parent_tb[2].get('tbody', 0) + 1
|
|
694
|
+
self._path_stack.append(
|
|
695
|
+
('tbody', _parent_tb[1] + '>' + path_segment('tbody', _parent_tb[2]['tbody']), {}))
|
|
695
696
|
if self._path_stack:
|
|
696
697
|
_parent = self._path_stack[-1]
|
|
697
698
|
_parent[2][tag] = _parent[2].get(tag, 0) + 1
|
|
@@ -727,8 +728,10 @@ class _Auditor(HTMLParser):
|
|
|
727
728
|
_hidden_aria = True
|
|
728
729
|
elif _ah_val == 'false':
|
|
729
730
|
_hidden_aria = False
|
|
731
|
+
# inert (4ª pasada): el subtroke queda no interactivo Y fuera del
|
|
732
|
+
# árbol de accesibilidad — un botón dentro de inert JAMÁS es enfocable
|
|
730
733
|
_hidden = _inh or 'hidden' in a or 'display:none' in _style \
|
|
731
|
-
or 'visibility:hidden' in _style or _hidden_aria
|
|
734
|
+
or 'visibility:hidden' in _style or _hidden_aria or 'inert' in a
|
|
732
735
|
# <template> es contenido INERTE (spec HTML): no renderiza, no recibe
|
|
733
736
|
# foco, sus ids no existen — se audita como oculto y los colectores
|
|
734
737
|
# que no consultan _hidden llevan guardia explícita
|
|
@@ -862,12 +865,20 @@ class _Auditor(HTMLParser):
|
|
|
862
865
|
'img_attrs': [], 'hidden': _hidden})
|
|
863
866
|
href = (a.get('href') or '').strip()
|
|
864
867
|
if self._in_nav and href and not href.startswith('#'):
|
|
865
|
-
|
|
868
|
+
_nv = href.split('#')[0].rstrip('/')
|
|
869
|
+
if _nv not in self.nav_hrefs:
|
|
870
|
+
self.nav_hrefs.append(_nv)
|
|
866
871
|
if href and re.search(r'help|contact|support|ayuda|contacto|soporte|asistencia',
|
|
867
872
|
href, re.I):
|
|
868
873
|
self.help_hrefs.add(href.split('#')[0].rstrip('/'))
|
|
869
874
|
if href and re.search(r'sitemap|site-map|mapa-del-sitio|mapa_web|mapaweb', href, re.I):
|
|
870
875
|
self.has_sitemap = True
|
|
876
|
+
# 2.4.5 vía adicional (4ª pasada): un índice/TOC o bloque de
|
|
877
|
+
# relacionados SON formas de encontrar páginas
|
|
878
|
+
if href and re.search(
|
|
879
|
+
r'(?:^|[/\-_!.])(?:index|indice|indice-de-contenidos|contents|toc|related|relacionados|ver-tambien|see-also)(?:$|[/\-_!.])',
|
|
880
|
+
href.split('#')[0].rstrip('/'), re.I):
|
|
881
|
+
self.has_index = True
|
|
871
882
|
elif tag == 'input':
|
|
872
883
|
self._field_note()
|
|
873
884
|
kind = (a.get('type') or 'text').lower()
|
|
@@ -882,8 +893,19 @@ class _Auditor(HTMLParser):
|
|
|
882
893
|
if kind == 'search' or re.search(r'search|busqueda|b[uú]squeda', (a.get('name') or '') + (a.get('id') or ''), re.I):
|
|
883
894
|
self.has_search = True
|
|
884
895
|
if kind in _FIELDS:
|
|
896
|
+
if self._wrap_labels(a):
|
|
897
|
+
self._fields_in_label.append(id(a))
|
|
885
898
|
self.fields_raw.append((tag, kind, a, self._wrap_labels(a), _hidden))
|
|
886
|
-
|
|
899
|
+
# 1.3.5 aplicabilidad y cobertura por SEPARADO (4ª pasada):
|
|
900
|
+
# type=email asumía «dato de la persona usuaria» aunque fuera
|
|
901
|
+
# el correo del DESTINATARIO, y autocomplete=off daba la
|
|
902
|
+
# condición por cubierta — off/on no identifican propósito
|
|
903
|
+
_recipient = re.search(
|
|
904
|
+
r'(?<![a-z0-9])(to|recipient|destinatari[oa]s?|destino|friend|amigo)(?![a-z0-9])',
|
|
905
|
+
((a.get('name') or '') + ' ' + (a.get('id') or '')), re.I)
|
|
906
|
+
_tok_ac = (a.get('autocomplete') or '').strip().lower()
|
|
907
|
+
_covered = bool(_tok_ac) and _tok_ac not in ('off', 'on')
|
|
908
|
+
if (not _covered) and kind != 'search' and not _recipient and (
|
|
887
909
|
kind in ('email', 'tel')
|
|
888
910
|
or _PERSONAL_DATA.search((a.get('name') or '') + ' ' + (a.get('id') or ''))):
|
|
889
911
|
self.missing_autocomplete.append(f'input type={kind} name={a.get("name") or "?"}'[:44])
|
|
@@ -929,11 +951,15 @@ class _Auditor(HTMLParser):
|
|
|
929
951
|
f'{_mal} (input name={a.get("name") or "?"})'[:60])
|
|
930
952
|
elif tag in ('select', 'textarea'):
|
|
931
953
|
self._field_note()
|
|
954
|
+
if self._wrap_labels(a):
|
|
955
|
+
self._fields_in_label.append(id(a))
|
|
932
956
|
self.fields_raw.append((tag, tag, a, self._wrap_labels(a), _hidden))
|
|
933
957
|
elif tag == 'label':
|
|
934
958
|
self._label_depth += 1
|
|
935
959
|
self._label_text_current = []
|
|
960
|
+
self._fields_in_label = [] # campos que ESTE label envuelve
|
|
936
961
|
self._labels_stack.append(False)
|
|
962
|
+
self._label_elem_stack.append(a)
|
|
937
963
|
self._label_for_stack.append(a.get('for') or None)
|
|
938
964
|
if a.get('for'):
|
|
939
965
|
self._labels_for[a['for']] = self._labels_for.get(a['for'], 0) + 1
|
|
@@ -1371,8 +1397,11 @@ class _Auditor(HTMLParser):
|
|
|
1371
1397
|
if _svgtxt:
|
|
1372
1398
|
if self._ctrl:
|
|
1373
1399
|
# nombre SÍ (accname from content); VISIBLE no — el
|
|
1374
|
-
# <title> de svg es texto alternativo, no renderizado
|
|
1400
|
+
# <title> de svg es texto alternativo, no renderizado.
|
|
1401
|
+
# Canal aparte (4ª pasada): el nombre del control parte
|
|
1402
|
+
# del texto VISIBLE y el título-vía-svg entra aquí
|
|
1375
1403
|
self._ctrl[-1]['text'].append(_svgtxt)
|
|
1404
|
+
self._ctrl[-1].setdefault('text_alt', []).append(_svgtxt)
|
|
1376
1405
|
for _fr in reversed(self._el_stack):
|
|
1377
1406
|
if _fr[0] == 'svg':
|
|
1378
1407
|
self._svg_titles[id(_fr[1])] = _svgtxt
|
|
@@ -1402,8 +1431,18 @@ class _Auditor(HTMLParser):
|
|
|
1402
1431
|
_lfor = self._label_for_stack.pop()
|
|
1403
1432
|
if _lfor and txt:
|
|
1404
1433
|
self._label_text_for[_lfor] = txt
|
|
1405
|
-
|
|
1406
|
-
|
|
1434
|
+
# texto del label ENVOLVENTE por campo (a11ylocate indexa el
|
|
1435
|
+
# campo por su nombre visible — la misma resolución del auditor)
|
|
1436
|
+
if txt:
|
|
1437
|
+
for _fa in getattr(self, '_fields_in_label', []):
|
|
1438
|
+
self._wrap_label_text[_fa] = txt
|
|
1439
|
+
if self._labels_stack:
|
|
1440
|
+
# pila paralela de elems: pop SIEMPRE (un pop por cierre)
|
|
1441
|
+
_le = self._label_elem_stack.pop() if self._label_elem_stack else None
|
|
1442
|
+
if not self._labels_stack.pop():
|
|
1443
|
+
self.orphan_labels += 1
|
|
1444
|
+
if _le is not None and len(self.orphan_label_elems) < 5:
|
|
1445
|
+
self.orphan_label_elems.append(_le)
|
|
1407
1446
|
elif tag == 'fieldset':
|
|
1408
1447
|
self._in_fieldset = False
|
|
1409
1448
|
elif tag == 'form':
|
|
@@ -1588,7 +1627,10 @@ class _Auditor(HTMLParser):
|
|
|
1588
1627
|
self._ctrl[-1]['text_visible'].append(data)
|
|
1589
1628
|
if self._heading_level is not None and not _hidden_ah:
|
|
1590
1629
|
self._heading_text.append(data)
|
|
1591
|
-
|
|
1630
|
+
# las CITAS son menciones legítimas (un checklist que cita el
|
|
1631
|
+
# anti-patrón «el botón de la derecha» para enseñarlo no incumple:
|
|
1632
|
+
# espejo de _sin_citas del corrector de plantillas)
|
|
1633
|
+
m = _SENSORIAL.search(re.sub(r'«[^»]*»|“[^”]*”|"[^"]*"', ' ', data))
|
|
1592
1634
|
if m and len(self.sensory) < 6:
|
|
1593
1635
|
self.sensory.append(m.group(0).strip()[:60])
|
|
1594
1636
|
|
|
@@ -1894,9 +1936,14 @@ def audit_html(html_text, url='(html)', lang='en', standard=None, target=None):
|
|
|
1894
1936
|
if _fa.get('role') == a.get('role') and not a.get('id') and not _fa.get('id')),
|
|
1895
1937
|
'')
|
|
1896
1938
|
_placeholder = (a.get('placeholder') or '').strip() if tag != 'select' else ''
|
|
1939
|
+
# el <label> SOLO cuenta con TEXTO (4ª pasada: un label VACÍO daba
|
|
1940
|
+
# nombre y Chromium exponía el campo sin nombre)
|
|
1941
|
+
_label_txt = (getattr(p, '_label_text_for', {}).get(a.get('id'), '')
|
|
1942
|
+
or getattr(p, '_wrap_label_text', {}).get(id(a), '')).strip()
|
|
1897
1943
|
_has_real_name = bool(al or lb or ti
|
|
1898
|
-
or (en_label and _is_labelable)
|
|
1899
|
-
or (_is_labelable and a.get('id') and a['id'] in p._labels_for
|
|
1944
|
+
or (en_label and _is_labelable and _label_txt)
|
|
1945
|
+
or (_is_labelable and a.get('id') and a['id'] in p._labels_for
|
|
1946
|
+
and getattr(p, '_label_text_for', {}).get(a.get('id'), '').strip())
|
|
1900
1947
|
or _content_name)
|
|
1901
1948
|
if not (_has_real_name or _placeholder):
|
|
1902
1949
|
p.fields_no_label.append((kind or tag, (a.get('name') or '')[:60], a.get('id')))
|
|
@@ -1971,7 +2018,9 @@ def audit_html(html_text, url='(html)', lang='en', standard=None, target=None):
|
|
|
1971
2018
|
paths=[p._elem_paths[id(_a)] for _a in p.role_no_tabindex_elems
|
|
1972
2019
|
if id(_a) in p._elem_paths][:5])
|
|
1973
2020
|
if p.orphan_labels:
|
|
1974
|
-
add('low', '3.3.2', 'label_orphan', n=p.orphan_labels
|
|
2021
|
+
add('low', '3.3.2', 'label_orphan', n=p.orphan_labels,
|
|
2022
|
+
paths=[p._elem_paths[id(_a)] for _a in p.orphan_label_elems
|
|
2023
|
+
if id(_a) in p._elem_paths][:5])
|
|
1975
2024
|
if p._bad_list:
|
|
1976
2025
|
add('medium', '1.3.1', 'list_structure', n=p._bad_list)
|
|
1977
2026
|
if p.root_tag in ('svg', 'math'):
|
|
@@ -2158,11 +2207,43 @@ def audit_html(html_text, url='(html)', lang='en', standard=None, target=None):
|
|
|
2158
2207
|
add('medium', '1.4.2', 'video_autoplay', n=p.media_autoplay,
|
|
2159
2208
|
paths=[p._elem_paths[id(_a)] for _a in p.media_autoplay_elems
|
|
2160
2209
|
if id(_a) in p._elem_paths][:5])
|
|
2210
|
+
# 2.5.3, veredicto POST-parse (4ª pasada): el nombre EFECTIVO por
|
|
2211
|
+
# precedencia accname — labelledby (ids resueltos, unidos en orden) GANA
|
|
2212
|
+
# a aria-label. El nombre del propio contenido cumple trivialmente.
|
|
2213
|
+
def _lin_words(txt):
|
|
2214
|
+
txt = re.sub(r'\([^)]*\)', ' ', txt)
|
|
2215
|
+
return [w for w in re.sub(r'[^\w\s]|_', '', txt.lower()).split() if w]
|
|
2216
|
+
_icon_font = bool(re.search(
|
|
2217
|
+
r"font-family\s*:[^;}]*?(Material[+ ]Icons|Font Awesome|glyphicon|icomoon|feather)"
|
|
2218
|
+
r"|@font-face[^}]*?(Material[+ ]Icons|Font Awesome|glyphicon|icomoon|feather)",
|
|
2219
|
+
getattr(p, '_styles_text', ''), re.I)) or bool(re.search(
|
|
2220
|
+
r'fonts\.googleapis\.com/icon|/material-icons|font-?awesome|/icomoon',
|
|
2221
|
+
' '.join(getattr(p, '_icon_links', [])), re.I))
|
|
2222
|
+
for _vis, _al, _lb_ids, _a in p.label_in_name_raw:
|
|
2223
|
+
_lb_txt = ' '.join((p._id_texts.get(i, '') or '').strip()
|
|
2224
|
+
for i in _lb_ids if (p._id_texts.get(i, '') or '').strip())
|
|
2225
|
+
_name_eff = _lb_txt or _al
|
|
2226
|
+
_vp, _np2 = _lin_words(_vis), _lin_words(_name_eff)
|
|
2227
|
+
if not (_vp and _np2):
|
|
2228
|
+
continue
|
|
2229
|
+
if len(_vp) == 1 and len(_vp[0]) <= 2 and _vp[0].isalpha():
|
|
2230
|
+
continue # letra-símbolo única (X, emoji): texto no verbal
|
|
2231
|
+
# fuente-icono: SOLO controles de token único (ligadura); un botón de
|
|
2232
|
+
# texto con dos palabras JAMÁS es un glifo (4ª pasada)
|
|
2233
|
+
if _icon_font and len(_vp) == 1:
|
|
2234
|
+
continue
|
|
2235
|
+
# RODAJA CONTIGUA EXACTA: «discover it» no cabe en «discover italy»
|
|
2236
|
+
if not any(_np2[i:i + len(_vp)] == _vp for i in range(len(_np2) - len(_vp) + 1)):
|
|
2237
|
+
p.label_no_name.append((_vis[:40], _name_eff[:60]))
|
|
2238
|
+
if len(p.label_no_name_elems) < 5:
|
|
2239
|
+
p.label_no_name_elems.append(_a)
|
|
2161
2240
|
if p.label_no_name:
|
|
2162
2241
|
_ln = p.label_no_name[0]
|
|
2163
2242
|
add_ej('medium', '2.5.3', 'label_in_name',
|
|
2164
|
-
[f'«{t}» vs
|
|
2165
|
-
n=len(p.label_no_name), example=f'{_ln[0]} ≠ {_ln[1]}'
|
|
2243
|
+
[f'«{t}» vs name «{al}»' for t, al in p.label_no_name],
|
|
2244
|
+
n=len(p.label_no_name), example=f'{_ln[0]} ≠ {_ln[1]}',
|
|
2245
|
+
paths=[p._elem_paths[id(_a)] for _a in p.label_no_name_elems
|
|
2246
|
+
if id(_a) in p._elem_paths][:5])
|
|
2166
2247
|
if p.lang_parts_invalid:
|
|
2167
2248
|
add_ej('medium', '3.1.2', 'element_lang_invalid', p.lang_parts_invalid,
|
|
2168
2249
|
n=len(p.lang_parts_invalid), example=', '.join(p.lang_parts_invalid[:4]))
|
|
@@ -2237,10 +2318,16 @@ def audit_html(html_text, url='(html)', lang='en', standard=None, target=None):
|
|
|
2237
2318
|
add('low', '1.3.1', 'landmark_dup', n=len(lm_dups), example=', '.join(lm_dups[:4]))
|
|
2238
2319
|
if p.generics >= 2: # un enlace genérico único suele desambiguarse por contexto
|
|
2239
2320
|
gen = [f'«{k}»' for k in p.links if k in _GENERIC_TEXT][:4]
|
|
2240
|
-
add('low', '2.4.4', 'generic_link', n=p.generics, example=', '.join(gen)
|
|
2321
|
+
add('low', '2.4.4', 'generic_link', n=p.generics, example=', '.join(gen),
|
|
2322
|
+
paths=[p._elem_paths[id(_a)] for _a in p.generic_link_elems
|
|
2323
|
+
if id(_a) in p._elem_paths][:5])
|
|
2241
2324
|
same = sum(1 for _k, hrefs in p.links.items() if len(hrefs) > 1)
|
|
2242
2325
|
if same:
|
|
2243
|
-
|
|
2326
|
+
_same_elems = [p.links_elems.get(_k, [None])[0]
|
|
2327
|
+
for _k, _hs in p.links.items() if len(_hs) > 1]
|
|
2328
|
+
add('low', '2.4.4', 'same_name_links', n=same,
|
|
2329
|
+
paths=[p._elem_paths[id(_a)] for _a in _same_elems
|
|
2330
|
+
if _a is not None and id(_a) in p._elem_paths][:5])
|
|
2244
2331
|
ak_dups = [f'"{k}" ×{v}' for k, v in p.accesskeys.items() if v > 1]
|
|
2245
2332
|
if ak_dups:
|
|
2246
2333
|
add('low', '2.1.1', 'accesskey_dup', n=len(ak_dups), example=', '.join(ak_dups[:4]))
|
|
@@ -2366,7 +2453,7 @@ class _CheckedRedirect(urllib.request.HTTPRedirectHandler):
|
|
|
2366
2453
|
_OPENER = urllib.request.build_opener(_CheckedRedirect)
|
|
2367
2454
|
|
|
2368
2455
|
|
|
2369
|
-
def _fetch(url, timeout=30, truncate_at=None, accept_ct=()):
|
|
2456
|
+
def _fetch(url, timeout=30, truncate_at=None, accept_ct=(), _meta=None):
|
|
2370
2457
|
scheme = url.split(':', 1)[0].lower() if ':' in url else ''
|
|
2371
2458
|
if scheme not in ('http', 'https'):
|
|
2372
2459
|
# política única para TODAS las rutas de descarga (audit_url la
|
|
@@ -2378,6 +2465,11 @@ def _fetch(url, timeout=30, truncate_at=None, accept_ct=()):
|
|
|
2378
2465
|
'Accept-Encoding': 'gzip',
|
|
2379
2466
|
})
|
|
2380
2467
|
with _OPENER.open(req, timeout=timeout) as r:
|
|
2468
|
+
# verdad de navegación (4ª pasada): seguir una redirección en
|
|
2469
|
+
# silencio hacía puntuar 100 la pantalla de acceso BAJO la URL pedida
|
|
2470
|
+
if _meta is not None:
|
|
2471
|
+
_meta['final_url'] = r.geturl()
|
|
2472
|
+
_meta['status'] = getattr(r, 'status', None)
|
|
2381
2473
|
ceiling = truncate_at or MAX_HTML
|
|
2382
2474
|
# TOTAL-CLOCK reading: the socket timeout is per-operation and a server
|
|
2383
2475
|
# dribbling one byte per operation reset it forever. Read in chunks
|
|
@@ -2435,15 +2527,29 @@ _T_SCHEME = {
|
|
|
2435
2527
|
def audit_url(url, timeout=30, lang='en', standard=None, target=None):
|
|
2436
2528
|
if url.split(':')[0].lower() not in ('http', 'https'):
|
|
2437
2529
|
return {'error': _T_SCHEME.get(lang, _T_SCHEME['es'])}
|
|
2530
|
+
_meta = {}
|
|
2438
2531
|
try:
|
|
2439
|
-
html_text = _fetch(url, timeout=timeout)
|
|
2532
|
+
html_text = _fetch(url, timeout=timeout, _meta=_meta)
|
|
2440
2533
|
except _FetchError as e:
|
|
2441
2534
|
return {'error': _t(lang, e.key).format(**e.fmt)}
|
|
2442
2535
|
except ValueError as e:
|
|
2443
2536
|
return {'error': str(e)}
|
|
2444
2537
|
except Exception as e: # noqa: BLE001
|
|
2445
2538
|
return {'error': _t(lang, 'fetch_error').format(e=e)}
|
|
2446
|
-
|
|
2539
|
+
# verdad de navegación (4ª pasada): el informe lleva la URL FINAL (la
|
|
2540
|
+
# página que de verdad se miró), la PEDIDA y el estado HTTP
|
|
2541
|
+
final_url = _meta.get('final_url') or url
|
|
2542
|
+
res = audit_html(html_text, final_url.split('#')[0], lang=lang,
|
|
2543
|
+
standard=standard, target=target)
|
|
2544
|
+
if final_url.split('#')[0] != url.split('#')[0]:
|
|
2545
|
+
res['requested_url'] = url
|
|
2546
|
+
res['redirect_note'] = (
|
|
2547
|
+
'la URL pedida redirigió: el informe es de la página FINAL'
|
|
2548
|
+
if lang == 'es' else
|
|
2549
|
+
'the requested URL redirected: this report is for the FINAL page')
|
|
2550
|
+
if _meta.get('status'):
|
|
2551
|
+
res['http_status'] = _meta['status']
|
|
2552
|
+
return res
|
|
2447
2553
|
|
|
2448
2554
|
|
|
2449
2555
|
_LOC = re.compile(r'<loc>\s*([^<\s]+)\s*</loc>', re.I)
|
|
@@ -2510,13 +2616,28 @@ def evaluate_site(parsers, lang='en'):
|
|
|
2510
2616
|
2.4.5 multiple ways. Pure function so tests need no network."""
|
|
2511
2617
|
out = []
|
|
2512
2618
|
if len(parsers) >= 3:
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2619
|
+
# 3.2.3 evalúa el ORDEN RELATIVO de la navegación repetida (4ª
|
|
2620
|
+
# pasada): comparar conjuntos dejaba pasar dos enlaces intercambiados
|
|
2621
|
+
# y disparaba ante un enlace contextual INSERTADO sin mover a los
|
|
2622
|
+
# demás. Se juzga la secuencia de los enlaces COMPARTIDOS por par
|
|
2623
|
+
seqs = [list(p.nav_hrefs) for p in parsers if p.nav_hrefs]
|
|
2624
|
+
if len(seqs) >= 3:
|
|
2625
|
+
reordered_pairs = 0
|
|
2626
|
+
for i in range(len(seqs)):
|
|
2627
|
+
for j in range(i + 1, len(seqs)):
|
|
2628
|
+
shared = set(seqs[i]) & set(seqs[j])
|
|
2629
|
+
if len(shared) < 2:
|
|
2630
|
+
continue
|
|
2631
|
+
order_a = [h for h in seqs[i] if h in shared]
|
|
2632
|
+
order_b = [h for h in seqs[j] if h in shared]
|
|
2633
|
+
if order_a != order_b:
|
|
2634
|
+
reordered_pairs += 1
|
|
2635
|
+
if reordered_pairs:
|
|
2636
|
+
out.append({'severity': 'medium', 'criterion': _crit(lang, '3.2.3'),
|
|
2637
|
+
'signal': 'nav_inconsistent',
|
|
2638
|
+
'issue': _t(lang, 'nav_inconsistent').format(
|
|
2639
|
+
example=f'{reordered_pairs} pares de páginas con orden distinto en {len(seqs)}'),
|
|
2640
|
+
'remediation': _t(lang, 'nav_inconsistent_rem')})
|
|
2520
2641
|
# 3.2.6 Consistent Help (A, new in 2.2): help links stable across pages
|
|
2521
2642
|
signatures_help = [frozenset(p.help_hrefs) for p in parsers if p.help_hrefs]
|
|
2522
2643
|
if len(signatures_help) >= 2 and len(parsers) >= 3 and len(set(signatures_help)) > 1:
|
|
@@ -2528,11 +2649,22 @@ def evaluate_site(parsers, lang='en'):
|
|
|
2528
2649
|
# 2.4.5 exige múltiples formas de encontrar PÁGINAS: con una muestra de
|
|
2529
2650
|
# una sola página no hay proceso multi-página que reclamarlo (FP en
|
|
2530
2651
|
# sitios de una página — la excepción del propio criterio)
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2652
|
+
# 2.4.5 (4ª pasada): un índice/TOC o enlaces relacionados SON vías; sin
|
|
2653
|
+
# buscador NI sitemap en una muestra pequeña, la evidencia es PARCIAL —
|
|
2654
|
+
# la reseña baja a low y lo declara
|
|
2655
|
+
_has_way = any(p.has_search or p.has_sitemap for p in parsers)
|
|
2656
|
+
_has_index_way = any(getattr(p, 'has_index', False) for p in parsers)
|
|
2657
|
+
if len(parsers) >= 2 and not _has_way and not _has_index_way:
|
|
2658
|
+
entry = {'criterion': _crit(lang, '2.4.5'),
|
|
2659
|
+
'signal': 'no_multiple_ways',
|
|
2660
|
+
'issue': _t(lang, 'no_multiple_ways'),
|
|
2661
|
+
'remediation': _t(lang, 'no_multiple_ways_rem')}
|
|
2662
|
+
entry['severity'] = 'medium' if len(parsers) >= 4 else 'low'
|
|
2663
|
+
entry['issue'] = entry['issue'] + (
|
|
2664
|
+
' (partial evidence: search and sitemap not found in a small sample)'
|
|
2665
|
+
if lang == 'en' else
|
|
2666
|
+
' (evidencia parcial: ni buscador ni sitemap en una muestra pequeña)')
|
|
2667
|
+
out.append(entry)
|
|
2536
2668
|
return out
|
|
2537
2669
|
|
|
2538
2670
|
|
|
@@ -2577,17 +2709,24 @@ def audit_site(url, max_pages=5, timeout=30, lang='en', from_sitemap=True,
|
|
|
2577
2709
|
if next in seen:
|
|
2578
2710
|
continue
|
|
2579
2711
|
seen.add(next)
|
|
2712
|
+
_m = {}
|
|
2580
2713
|
try:
|
|
2581
|
-
html_pg = _fetch(next, timeout=timeout)
|
|
2714
|
+
html_pg = _fetch(next, timeout=timeout, _meta=_m)
|
|
2582
2715
|
except Exception: # noqa: BLE001
|
|
2583
2716
|
continue
|
|
2584
|
-
|
|
2717
|
+
# enlaces y reporte contra la URL FINAL (4ª pasada: tras una
|
|
2718
|
+
# redirección, resolver contra la PEDIDA visitaba rutas equivocadas)
|
|
2719
|
+
next_final = ((_m.get('final_url') or next).split('#')[0]).rstrip('/')
|
|
2720
|
+
if next_final != next and next_final in seen:
|
|
2721
|
+
continue # la redirección aterrizó en una ya auditada
|
|
2722
|
+
seen.add(next_final)
|
|
2723
|
+
pg, pg_err = _parse_page(html_pg, next_final)
|
|
2585
2724
|
if pg_err is not None:
|
|
2586
2725
|
continue # página rota: no cuenta, el crawl sigue
|
|
2587
|
-
reports.append(audit_html(html_pg,
|
|
2726
|
+
reports.append(audit_html(html_pg, next_final, lang=lang))
|
|
2588
2727
|
parsers.append(pg)
|
|
2589
2728
|
if len(reports) < max_pages and not from_sitemap:
|
|
2590
|
-
for new in _internal_links(html_pg,
|
|
2729
|
+
for new in _internal_links(html_pg, next_final, url):
|
|
2591
2730
|
if new not in seen:
|
|
2592
2731
|
queue.append(new)
|
|
2593
2732
|
site_findings = evaluate_site(parsers, lang=lang)
|
|
@@ -2762,7 +2901,11 @@ def main(argv):
|
|
|
2762
2901
|
# --standard nunca se descarte en silencio en NINGUNA ruta del CLI
|
|
2763
2902
|
res = _apply_standard(res, a.standard, a.target, a.lang)
|
|
2764
2903
|
print(json.dumps(res, ensure_ascii=False, indent=1))
|
|
2765
|
-
|
|
2904
|
+
# fallo de ejecución (error en el informe) ≠ hallazgo de accesibilidad:
|
|
2905
|
+
# la revisión externa cazó audit --url devolviendo 1 pero --file (y los
|
|
2906
|
+
# mains de a11ydom) devolviendo 0 CON error — un verde falso para cualquier
|
|
2907
|
+
# script que encauce por el código de salida
|
|
2908
|
+
return 1 if isinstance(res, dict) and res.get('error') else 0
|
|
2766
2909
|
|
|
2767
2910
|
|
|
2768
2911
|
if __name__ == '__main__':
|
|
@@ -75,7 +75,20 @@ def init(audit):
|
|
|
75
75
|
|
|
76
76
|
def compare(budget, audit, today=None):
|
|
77
77
|
"""Presupuesto vs informe actual → veredicto ok/bloqueado con el detalle."""
|
|
78
|
-
|
|
78
|
+
# un informe FALLIDO no es evidencia de nada (revisión externa 2026-11-22:
|
|
79
|
+
# con {'error': …} current quedaba vacío, TODO el baseline salía
|
|
80
|
+
# «resolved» y el gate día verde). Sin páginas usables → error; las
|
|
81
|
+
# sub-páginas fallidas de un crawl se excluyen y se declaran.
|
|
82
|
+
if not isinstance(audit, dict) or audit.get('error'):
|
|
83
|
+
return {'error': 'the audit report failed (error field) — a failed run '
|
|
84
|
+
'is not evidence that findings were fixed'}
|
|
85
|
+
pages = audit.get('reports') if isinstance(audit.get('reports'), list) else [audit]
|
|
86
|
+
failed = [pg.get('url') for pg in pages
|
|
87
|
+
if isinstance(pg, dict) and pg.get('error')]
|
|
88
|
+
pages = [pg for pg in pages if not (isinstance(pg, dict) and pg.get('error'))]
|
|
89
|
+
if not pages:
|
|
90
|
+
return {'error': f'all {len(failed)} pages of the report failed — '
|
|
91
|
+
'nothing to compare'}
|
|
79
92
|
base = {normalize_signal(s) for s in budget.get('signals', [])}
|
|
80
93
|
blocking = set(budget.get('blocking', ['high', 'medium']))
|
|
81
94
|
current = {}
|
|
@@ -98,6 +111,7 @@ def compare(budget, audit, today=None):
|
|
|
98
111
|
'new': new,
|
|
99
112
|
'new_blocking': new_blocking,
|
|
100
113
|
'resolved': resolved,
|
|
114
|
+
**({'pages_failed': failed} if failed else {}),
|
|
101
115
|
'summary': {
|
|
102
116
|
'baseline': len(base),
|
|
103
117
|
'current': len(current),
|
|
@@ -258,6 +272,12 @@ def main(argv):
|
|
|
258
272
|
from .a11yaudit import audit_url
|
|
259
273
|
report = audit_url(a.url)
|
|
260
274
|
verdict = compare(budget, report)
|
|
275
|
+
if 'error' in verdict:
|
|
276
|
+
# informe fallido/malformado: error de EJECUCIÓN (exit 1), jamás un
|
|
277
|
+
# verde — el gate presupuestario no puede declarar resuelto lo que no
|
|
278
|
+
# llegó a mirar
|
|
279
|
+
print(json.dumps(verdict, ensure_ascii=False, indent=1))
|
|
280
|
+
return 1
|
|
261
281
|
print(json.dumps(verdict, ensure_ascii=False, indent=1))
|
|
262
282
|
return 0 if verdict['ok'] else 2
|
|
263
283
|
|
|
@@ -308,7 +308,7 @@ def evaluate(submission, directory='corpus', submission_name='submission'):
|
|
|
308
308
|
additional.append({'case_id': cid, 'additional_criteria': extra})
|
|
309
309
|
n_mut = sum(1 for c in entries.values() if c['kind'] == 'mutant')
|
|
310
310
|
n_pla = len(entries) - n_mut
|
|
311
|
-
|
|
311
|
+
out = {
|
|
312
312
|
'format': EVAL_FORMAT,
|
|
313
313
|
'submission_name': submission_name,
|
|
314
314
|
'mutants': n_mut, 'killed': len(killed),
|
|
@@ -316,6 +316,12 @@ def evaluate(submission, directory='corpus', submission_name='submission'):
|
|
|
316
316
|
'missed_detail': missed,
|
|
317
317
|
'control_pages': n_pla,
|
|
318
318
|
'false_positives': fps,
|
|
319
|
+
# (4ª pasada) sin páginas control, «cero falsos positivos» es
|
|
320
|
+
# infalsable — la evaluación se declara incompleta, no limpia
|
|
321
|
+
**({'incomplete': True,
|
|
322
|
+
'incomplete_reason': 'no control (placebo) pages in the submission: '
|
|
323
|
+
'the false-positive claim cannot be evaluated'}
|
|
324
|
+
if n_pla == 0 else {'incomplete': False}),
|
|
319
325
|
'additional_findings_on_mutants': {'count': len(additional),
|
|
320
326
|
'note': 'reported, not scored: only '
|
|
321
327
|
'placebo flags are false '
|
|
@@ -327,6 +333,7 @@ def evaluate(submission, directory='corpus', submission_name='submission'):
|
|
|
327
333
|
'cases_without_submission': [cid for cid in sorted(entries)
|
|
328
334
|
if cid not in by_id][:10],
|
|
329
335
|
}
|
|
336
|
+
return out
|
|
330
337
|
|
|
331
338
|
|
|
332
339
|
def reference(directory='corpus'):
|