Created
December 14, 2017 12:40
-
-
Save taotao54321/539af02aedab5bef2dc8ae9e18bb2789 to your computer and use it in GitHub Desktop.
Helps to create .tbl files
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
"""Helps to create .tbl files | |
Write "game.in": | |
0x30 | |
あいうえお | |
かきくけこ | |
... | |
Run: | |
$ tblhelper game.in | |
Output: | |
30=あ | |
31=い | |
32=う | |
... | |
""" | |
import fileinput | |
def chomp(s): | |
return s.rstrip("\r\n") | |
def main(): | |
code = None | |
for line in map(chomp, fileinput.input()): | |
if fileinput.isfirstline(): | |
code = int(line, base=0) | |
continue | |
for c in line: | |
print(f"{code:02X}={c}") | |
code += 1 | |
if __name__ == "__main__": main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment