@@ -43,10 +43,14 @@ def __init__(self, **options):
4343
4444 def load_replays (self , replay_collection , options = None , ** new_options ):
4545 options = options or utils .merged_dict (self .options , new_options )
46+
47+ # Get the directory and hide it from nested calls
48+ directory = options .get ('directory' ,'' )
49+ if 'directory' in options : del options ['directory' ]
50+
4651 if isinstance (replay_collection , basestring ):
47- directory = os .path .join (options .get ('directory' ,'' ), replay_collection )
48- del options ['directory' ] # don't need this anymore on this request
49- for replay_path in utils .get_replay_files (directory , ** options ):
52+ full_path = os .path .join (directory , replay_collection )
53+ for replay_path in utils .get_replay_files (full_path , ** options ):
5054 with open (replay_path ) as replay_file :
5155 try :
5256 yield self .load_replay (replay_file , options = options )
@@ -55,7 +59,16 @@ def load_replays(self, replay_collection, options=None, **new_options):
5559
5660 else :
5761 for replay_file in replay_collection :
58- yield self .load_replay (replay_file , options = options )
62+ if isinstance (replay_file , basestring ):
63+ full_path = os .path .join (directory , replay_file )
64+ if os .path .isdir (full_path ):
65+ for replay in self .load_replays (full_path , options = options ):
66+ yield replay
67+ else :
68+ yield self .load_replay (full_path , options = options )
69+
70+ else :
71+ yield self .load_replay (replay_file , options = options )
5972
6073 def load_replay (self , replay_file , options = None , ** new_options ):
6174 options = options or utils .merged_dict (self .options , new_options )
0 commit comments