Skip to content

Commit e369643

Browse files
committed
Applies a series of fixes to the SC2Reader configure and read functions
1 parent c1bbc5f commit e369643

24 files changed

+14
-73
lines changed

sc2reader/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,21 @@ def __init__(self, parse=config.FULL, directory="", processors=[], debug=False,
4646

4747
def read(self, location):
4848
#account for the directory option
49-
location = os.path.join(self.directory,location)
49+
if self.directory: location = os.path.join(self.directory,location)
5050

5151
if not os.path.exists(location):
5252
raise ValueError("Location must exist")
5353

5454
#If its a directory, read each subfile/directory and combine the lists
5555
if os.path.isdir(location):
56-
return sum(map(self.read, os.list_files(location)),[])
56+
replays = list()
57+
for filename in os.listdir(location):
58+
replay = self.read(os.path.join(location,filename))
59+
if isinstance(replay,list):
60+
replays.extend(replay)
61+
else:
62+
replays.append(replay)
63+
return replays
5764

5865
#The primary replay reading routine
5966
else:
@@ -82,11 +89,14 @@ def read(self, location):
8289

8390
return replay
8491

92+
def configure(self,**options):
93+
self.__dict__.update(options)
94+
8595
#Prepare the lightweight interface
8696
__defaultSC2Reader = SC2Reader()
8797

88-
def configure(parse=config.FULL, directory=None, processors=[], debug=False, files=None):
89-
__defaultSC2Reader.__dict__.update(locals())
98+
def configure(**options):
99+
__defaultSC2Reader.configure(options)
90100

91101
def read(location):
92102
return __defaultSC2Reader.read(location)
-41.6 KB
Binary file not shown.
-41.6 KB
Binary file not shown.
-41.6 KB
Binary file not shown.
-59.7 KB
Binary file not shown.
-99.7 KB
Binary file not shown.
-139 KB
Binary file not shown.
-51 KB
Binary file not shown.
-70.7 KB
Binary file not shown.
-161 KB
Binary file not shown.

0 commit comments

Comments
 (0)