-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map species IDs and form names as Showdown expects
- Loading branch information
1 parent
9614e26
commit 536f975
Showing
4 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pathlib | ||
import re | ||
|
||
def parse_national_dex_enum(fname: pathlib.Path) -> dict[str, int]: | ||
ENUM_ENTRY_PATTERN = re.compile(r'(NATIONAL_DEX_\w+),') | ||
enum_ctx = False | ||
national_dex = {} | ||
counter = 0 | ||
with open(fname, 'r', encoding='utf-8') as enum_file: | ||
for line in enum_file: | ||
line = line.strip() | ||
if enum_ctx: | ||
if line.startswith('};'): | ||
enum_ctx = False | ||
if national_dex: | ||
break | ||
|
||
match = ENUM_ENTRY_PATTERN.match(line) | ||
if match: | ||
national_dex[match.group(1)] = counter | ||
counter = counter + 1 | ||
|
||
elif line.startswith('enum'): | ||
enum_ctx = True | ||
|
||
return national_dex | ||
|
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