[dvsim] Minor fix in clean_odirs function
The `clean_odirs` method takes `max_odirs` as an arg (which limits the
number of output directories to that number). This fixes the code to
handle `max_odirs = 1|0`.
Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/util/dvsim/utils.py b/util/dvsim/utils.py
index dd2cce2..dedcf75 100644
--- a/util/dvsim/utils.py
+++ b/util/dvsim/utils.py
@@ -579,7 +579,7 @@
key=os.path.getctime,
reverse=True)
- for old in dirs[max_odirs - 1:]:
+ for old in dirs[max(0, max_odirs - 1):]:
shutil.rmtree(old, ignore_errors=True)
- return dirs[0:max_odirs - 2]
+ return [] if max_odirs == 0 else dirs[:max_odirs - 1]