forked from FlagBrew/Sharkive
-
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.
- Loading branch information
1 parent
17060ac
commit c6a1c22
Showing
2 changed files
with
37 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
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,36 @@ | ||
#!/usr/bin/python3 | ||
import argparse | ||
import os | ||
import json | ||
|
||
parser = argparse.ArgumentParser(description = 'Sharkive cheat codes joiner') | ||
parser.add_argument('type', help = '3ds, switch') | ||
|
||
def main(args): | ||
if '3ds' in args.type: | ||
cheats = os.listdir('./3ds') | ||
elif 'switch' in args.type: | ||
cheats = os.listdir('./switch') | ||
else: | ||
exit(0) | ||
|
||
db = {} | ||
for cheat in cheats: | ||
with open(os.path.join(args.type, cheat), 'r') as file: | ||
titleid = cheat[:cheat.rfind('.')] | ||
lines = [line.strip() for line in file] | ||
lines = list(filter(None, lines)) | ||
|
||
db[titleid] = {} | ||
selectedCheat = lines[0] | ||
for line in lines: | ||
if line.startswith('[') and line.endswith(']'): | ||
selectedCheat = line[1:-1] | ||
db[titleid][selectedCheat] = [] | ||
else: | ||
db[titleid][selectedCheat].append(line) | ||
with open(os.path.join('build', args.type + '.json'), 'w') as f: | ||
f.write(json.dumps(db, indent = 2)) | ||
|
||
if __name__ == '__main__': | ||
main(parser.parse_args()) |