Skip to content

Commit

Permalink
Push joiner script
Browse files Browse the repository at this point in the history
  • Loading branch information
BernardoGiordano committed Mar 7, 2019
1 parent 17060ac commit c6a1c22
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
36 changes: 36 additions & 0 deletions joiner.py
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())

0 comments on commit c6a1c22

Please sign in to comment.