pyjmap 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyjmap/__init__.py +4 -0
- pyjmap/__main__.py +58 -0
- pyjmap/jmap.py +997 -0
- pyjmap/lookup_donkeykongjunglebeat.txt +81 -0
- pyjmap/lookup_luigismansion.txt +133 -0
- pyjmap/lookup_supermariogalaxy.txt +1470 -0
- pyjmap/lookup_supermariosunshine.txt +3 -0
- pyjmap-1.1.0.dist-info/METADATA +171 -0
- pyjmap-1.1.0.dist-info/RECORD +13 -0
- pyjmap-1.1.0.dist-info/WHEEL +5 -0
- pyjmap-1.1.0.dist-info/entry_points.txt +2 -0
- pyjmap-1.1.0.dist-info/licenses/LICENSE +674 -0
- pyjmap-1.1.0.dist-info/top_level.txt +1 -0
pyjmap/__init__.py
ADDED
pyjmap/__main__.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from . import jmap
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
LOOKUP_TABLES = {
|
|
6
|
+
"smg": jmap.SuperMarioGalaxyHashTable,
|
|
7
|
+
"sms": jmap.SuperMarioSunshineHashTable,
|
|
8
|
+
"dkjb": jmap.JungleBeatHashTable,
|
|
9
|
+
"lm": jmap.LuigisMansionHashTable
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def dump(args):
|
|
14
|
+
jmap_enc = args.jmap_encoding if args.jmap_encoding else "shift_jisx0213"
|
|
15
|
+
csv_enc = args.csv_encoding if args.csv_encoding else "utf-8"
|
|
16
|
+
|
|
17
|
+
data = jmap.from_file(LOOKUP_TABLES[args.lookup](), args.jmap, not args.little_endian, jmap_enc)
|
|
18
|
+
jmap.dump_csv(data, args.csv, csv_enc)
|
|
19
|
+
print("Successfully dumped data to CSV file.")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def pack(args):
|
|
23
|
+
jmap_enc = args.jmap_encoding if args.jmap_encoding else "shift_jisx0213"
|
|
24
|
+
csv_enc = args.csv_encoding if args.csv_encoding else "utf-8"
|
|
25
|
+
|
|
26
|
+
data = jmap.from_csv(LOOKUP_TABLES[args.lookup](), args.csv, csv_enc)
|
|
27
|
+
jmap.write_file(data, args.jmap, not args.little_endian, jmap_enc)
|
|
28
|
+
print("Successfully packed JMap data.")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def main():
|
|
32
|
+
parser = argparse.ArgumentParser(description="")
|
|
33
|
+
subs = parser.add_subparsers(dest="command", help="Command")
|
|
34
|
+
subs.required = True
|
|
35
|
+
|
|
36
|
+
dump_parser = subs.add_parser("tocsv", description="Dump JMap data to CSV file.")
|
|
37
|
+
pack_parser = subs.add_parser("tojmap", description="Pack CSV file as JMap data.")
|
|
38
|
+
|
|
39
|
+
for sub_parser in [dump_parser, pack_parser]:
|
|
40
|
+
sub_parser.add_argument("-le", "--little_endian", action="store_true", help="Data is little-endian?")
|
|
41
|
+
sub_parser.add_argument("-jmapenc", "--jmap_encoding", help="JMap file encoding. Default is shift_jisx0213."),
|
|
42
|
+
sub_parser.add_argument("-csvenc", "--csv_encoding", help="CSV file encoding. Default is utf-8"),
|
|
43
|
+
sub_parser.add_argument("lookup", choices=["smg", "dkjb", "sms", "lm"], help="The hash lookup table to use.")
|
|
44
|
+
|
|
45
|
+
dump_parser.add_argument("jmap", help="Path to JMap data.")
|
|
46
|
+
dump_parser.add_argument("csv", help="Path to CSV file.")
|
|
47
|
+
dump_parser.set_defaults(func=dump)
|
|
48
|
+
|
|
49
|
+
pack_parser.add_argument("csv", help="Path to CSV file.")
|
|
50
|
+
pack_parser.add_argument("jmap", help="Path to JMap data.")
|
|
51
|
+
pack_parser.set_defaults(func=pack)
|
|
52
|
+
|
|
53
|
+
args = parser.parse_args()
|
|
54
|
+
args.func(args)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
main()
|