Created
June 14, 2016 17:18
-
-
Save phase/2be7228daa6923464ca225ee5b6c4e53 to your computer and use it in GitHub Desktop.
regex stuff
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
| 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