17
17
for the ticket filed.
18
18
"""
19
19
20
+ import argparse
20
21
import sys
21
22
import sc2reader
22
23
import traceback
23
24
24
25
sc2reader .log_utils .log_to_console ('INFO' )
25
26
26
27
def 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' ):
29
37
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 )
31
43
except sc2reader .exceptions .ReadError as e :
32
44
print
33
45
print path
@@ -41,17 +53,25 @@ def main():
41
53
except Exception as e :
42
54
print
43
55
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
+
54
74
55
75
56
76
if __name__ == '__main__' :
57
- main ()
77
+ main ()
0 commit comments