Skip to content

Instantly share code, notes, and snippets.

@captainGeech42
Created December 19, 2021 04:15
Show Gist options
  • Save captainGeech42/ba0e642ce2411143d272d673eb7c7081 to your computer and use it in GitHub Desktop.
Save captainGeech42/ba0e642ce2411143d272d673eb7c7081 to your computer and use it in GitHub Desktop.
Take all of the lines, remove leading/trailing whitespace and comments, and stick them in "in"
# https://github.com/miekg/dns/blob/master/types.go#L27
with open("in", "r") as f:
lines = [x.strip() for x in f.readlines()]
for l in lines:
parts = l.split("uint16 = ")
type = parts[0].strip()[4:]
val = parts[1]
print(f"{val}: \"{type}\",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment