1717for the ticket filed.
1818"""
1919
20+ import argparse
2021import sys
2122import sc2reader
2223import traceback
2324
2425sc2reader .log_utils .log_to_console ('INFO' )
2526
2627def main ():
27- for argument in sys .argv [1 :]:
28- for path in sc2reader .utils .get_files (argument ,extension = 'SC2Replay' ):
28+ parser = argparse .ArgumentParser (description = "Recursively parses replay files, inteded for debugging parse issues." )
29+ parser .add_argument ('--one_each' , help = "Attempt to parse only one replay for each release_string" , action = "store_true" )
30+ parser .add_argument ('folders' , metavar = 'folder' , type = str , nargs = '+' , help = "Path to a folder" )
31+ args = parser .parse_args ()
32+
33+ releases_parsed = set ()
34+ for folder in args .folders :
35+ print "dealing with {}" .format (folder )
36+ for path in sc2reader .utils .get_files (folder ,extension = 'SC2Replay' ):
2937 try :
30- replay = sc2reader .load_replay (path , debug = True , verbose = True )
38+ rs = sc2reader .load_replay (path , load_level = 0 ).release_string
39+ already_did = rs in releases_parsed
40+ releases_parsed .add (rs )
41+ if not args .one_each or not already_did :
42+ replay = sc2reader .load_replay (path , debug = True , verbose = True )
3143 except sc2reader .exceptions .ReadError as e :
3244 print
3345 print path
@@ -41,17 +53,25 @@ def main():
4153 except Exception as e :
4254 print
4355 print path
44- replay = sc2reader .load_replay (path , debug = True , load_level = 1 )
45- print '{build} - {real_type} on {map_name} - Played {start_time}' .format (** replay .__dict__ )
46- print '[ERROR]' , e .message
47- for pid , attributes in replay .attributes .items ():
48- print pid , attributes
49- for pid , info in enumerate (replay .raw_data ['replay.details' ].players ):
50- print pid , info
51- print replay .raw_data ['replay.initData' ].player_names
52- traceback .print_exc ()
53- print
56+ try :
57+ replay = sc2reader .load_replay (path , debug = True , load_level = 1 )
58+ print '{build} - {real_type} on {map_name} - Played {start_time}' .format (** replay .__dict__ )
59+ print '[ERROR]' , e .message
60+ for pid , attributes in replay .attributes .items ():
61+ print pid , attributes
62+ for pid , info in enumerate (replay .raw_data ['replay.details' ].players ):
63+ print pid , info
64+ print replay .raw_data ['replay.initData' ].player_names
65+ traceback .print_exc ()
66+ print
67+ except Exception as e2 :
68+ replay = sc2reader .load_replay (path , debug = True , load_level = 0 )
69+ print '[ERROR]' , e .message
70+ print '[ERROR]' , e2 .message
71+ traceback .print_exc ()
72+ print
73+
5474
5575
5676if __name__ == '__main__' :
57- main ()
77+ main ()
0 commit comments