mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-08 11:13:51 +00:00
add length counter for AmmoFileReader
This commit is contained in:
parent
372b4e5d71
commit
0235b84c97
@ -69,6 +69,7 @@ class AmmoFileReader(SimpleGenerator):
|
||||
def __init__(self, filename, loop_limit=0):
|
||||
self.filename = filename
|
||||
self.loops = 0
|
||||
self.ammo_len = 0
|
||||
self.loop_limit = loop_limit
|
||||
|
||||
def __iter__(self):
|
||||
@ -84,6 +85,7 @@ class AmmoFileReader(SimpleGenerator):
|
||||
if len(missile) < chunk_size:
|
||||
raise AmmoFileError(
|
||||
"Unexpected end of file: read %s bytes instead of %s" % (len(missile), chunk_size))
|
||||
self.ammo_len += 1
|
||||
yield (missile, marker)
|
||||
except (IndexError, ValueError):
|
||||
raise AmmoFileError(
|
||||
@ -92,3 +94,6 @@ class AmmoFileReader(SimpleGenerator):
|
||||
self.loops += 1
|
||||
ammo_file.seek(0)
|
||||
chunk_header = ammo_file.readline()
|
||||
|
||||
def __len__(self):
|
||||
return self.ammo_len
|
||||
|
Loading…
Reference in New Issue
Block a user