@kinti/a11y-toolkit 5.26.0 → 5.27.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/README.md +1 -1
- package/a11y_toolkit/a11y.py +27 -4
- package/a11y_toolkit/a11yact.py +9 -1
- package/a11y_toolkit/a11yannotate.py +185 -0
- package/a11y_toolkit/a11yaudit.py +853 -193
- package/a11y_toolkit/a11ybadge.py +24 -17
- package/a11y_toolkit/a11ybudget.py +145 -1
- package/a11y_toolkit/a11ycorpus.py +58 -24
- package/a11y_toolkit/a11ycrit.py +110 -53
- package/a11y_toolkit/a11ydiff.py +104 -34
- package/a11y_toolkit/a11ydisprove.py +15 -8
- package/a11y_toolkit/a11ydocx.py +8 -6
- package/a11y_toolkit/a11ydom.py +425 -95
- package/a11y_toolkit/a11yen301549.py +53 -1
- package/a11y_toolkit/a11yengines.py +157 -0
- package/a11y_toolkit/a11yevidence.py +81 -33
- package/a11y_toolkit/a11yfix.py +131 -52
- package/a11y_toolkit/a11yinit.py +30 -5
- package/a11y_toolkit/a11yjourney.py +110 -4
- package/a11y_toolkit/a11yledger.py +119 -12
- package/a11y_toolkit/a11ylocate.py +247 -0
- package/a11y_toolkit/a11yopenacr.py +10 -3
- package/a11y_toolkit/a11ypatches.py +154 -0
- package/a11y_toolkit/a11ypatterns.py +344 -0
- package/a11y_toolkit/a11ypdf.py +109 -53
- package/a11y_toolkit/a11yrgaa.py +60 -0
- package/a11y_toolkit/a11yroute.py +34 -12
- package/a11y_toolkit/a11ysarif.py +45 -18
- package/a11y_toolkit/a11yscope.py +67 -15
- package/a11y_toolkit/a11yscroll.py +7 -5
- package/a11y_toolkit/a11ystatement.py +30 -6
- package/a11y_toolkit/a11ytrace.py +293 -0
- package/a11y_toolkit/a11yvalidate.py +21 -15
- package/a11y_toolkit/a11yvpat.py +34 -7
- package/a11y_toolkit/a11yvtt.py +22 -6
- package/a11y_toolkit/a11ywiz.py +121 -0
- package/a11y_toolkit/contrast.py +62 -24
- package/a11y_toolkit/locales/en.json +177 -20
- package/a11y_toolkit/locales/es.json +178 -21
- package/a11y_toolkit/rgaa.json +2661 -0
- package/a11y_toolkit/server.py +149 -50
- package/package.json +2 -2
- package/a11y_toolkit/a11yplan.py +0 -214
- package/a11y_toolkit/a11ywcagem.py +0 -237
|
@@ -105,8 +105,12 @@ ROUTES = [
|
|
|
105
105
|
'cli': 'a11ytoolkit kbd https://…',
|
|
106
106
|
'prompts': []},
|
|
107
107
|
{'id': 'statement',
|
|
108
|
+
# 'document' lives HERE, not in the pdf route: the English verb ("document
|
|
109
|
+
# the accessibility of my site") is a statement goal; pdf keywords stay
|
|
110
|
+
# unambiguous (pdf/docx/word/'documento')
|
|
108
111
|
'patterns': ['statement', 'declaración', 'declaracion', 'eaa', 'ley',
|
|
109
|
-
'legal', 'rd 1112', 'acta', '11/2023', 'compliance doc'
|
|
112
|
+
'legal', 'rd 1112', 'acta', '11/2023', 'compliance doc',
|
|
113
|
+
'document'],
|
|
110
114
|
'tools': [
|
|
111
115
|
('a11y_audit_url', 'los hallazgos alimentan la lista de contenido no accesible',
|
|
112
116
|
'findings feed the non-accessible content list'),
|
|
@@ -142,7 +146,7 @@ ROUTES = [
|
|
|
142
146
|
'cli': 'a11ytoolkit vpat pack.json --product "Acme" -o vpat.html',
|
|
143
147
|
'prompts': []},
|
|
144
148
|
{'id': 'media',
|
|
145
|
-
'patterns': ['video', 'caption', 'subtítulo', 'subtitulo',
|
|
149
|
+
'patterns': ['video', 'caption', 'subtítulo', 'subtitulo',
|
|
146
150
|
'vtt', 'audio description', 'audiodescripción', 'podcast'],
|
|
147
151
|
'tools': [
|
|
148
152
|
('a11y_vtt_check', 'el CONTENIDO de los subtítulos: cps, solapes, cobertura',
|
|
@@ -152,7 +156,7 @@ ROUTES = [
|
|
|
152
156
|
],
|
|
153
157
|
'cli': None, 'prompts': []},
|
|
154
158
|
{'id': 'pdf',
|
|
155
|
-
'patterns': ['pdf', 'documento', '
|
|
159
|
+
'patterns': ['pdf', 'documento', 'docx', 'word', 'informe pdf'],
|
|
156
160
|
'tools': [
|
|
157
161
|
('a11y_audit_pdf', 'cribado estructural + formularios: lo que nadie automatiza',
|
|
158
162
|
'structural screening + forms: what nobody automates'),
|
|
@@ -233,39 +237,55 @@ _NOTE = {
|
|
|
233
237
|
# ── diagnóstico secuencial: la EVIDENCIA manda, la severidad solo desempata ──
|
|
234
238
|
# Traducción cruzada del diagnóstico diferencial (medicina): primero la
|
|
235
239
|
# constante vital barata —el pase estático— y sus síntomas deciden qué
|
|
236
|
-
# examen reduce más la
|
|
240
|
+
# examen reduce más la incertumbre. No es una prioridad fija de criterios:
|
|
237
241
|
# una página sin formularios no necesita el examen de formularios por muy
|
|
238
242
|
# grave que sea 3.3.1 sobre el papel. detect() devuelve None (síntoma
|
|
239
|
-
# ausente) o la evidencia
|
|
243
|
+
# ausente) o el dato crudo; la línea de evidencia se redacta por idioma
|
|
244
|
+
# con _DIAG_EV (antes llegaba siempre en inglés, también con lang='es').
|
|
240
245
|
_DIAG = [
|
|
241
246
|
{'id': 'forms', 'severity': 'high', 'tool': 'a11y_forms',
|
|
242
247
|
# ojo: sin \b dentro de las llaves del f-string (barra invertida DENTRO
|
|
243
248
|
# de llaves es SyntaxError antes de 3.12; el guardián de test_solido lo
|
|
244
249
|
# vigila) — la detección con \b vive en el re.search de fuera
|
|
245
|
-
'detect': lambda h: (
|
|
250
|
+
'detect': lambda h: (len(re.findall(r"<(?:input|select|textarea)", h))
|
|
246
251
|
if re.search(r'<(?:input|select|textarea)\b', h) else None),
|
|
247
252
|
'why': ('formularios presentes: rellenar inválido, enviar y juzgar el aviso de errores',
|
|
248
253
|
'forms present: fill invalid data, submit, judge the error announcement')},
|
|
249
254
|
{'id': 'menus', 'severity': 'high', 'tool': 'a11y_keyboard',
|
|
250
|
-
'detect': lambda h: (
|
|
255
|
+
'detect': lambda h: (True
|
|
251
256
|
if re.search(r'<(?:nav|details)\b|aria-expanded', h) else None),
|
|
252
257
|
'why': ('menús o desplegables: la zona clásica de trampas de teclado',
|
|
253
258
|
'menus or disclosure widgets: the classic keyboard-trap zone')},
|
|
254
259
|
{'id': 'video', 'severity': 'medium', 'tool': 'a11y_vtt_check',
|
|
255
|
-
'detect': lambda h: (
|
|
260
|
+
'detect': lambda h: (h.count('<video') if '<video' in h else None),
|
|
256
261
|
'why': ('vídeo presente: que existan subtítulos no basta — juzgar su CONTENIDO',
|
|
257
262
|
'video present: captions existing is not enough — judge their CONTENT')},
|
|
258
263
|
{'id': 'animation', 'severity': 'medium', 'tool': 'a11y_reduced_motion',
|
|
259
|
-
'detect': lambda h: (
|
|
264
|
+
'detect': lambda h: (True
|
|
260
265
|
if re.search(r'animation|transition|<marquee', h) else None),
|
|
261
266
|
'why': ('contenido animado: ¿respeta prefers-reduced-motion?',
|
|
262
267
|
'animated content: does it honor prefers-reduced-motion?')},
|
|
263
268
|
{'id': 'svg', 'severity': 'low', 'tool': 'a11y_forced_colors',
|
|
264
|
-
'detect': lambda h: (
|
|
269
|
+
'detect': lambda h: (h.count('<svg') if h.count('<svg') >= 2 else None),
|
|
265
270
|
'why': ('iconografía SVG en volumen: los fills fijos caen en forced-colors',
|
|
266
271
|
'SVG iconography at volume: hardcoded fills fall in forced-colors')},
|
|
267
272
|
]
|
|
268
273
|
|
|
274
|
+
# evidencia por síntoma e idioma: {n} recibe el dato crudo de detect()
|
|
275
|
+
_DIAG_EV = {
|
|
276
|
+
'forms': {'es': '{n} campos de formulario', 'en': '{n} form fields'},
|
|
277
|
+
'menus': {'es': 'menús o desplegables', 'en': 'menus or disclosure widgets'},
|
|
278
|
+
'video': {'es': '{n} <video>', 'en': '{n} <video>'},
|
|
279
|
+
'animation': {'es': 'contenido animado', 'en': 'animated content'},
|
|
280
|
+
'svg': {'es': '{n} <svg> inline', 'en': '{n} inline <svg>'},
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def _evidence(sid, raw, lang):
|
|
285
|
+
"""La línea de evidencia de un síntoma, en el idioma pedido."""
|
|
286
|
+
tpl = _DIAG_EV[sid]['es' if lang == 'es' else 'en']
|
|
287
|
+
return tpl.format(n=raw) if isinstance(raw, int) else tpl
|
|
288
|
+
|
|
269
289
|
_RANK = {'high': 0, 'medium': 1, 'low': 2}
|
|
270
290
|
|
|
271
291
|
_GUARANTEE = {
|
|
@@ -291,7 +311,8 @@ def diagnose(html_text, url='(html)', lang='en', goal=None):
|
|
|
291
311
|
for d in _DIAG:
|
|
292
312
|
ev = d['detect'](html_text)
|
|
293
313
|
if ev:
|
|
294
|
-
symptoms.append({'symptom': d['id'],
|
|
314
|
+
symptoms.append({'symptom': d['id'],
|
|
315
|
+
'evidence': _evidence(d['id'], ev, t)})
|
|
295
316
|
hit.append(d)
|
|
296
317
|
# sort estable: severidad como desempate, orden de tabla dentro de cada nivel
|
|
297
318
|
hit.sort(key=lambda d: _RANK[d['severity']])
|
|
@@ -301,7 +322,8 @@ def diagnose(html_text, url='(html)', lang='en', goal=None):
|
|
|
301
322
|
evidences = {d['id']: d['detect'](html_text) for d in _DIAG}
|
|
302
323
|
for i, d in enumerate(hit, 2):
|
|
303
324
|
steps.append({'step': i, 'tool': d['tool'], 'why': d['why'][idx],
|
|
304
|
-
'symptom': d['id'],
|
|
325
|
+
'symptom': d['id'],
|
|
326
|
+
'evidence': _evidence(d['id'], evidences[d['id']], t)})
|
|
305
327
|
steps.append({'step': len(steps) + 1, 'tool': 'a11y_audit_dom',
|
|
306
328
|
'why': ('profundizar lo que el estático no ve: contraste computado, 2.5.8, foco',
|
|
307
329
|
'deepen what static cannot see: computed contrast, 2.5.8, focus')[idx]})
|
|
@@ -17,6 +17,7 @@ CLI:
|
|
|
17
17
|
import argparse
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
|
+
from .a11yact import _NOT_DEAD
|
|
20
21
|
from .a11yaudit import normalize_signal # noqa: E402 (compat 5.10)
|
|
21
22
|
import sys
|
|
22
23
|
|
|
@@ -55,28 +56,48 @@ def _help_uri(criterion_text):
|
|
|
55
56
|
return _BASE + slug if slug else 'https://www.w3.org/TR/WCAG22/'
|
|
56
57
|
|
|
57
58
|
|
|
58
|
-
def from_report(report, driver_version=
|
|
59
|
+
def from_report(report, driver_version=None, standard=None, target=None):
|
|
59
60
|
"""Informe(s) del auditor → dict SARIF 2.1.0.
|
|
60
61
|
|
|
61
62
|
Acepta un informe individual (audit_html/audit_url) o uno 'site'
|
|
62
63
|
(con la lista 'reports'). Con standard='en301549' cada regla gana
|
|
63
64
|
properties/tags con su cláusula EN 301 549 V4.1.1 (9.x web por defecto,
|
|
64
65
|
10.x documents, 11.x software) — filtrable en code scanning."""
|
|
66
|
+
if driver_version is None:
|
|
67
|
+
# versión del driver = fuente única (estaba congelada en '3.2.0' con el
|
|
68
|
+
# motor en 5.26: GitHub mostraba una versión muerta en code scanning)
|
|
69
|
+
from .server import VERSION as _V # lazy: server importa este módulo
|
|
70
|
+
driver_version = _V
|
|
65
71
|
from . import a11yen301549 as _enstd
|
|
66
|
-
pages = report.get('reports') if 'reports'
|
|
72
|
+
pages = report.get('reports') if isinstance(report.get('reports'), list) else [report]
|
|
67
73
|
rules = {}
|
|
68
74
|
results = []
|
|
75
|
+
skipped = 0 # hallazgos truncados/hostiles: se saltan, jamás un KeyError
|
|
69
76
|
_tgt = target or _enstd.target_for_mode(report.get('mode', 'static'))
|
|
70
77
|
for pg in pages:
|
|
78
|
+
if not isinstance(pg, dict):
|
|
79
|
+
skipped += 1
|
|
80
|
+
continue
|
|
71
81
|
url = pg.get('url', '(html)')
|
|
72
|
-
for h in pg.get('findings', []):
|
|
73
|
-
|
|
82
|
+
for h in pg.get('findings', []) or []:
|
|
83
|
+
if not isinstance(h, dict):
|
|
84
|
+
skipped += 1
|
|
85
|
+
continue
|
|
86
|
+
if h.get('status') in _NOT_DEAD or h.get('disprover_status') in _NOT_DEAD:
|
|
87
|
+
# hallazgo muerto (disprover rejected / not-rechecked): no es
|
|
88
|
+
# evidencia y no navega a GitHub como alerta viva
|
|
89
|
+
continue
|
|
90
|
+
crit, issue = h.get('criterion'), h.get('issue')
|
|
91
|
+
if not isinstance(crit, str) or not isinstance(issue, str):
|
|
92
|
+
skipped += 1
|
|
93
|
+
continue # --from-audit hostil/truncado: degradar, no caer
|
|
94
|
+
code = crit.split(' ')[0]
|
|
74
95
|
rule_id = f'WCAG-{code}-{normalize_signal(h.get("signal", ""))}'
|
|
75
96
|
if rule_id not in rules:
|
|
76
97
|
rule = {
|
|
77
98
|
'id': rule_id,
|
|
78
|
-
'shortDescription': {'text':
|
|
79
|
-
'helpUri': _help_uri(
|
|
99
|
+
'shortDescription': {'text': crit},
|
|
100
|
+
'helpUri': _help_uri(crit),
|
|
80
101
|
}
|
|
81
102
|
# target explícito = mandato del usuario: recalcula SIEMPRE
|
|
82
103
|
# (las cláusulas embebidas pueden ser de otro target); sin
|
|
@@ -90,12 +111,12 @@ def from_report(report, driver_version='3.2.0', standard=None, target=None):
|
|
|
90
111
|
'tags': [f'en301549:{clause}', 'wcag22:' + code],
|
|
91
112
|
}
|
|
92
113
|
rules[rule_id] = rule
|
|
93
|
-
message =
|
|
114
|
+
message = issue
|
|
94
115
|
if h.get('remediation'):
|
|
95
|
-
message += ' — Fix: ' + h['remediation']
|
|
116
|
+
message += ' — Fix: ' + str(h['remediation'])
|
|
96
117
|
results.append({
|
|
97
118
|
'ruleId': rule_id,
|
|
98
|
-
'level': LEVEL.get(h
|
|
119
|
+
'level': LEVEL.get(h.get('severity'), 'note'),
|
|
99
120
|
'message': {'text': message},
|
|
100
121
|
'locations': [{
|
|
101
122
|
'physicalLocation': {
|
|
@@ -103,18 +124,22 @@ def from_report(report, driver_version='3.2.0', standard=None, target=None):
|
|
|
103
124
|
},
|
|
104
125
|
}],
|
|
105
126
|
})
|
|
127
|
+
run = {
|
|
128
|
+
'tool': {'driver': {
|
|
129
|
+
'name': 'a11y-toolkit',
|
|
130
|
+
'version': driver_version,
|
|
131
|
+
'informationUri': 'https://github.com/kinti/a11y-toolkit',
|
|
132
|
+
'rules': sorted(rules.values(), key=lambda r: r['id']),
|
|
133
|
+
}},
|
|
134
|
+
'results': results,
|
|
135
|
+
}
|
|
136
|
+
if skipped:
|
|
137
|
+
# exportación degradada, no silenciada: lo saltado queda contado
|
|
138
|
+
run['properties'] = {'skippedFindings': skipped}
|
|
106
139
|
return {
|
|
107
140
|
'$schema': 'https://json.schemastore.org/sarif-2.1.0.json',
|
|
108
141
|
'version': '2.1.0',
|
|
109
|
-
'runs': [
|
|
110
|
-
'tool': {'driver': {
|
|
111
|
-
'name': 'a11y-toolkit',
|
|
112
|
-
'version': driver_version,
|
|
113
|
-
'informationUri': 'https://github.com/kinti/a11y-toolkit',
|
|
114
|
-
'rules': sorted(rules.values(), key=lambda r: r['id']),
|
|
115
|
-
}},
|
|
116
|
-
'results': results,
|
|
117
|
-
}],
|
|
142
|
+
'runs': [run],
|
|
118
143
|
}
|
|
119
144
|
|
|
120
145
|
|
|
@@ -152,6 +177,8 @@ def main(argv):
|
|
|
152
177
|
summary = report.get('summary', {'high': 0, 'medium': 0, 'low': 0})
|
|
153
178
|
print(json.dumps({'sarif': a.out,
|
|
154
179
|
'results': len(sarif['runs'][0]['results']),
|
|
180
|
+
'skipped': sarif['runs'][0].get('properties', {})
|
|
181
|
+
.get('skippedFindings', 0),
|
|
155
182
|
'score': report.get('score'),
|
|
156
183
|
'summary': summary}))
|
|
157
184
|
return 0
|
|
@@ -32,7 +32,7 @@ import json
|
|
|
32
32
|
import sys
|
|
33
33
|
from datetime import datetime, timezone
|
|
34
34
|
|
|
35
|
-
STANDARDS = ('wcag22', 'en301549')
|
|
35
|
+
STANDARDS = ('wcag22', 'en301549', 'rgaa') # 508 GSA tree: capa privada pro
|
|
36
36
|
STATUS_ORDER = ('in-scope', 'proposed-excluded', 'excluded')
|
|
37
37
|
|
|
38
38
|
# Criterios cuya aplicabilidad depende de un rasgo ESTRUCTURAL detectable:
|
|
@@ -100,7 +100,7 @@ def _forms_present(feats, findings_codes):
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
def build_scope(reports, standard='wcag22', target='web', answers=None,
|
|
103
|
-
lang='en'):
|
|
103
|
+
lang='en', targets=None):
|
|
104
104
|
"""Informes (lista de dicts) + respuestas humanas → alcance a11y-scope/1."""
|
|
105
105
|
if standard not in STANDARDS:
|
|
106
106
|
raise ValueError(f"standard must be one of {STANDARDS}, got {standard!r}")
|
|
@@ -109,6 +109,10 @@ def build_scope(reports, standard='wcag22', target='web', answers=None,
|
|
|
109
109
|
from .a11ycrit import _C
|
|
110
110
|
tx = pack(lang).get('scope', {}) or {}
|
|
111
111
|
|
|
112
|
+
if targets:
|
|
113
|
+
targets = [x for x in targets if x in ('web', 'documents', 'software')] or [target]
|
|
114
|
+
else:
|
|
115
|
+
targets = [target]
|
|
112
116
|
reports = [r for r in reports if isinstance(r, dict)]
|
|
113
117
|
findings_codes = set()
|
|
114
118
|
for rep in reports:
|
|
@@ -136,7 +140,9 @@ def build_scope(reports, standard='wcag22', target='web', answers=None,
|
|
|
136
140
|
name = (_C[code][1].get(lang) or _C[code][1]['en'])[0]
|
|
137
141
|
row = {'criterion': f'{code} {name}', 'level': _C[code][0]}
|
|
138
142
|
if standard == 'en301549':
|
|
139
|
-
row['clause'] = enstd.clause_for(code,
|
|
143
|
+
row['clause'] = enstd.clause_for(code, targets[0])
|
|
144
|
+
if len(targets) > 1:
|
|
145
|
+
row['clauses'] = {tg: enstd.clause_for(code, tg) for tg in targets}
|
|
140
146
|
|
|
141
147
|
ans = answers.get(code)
|
|
142
148
|
if isinstance(ans, str): # abreviatura: "excluded"/"in-scope"
|
|
@@ -171,6 +177,32 @@ def build_scope(reports, standard='wcag22', target='web', answers=None,
|
|
|
171
177
|
row['evidence'] = tx.get('evidence_forms_present')
|
|
172
178
|
criteria.append(row)
|
|
173
179
|
|
|
180
|
+
if standard == 'rgaa':
|
|
181
|
+
from . import a11yrgaa
|
|
182
|
+
criteria = [{'criterion': c['num'] + ' ' + c['title'],
|
|
183
|
+
'status': 'in-scope'} for c in a11yrgaa.CRITERIA]
|
|
184
|
+
# las respuestas humanas también aplican a RGAA (antes se descartaban:
|
|
185
|
+
# counters.excluded siempre 0). La máquina NUNCA propone en rgaa —
|
|
186
|
+
# solo una respuesta humana mueve filas. La clave puede venir como el
|
|
187
|
+
# num exacto ('1.1') o con cola de test ('1.1.1'): el num de la fila
|
|
188
|
+
# es el prefijo — el match con separador evita 1.1 vs 1.10.
|
|
189
|
+
for key, ans in answers.items():
|
|
190
|
+
if not isinstance(key, str):
|
|
191
|
+
continue
|
|
192
|
+
a = {'status': ans} if isinstance(ans, str) else (
|
|
193
|
+
ans if isinstance(ans, dict) else None)
|
|
194
|
+
if not a or a.get('status') not in STATUS_ORDER:
|
|
195
|
+
continue
|
|
196
|
+
for row in criteria:
|
|
197
|
+
num = row['criterion'].split(' ')[0]
|
|
198
|
+
if key == num or key.startswith(num + '.'):
|
|
199
|
+
row['status'] = a['status']
|
|
200
|
+
row['evidence_source'] = 'human'
|
|
201
|
+
if a.get('reason'):
|
|
202
|
+
row['reason'] = str(a['reason'])[:500]
|
|
203
|
+
|
|
204
|
+
std508_block = None # 508 GSA tree: moved to the private pro layer
|
|
205
|
+
|
|
174
206
|
counters = {
|
|
175
207
|
'criteria': len(criteria),
|
|
176
208
|
'in_scope': sum(1 for r in criteria if r['status'] == 'in-scope'),
|
|
@@ -184,11 +216,14 @@ def build_scope(reports, standard='wcag22', target='web', answers=None,
|
|
|
184
216
|
counters['en_clauses_applicable'] = counters['in_scope'] + counters['excluded']
|
|
185
217
|
|
|
186
218
|
scope = {
|
|
219
|
+
'section508': std508_block,
|
|
187
220
|
'format': 'a11y-scope/1',
|
|
188
221
|
'lang': lang,
|
|
189
222
|
'generated': datetime.now(timezone.utc).isoformat(timespec='seconds'),
|
|
190
223
|
'tool': 'a11y-toolkit (github.com/kinti/a11y-toolkit)',
|
|
191
|
-
'standard': enstd.STANDARD_NAME if standard == 'en301549'
|
|
224
|
+
'standard': (enstd.STANDARD_NAME if standard == 'en301549'
|
|
225
|
+
else a11yrgaa.STANDARD_NAME if standard == 'rgaa'
|
|
226
|
+
else 'WCAG 2.2 (A/AA)'),
|
|
192
227
|
'target': target,
|
|
193
228
|
'features_observed': feats if features_seen else None,
|
|
194
229
|
'features_evidence': bool(features_seen),
|
|
@@ -201,16 +236,29 @@ def build_scope(reports, standard='wcag22', target='web', answers=None,
|
|
|
201
236
|
if standard == 'en301549':
|
|
202
237
|
fam_rows = []
|
|
203
238
|
for fam in enstd.family_rows(lang):
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
239
|
+
def _status_for(tg):
|
|
240
|
+
if fam['family'] == '12':
|
|
241
|
+
return 'in-scope'
|
|
242
|
+
if fam['family'] in ('6', '7', '8') and tg == 'web':
|
|
243
|
+
# un producto web no lleva RTT/transmisión de vídeo/hardware:
|
|
244
|
+
# propuesta de la MISMA lógica que usa el wizard oficial
|
|
245
|
+
return 'proposed-excluded'
|
|
246
|
+
return 'human-review'
|
|
247
|
+
status = _status_for(targets[0])
|
|
248
|
+
row_f = {**fam, 'status': status,
|
|
249
|
+
'evaluated_by_toolkit': False}
|
|
250
|
+
if len(targets) > 1:
|
|
251
|
+
row_f['status_per_target'] = {tg: _status_for(tg) for tg in targets}
|
|
252
|
+
fam_rows.append(row_f)
|
|
213
253
|
scope['en301549_families'] = fam_rows
|
|
254
|
+
if 'software' in targets:
|
|
255
|
+
# cláusulas EN-only de la cláusula 11 (11.5-11.7): aplicabilidad
|
|
256
|
+
# honesta que este motor NO evalúa — revisión humana, jamás una
|
|
257
|
+
# propuesta (la forma del producto NO las decide, a diferencia de
|
|
258
|
+
# 6/7/8 en web) y jamás un claim de conformidad
|
|
259
|
+
scope['en301549_software_clauses'] = [
|
|
260
|
+
{**row, 'status': 'human-review', 'evaluated_by_toolkit': False}
|
|
261
|
+
for row in enstd.software_clause_rows(lang)]
|
|
214
262
|
# el sello excluye el reloj: re-emitir el mismo alcance → mismo sha
|
|
215
263
|
scope['sha256'] = _sha256({k: v for k, v in scope.items() if k != 'generated'})
|
|
216
264
|
return scope
|
|
@@ -228,11 +276,15 @@ def main(argv):
|
|
|
228
276
|
'{"1.2.4": {"status": "excluded", "reason": "…"}}')
|
|
229
277
|
ap.add_argument('--lang', default='en', choices=('es', 'en'))
|
|
230
278
|
ap.add_argument('-o', '--out', default='scope.json')
|
|
279
|
+
ap.add_argument('--targets', default=None,
|
|
280
|
+
help='comma-separated ICT targets for combined scope (e.g. web,documents)')
|
|
281
|
+
# (--solicitation se retiró: el generador de anexos vive en a11y-toolkit-pro)
|
|
231
282
|
a = ap.parse_args(argv)
|
|
232
|
-
reports = [json.load(open(
|
|
283
|
+
reports = [json.load(open(r, encoding='utf-8')) for r in a.reports]
|
|
233
284
|
answers = json.load(open(a.answers, encoding='utf-8')) if a.answers else None
|
|
285
|
+
tgts = [t.strip() for t in a.targets.split(',')] if a.targets else None
|
|
234
286
|
scope = build_scope(reports, standard=a.standard, target=a.target,
|
|
235
|
-
answers=answers, lang=a.lang)
|
|
287
|
+
answers=answers, lang=a.lang, targets=tgts)
|
|
236
288
|
with open(a.out, 'w', encoding='utf-8') as f:
|
|
237
289
|
json.dump(scope, f, ensure_ascii=False, indent=1)
|
|
238
290
|
print(json.dumps({'scope': a.out, 'sha256': scope['sha256'],
|
|
@@ -78,13 +78,15 @@ def _add(findings, lang, sev, code, key, **fmt):
|
|
|
78
78
|
})
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
def audit_scroll(url, max_batches=5, lang='en', timeout=45, auth_state=None):
|
|
81
|
+
def audit_scroll(url, max_batches=5, lang='en', timeout=45, auth_state=None, browser='auto'):
|
|
82
82
|
from playwright.sync_api import sync_playwright
|
|
83
|
+
from .a11ydom import _get_browser
|
|
83
84
|
with sync_playwright() as p:
|
|
84
|
-
nav = p
|
|
85
|
+
nav = _get_browser(p, preferred=browser)
|
|
85
86
|
ctx = nav.new_context(storage_state=auth_state) if auth_state else nav
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
# BrowserContext.new_page() NO acepta viewport: va en el new_context
|
|
88
|
+
page = (ctx.new_page() if auth_state
|
|
89
|
+
else nav.new_page(viewport={'width': 1280, 'height': 800}))
|
|
88
90
|
try:
|
|
89
91
|
page.goto(url, wait_until='load', timeout=timeout * 1000)
|
|
90
92
|
page.wait_for_timeout(500)
|
|
@@ -205,7 +207,7 @@ def main(argv):
|
|
|
205
207
|
print(json.dumps({'error': 'Playwright not installed'}))
|
|
206
208
|
return 1
|
|
207
209
|
print(json.dumps(res, ensure_ascii=False, indent=1))
|
|
208
|
-
return 0
|
|
210
|
+
return 1 if 'error' in res else 0
|
|
209
211
|
|
|
210
212
|
|
|
211
213
|
if __name__ == '__main__':
|
|
@@ -13,6 +13,11 @@ Usage:
|
|
|
13
13
|
declaracion.py --entity "Name" --url "https://…" --status partial \
|
|
14
14
|
--inaccessible "…" --feedback "a@b.gal" [--framework rd1112|eaa] \
|
|
15
15
|
[--lang es|en] [--output decl.html]
|
|
16
|
+
|
|
17
|
+
FROZEN LAYER (2026-11-04, founder decision "freeze the docs"): this
|
|
18
|
+
module stays public as an HONEST DRAFT generator (the machine fills
|
|
19
|
+
Remarks/texts, never the claim). Maintenance fixes only; new
|
|
20
|
+
capabilities live in the SaaS (a11y.es / Lince).
|
|
16
21
|
"""
|
|
17
22
|
|
|
18
23
|
import argparse
|
|
@@ -50,9 +55,11 @@ def generate(entity, url, status, inaccessible_content=None, method=None,
|
|
|
50
55
|
return {'error': t['error_inconsistent']}
|
|
51
56
|
|
|
52
57
|
e = lambda s: html.escape(str(s), quote=True) # noqa: E731
|
|
58
|
+
today = TODAY() # una sola lectura del reloj: una ejecución que cruce la
|
|
59
|
+
# medianoche no puede fechar cuerpo y resumen con días distintos
|
|
53
60
|
status_title, status_text = STATES.get(lang, STATES['es'])[status]
|
|
54
|
-
evaluation_date = evaluation_date or
|
|
55
|
-
review_date = review_date or
|
|
61
|
+
evaluation_date = evaluation_date or today
|
|
62
|
+
review_date = review_date or today
|
|
56
63
|
method = method or t['method_default']
|
|
57
64
|
feedback = feedback or t['feedback_default']
|
|
58
65
|
|
|
@@ -75,6 +82,23 @@ def generate(entity, url, status, inaccessible_content=None, method=None,
|
|
|
75
82
|
<h2>{t['h_alt_access']}</h2>
|
|
76
83
|
<p>{e(alternative_format)}</p>'''
|
|
77
84
|
|
|
85
|
+
# RD 1112/2018 art. 10.1(b): el procedimiento de reclamación se ENLAZA,
|
|
86
|
+
# no queda en texto inerte — un valor http(s) se renderiza como <a>
|
|
87
|
+
# (escapado); el texto que no es URL se queda plano (también escapado).
|
|
88
|
+
# El canal de feedback recibe el MISMO trato (es un canal de contacto)
|
|
89
|
+
feedback_html = ''
|
|
90
|
+
if feedback:
|
|
91
|
+
esc_f = e(feedback)
|
|
92
|
+
feedback_html = (f'<a href="{esc_f}">{esc_f}</a>'
|
|
93
|
+
if str(feedback).lower().startswith(('http://', 'https://'))
|
|
94
|
+
else esc_f)
|
|
95
|
+
complaints_html = ''
|
|
96
|
+
if complaints:
|
|
97
|
+
esc_c = e(complaints)
|
|
98
|
+
complaints_html = (f'<a href="{esc_c}">{esc_c}</a>'
|
|
99
|
+
if str(complaints).lower().startswith(('http://', 'https://'))
|
|
100
|
+
else esc_c)
|
|
101
|
+
|
|
78
102
|
doc_title = t['title'][framework]
|
|
79
103
|
doc = f'''<!doctype html>
|
|
80
104
|
<html lang="{html.escape(str(lang), quote=True)}">
|
|
@@ -97,14 +121,14 @@ def generate(entity, url, status, inaccessible_content=None, method=None,
|
|
|
97
121
|
<h2>{t['h_preparation']}</h2>
|
|
98
122
|
<ul>
|
|
99
123
|
<li>{t['l_evaluation']}: <time datetime="{e(evaluation_date)}">{e(evaluation_date)}</time></li>
|
|
100
|
-
<li>{t['l_declared']} <time datetime="{e(
|
|
124
|
+
<li>{t['l_declared']} <time datetime="{e(today)}">{e(today)}</time></li>
|
|
101
125
|
<li>{t['l_method']}: {e(method)}</li>
|
|
102
126
|
<li>{t['l_review']}: <time datetime="{e(review_date)}">{e(review_date)}</time></li>
|
|
103
127
|
</ul>
|
|
104
128
|
|
|
105
129
|
<h2>{t['h_contact']}</h2>
|
|
106
|
-
<p>{t['contact'].format(f=
|
|
107
|
-
<p>{
|
|
130
|
+
<p>{t['contact'].format(f=feedback_html)}</p>
|
|
131
|
+
<p>{complaints_html if complaints else t['complaints'][framework]}</p>
|
|
108
132
|
{disalt}
|
|
109
133
|
</main>
|
|
110
134
|
</body>
|
|
@@ -116,7 +140,7 @@ def generate(entity, url, status, inaccessible_content=None, method=None,
|
|
|
116
140
|
'entity': entity, 'url': url, 'framework': framework, 'lang': lang,
|
|
117
141
|
'status': status_title,
|
|
118
142
|
'inaccessible_items': len(inaccessible_content),
|
|
119
|
-
'dates': {'evaluation': evaluation_date, 'declaration':
|
|
143
|
+
'dates': {'evaluation': evaluation_date, 'declaration': today,
|
|
120
144
|
'review': review_date},
|
|
121
145
|
},
|
|
122
146
|
}
|