jsonout parameter now dumps to stdout instead of file.
This commit is contained in:
parent
a6ab6cdcf1
commit
132a264d8a
|
@ -144,8 +144,8 @@ if __name__ == '__main__':
|
||||||
''')
|
''')
|
||||||
parser.add_argument('--suppress_rom', help='Do not create an output rom file.', action='store_true')
|
parser.add_argument('--suppress_rom', help='Do not create an output rom file.', action='store_true')
|
||||||
parser.add_argument('--gui', help='Launch the GUI', action='store_true')
|
parser.add_argument('--gui', help='Launch the GUI', action='store_true')
|
||||||
parser.add_argument('--jsonout', help='''\
|
parser.add_argument('--jsonout', action='store_true', help='''\
|
||||||
Output .json patch file instead of a patched rom. Used
|
Output .json patch to stdout instead of a patched rom. Used
|
||||||
for VT site integration, do not use otherwise.
|
for VT site integration, do not use otherwise.
|
||||||
''')
|
''')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -154,9 +154,12 @@ if __name__ == '__main__':
|
||||||
if not args.jsonout and not os.path.isfile(args.rom):
|
if not args.jsonout and not os.path.isfile(args.rom):
|
||||||
input('Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom)
|
input('Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom)
|
||||||
exit(1)
|
exit(1)
|
||||||
if args.sprite is not None and not os.path.isfile(args.rom):
|
if args.sprite is not None and not os.path.isfile(args.sprite):
|
||||||
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite)
|
if not args.jsonout:
|
||||||
exit(1)
|
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite)
|
||||||
|
exit(1)
|
||||||
|
else:
|
||||||
|
raise IOError('Cannot find sprite file at %s' % args.sprite)
|
||||||
|
|
||||||
# set up logger
|
# set up logger
|
||||||
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel]
|
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel]
|
||||||
|
|
8
Main.py
8
Main.py
|
@ -8,6 +8,7 @@ from Items import ItemFactory
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
|
|
||||||
__version__ = '0.4.2-dev'
|
__version__ = '0.4.2-dev'
|
||||||
|
|
||||||
|
@ -92,9 +93,12 @@ def main(args, seed=None):
|
||||||
else:
|
else:
|
||||||
rom = LocalRom(args.rom)
|
rom = LocalRom(args.rom)
|
||||||
patch_rom(world, rom, bytearray(logic_hash), args.quickswap, args.heartbeep, sprite)
|
patch_rom(world, rom, bytearray(logic_hash), args.quickswap, args.heartbeep, sprite)
|
||||||
rom.write_to_file(args.jsonout or '%s.sfc' % outfilebase)
|
if args.jsonout:
|
||||||
|
print(json.dumps({'patch': rom.patches, 'spoiler': world.spoiler}))
|
||||||
|
else:
|
||||||
|
rom.write_to_file(args.jsonout or '%s.sfc' % outfilebase)
|
||||||
|
|
||||||
if args.create_spoiler:
|
if args.create_spoiler and not args.jsonout:
|
||||||
with open('%s_Spoiler.txt' % outfilebase, 'w') as outfile:
|
with open('%s_Spoiler.txt' % outfilebase, 'w') as outfile:
|
||||||
outfile.write(world.spoiler)
|
outfile.write(world.spoiler)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue