Created
October 4, 2019 21:01
-
-
Save plavjanik/a0f50e61edc2e2419a161e8d736e86de to your computer and use it in GitHub Desktop.
Parser for ErrnoJr (errno2) codes (z/OS UNIX reason codes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pathlib import Path | |
| import re | |
| def main(): | |
| try: | |
| from BeautifulSoup import BeautifulSoup | |
| except ImportError: | |
| from bs4 import BeautifulSoup | |
| # ZosReasonCodes.html is a table in https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.bpxa800/errnojrs.htm | |
| html = Path("ZosReasonCodes.html").read_text() | |
| parsed = BeautifulSoup(html) | |
| for tr in parsed.body.find_all("tr"): | |
| tds = tr.find_all("td") | |
| if tds: | |
| code = tds[0].text | |
| text = tds[1].text | |
| p = tds[1].find("p") | |
| name = text.split()[0].strip().replace("Jr", "JR") | |
| explanation = re.sub('\s+', ' ', p.text).strip().strip(".") | |
| print(f'{name}("{name}", 0x{code.lower()}, "{explanation}"),') | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment