(url)
| 35 | |
| 36 | |
| 37 | def parse_errors_txt(url): |
| 38 | classes = {} |
| 39 | errors = defaultdict(dict) |
| 40 | |
| 41 | page = urlopen(url) |
| 42 | for line in page.read().decode("ascii").splitlines(): |
| 43 | # Strip comments and skip blanks |
| 44 | |
| 45 | if not (line := line.split("#")[0].strip()): |
| 46 | continue |
| 47 | |
| 48 | # Parse a section |
| 49 | if m := re.match("Section: (Class (..) - .+)", line): |
| 50 | label, class_ = m.groups() |
| 51 | classes[class_] = label |
| 52 | continue |
| 53 | |
| 54 | # Parse an error |
| 55 | if m := re.match(r"(.....)\s+(?:E|W|S)\s+ERRCODE_(\S+)(?:\s+(\S+))?$", line): |
| 56 | sqlstate, macro, spec = m.groups() |
| 57 | # skip sqlstates without specs as they are not publicly visible |
| 58 | if not spec: |
| 59 | continue |
| 60 | errlabel = spec.upper() |
| 61 | errors[class_][sqlstate] = errlabel |
| 62 | continue |
| 63 | |
| 64 | # We don't expect anything else |
| 65 | raise ValueError("unexpected line:\n%s" % line) |
| 66 | |
| 67 | return classes, errors |
| 68 | |
| 69 | |
| 70 | def tag_from_version(version: str) -> str: |
no test coverage detected