forked from rc/aircox
write tests for SoundStat
This commit is contained in:
@@ -73,19 +73,18 @@ class SoundStats:
|
||||
|
||||
def __init__(self, path, sample_length=None):
|
||||
self.path = path
|
||||
self.sample_length = (
|
||||
sample_length if sample_length is not None else self.sample_length
|
||||
)
|
||||
if sample_length is not None:
|
||||
self.sample_length = sample_length
|
||||
|
||||
def get_file_stats(self):
|
||||
return self.stats and self.stats[0]
|
||||
return self.stats and self.stats[0] or None
|
||||
|
||||
def analyse(self):
|
||||
logger.debug("complete file analysis")
|
||||
self.stats = [SoxStats(self.path)]
|
||||
position = 0
|
||||
length = self.stats[0].get("length")
|
||||
|
||||
print(self.stats, "-----")
|
||||
if not self.sample_length:
|
||||
return
|
||||
|
||||
@@ -109,23 +108,23 @@ class SoundStats:
|
||||
self.resume()
|
||||
|
||||
def resume(self):
|
||||
def view(array):
|
||||
return [
|
||||
"file"
|
||||
if index == 0
|
||||
else "sample {} (at {} seconds)".format(
|
||||
index, (index - 1) * self.sample_length
|
||||
)
|
||||
for index in array
|
||||
]
|
||||
|
||||
if self.good:
|
||||
logger.debug(
|
||||
self.path + " -> good: \033[92m%s\033[0m",
|
||||
", ".join(view(self.good)),
|
||||
", ".join(self._view(self.good)),
|
||||
)
|
||||
if self.bad:
|
||||
logger.debug(
|
||||
self.path + " -> bad: \033[91m%s\033[0m",
|
||||
", ".join(view(self.bad)),
|
||||
", ".join(self._view(self.bad)),
|
||||
)
|
||||
|
||||
def _view(self, array):
|
||||
return [
|
||||
"file"
|
||||
if index == 0
|
||||
else "sample {} (at {} seconds)".format(
|
||||
index, (index - 1) * self.sample_length
|
||||
)
|
||||
for index in array
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user