Skip to content

Instantly share code, notes, and snippets.

@namuan
Created November 14, 2019 21:17
Show Gist options
  • Save namuan/2f646860725e2354af837e04eb9608bd to your computer and use it in GitHub Desktop.
Save namuan/2f646860725e2354af837e04eb9608bd to your computer and use it in GitHub Desktop.
Python one liner to extract and transform Spring HttpStatus enums
curl -s https://raw.githubusercontent.com/spring-projects/spring-framework/master/spring-web/src/main/java/org/springframework/http/HttpStatus.java | \
grep '\".*),' | \
while read line; \
do echo $line | python -c 'import re,sys; s, c, m = re.search("([\w\_]+)\((\d+),\s+\"([\w\s]+)", sys.stdin.readline()).groups(); print("{}: (\"HttpStatus.{}\", \"{}\"),".format(c, s, m))'; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment