Created
February 24, 2025 15:19
-
-
Save apetenchea/86751442d0e1e02508c00e30e85f6ffa to your computer and use it in GitHub Desktop.
Create arango errno.py file for the python driver
This file contains 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
import requests | |
ARANGODB_ERRORS_FILE = "https://raw.githubusercontent.com/arangodb/arangodb/refs/heads/devel/lib/Basics/errors.dat" # noqa: E501 | |
def generate_section(line, output): | |
text = line[3:].strip() | |
print("#" * (len(text) + 4), file=output) | |
print(f"# {text} #", file=output) | |
print("#" * (len(text) + 4) + "\n", file=output) | |
def generate_error(line, output): | |
text = line.split(",") | |
err = text[0].strip()[6:] | |
if err.startswith("ARANGO_"): | |
err = err[7:] | |
code = text[1].strip() | |
cmt = text[2].strip('"') | |
print(f"# {cmt}\n{err} = {code}\n", file=output) | |
def main(): | |
response = requests.get(ARANGODB_ERRORS_FILE) | |
response.raise_for_status() | |
lines = response.text.splitlines() | |
with open("errno.py", "w") as output: | |
for idx, line in enumerate(lines): | |
if line.startswith("## ") and not lines[idx - 1].startswith("## "): | |
generate_section(line, output) | |
elif line.startswith("ERROR_"): | |
generate_error(line, output) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment