Skip to content

Instantly share code, notes, and snippets.

@phase
Created June 14, 2016 17:18
Show Gist options
  • Select an option

  • Save phase/2be7228daa6923464ca225ee5b6c4e53 to your computer and use it in GitHub Desktop.

Select an option

Save phase/2be7228daa6923464ca225ee5b6c4e53 to your computer and use it in GitHub Desktop.
regex stuff
import re
regex = ''' public static final BlockType (.*) = getByName\((.*)\);'''
pattern = re.compile(regex)
register_block_lines = []
fields = []
with open('src/main/java/org/fountainmc/api/BlockType.java') as f:
lines = f.readlines()
for line in lines:
if pattern.match(line):
register_block_lines.append(line.split("BlockType ")[1])
fields.append(line.split(" =")[0].replace(" final", "") + " = null;")
print("".join(register_block_lines))
print("\n".join(fields))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment