File: updateAlerts_rst.py

package info (click to toggle)
psychopy 2020.2.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 44,056 kB
  • sloc: python: 119,649; javascript: 3,022; makefile: 148; sh: 125; xml: 9
file content (35 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Build rst files appropriate for the **currently-installed** psychopy.alerts
"""
from pathlib import Path
from psychopy.alerts import catalog

thisFolder = Path(__file__).parent
alertDocsRoot = thisFolder / "source/alerts"

for ID in catalog.alert:
    alert = catalog.alert[ID]
    if 'label' in alert:
        label = alert['label']
    else:
        label = alert['synopsis']

    with open(alertDocsRoot / (str(ID)+'.rst'), 'w') as f:
        titleStr = f"{ID}: {label}\n"
        f.write(f"{ID}: {label}\n")
        f.write(f"="*len(titleStr) + "\n\n")
        if 'synopsis' in alert:
            f.write(f"Synopsis\n")
            f.write(f"-----------\n\n")
            f.write(alert["synopsis"] + "\n\n")
        if 'details' in alert:
            f.write(f"Details\n")
            f.write(f"-----------\n\n")
            f.write(alert["details"] + "\n\n")
        if 'versions' in alert:
            f.write(f"PsychoPy versions affected\n")
            f.write(f"---------------------------\n\n")
            f.write(alert["versions"] + "\n\n")
        if 'solutions' in alert:
            f.write(f"Solutions\n")
            f.write(f"-----------\n\n")
            f.write(alert["solutions"] + "\n\n")