mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-03 03:42:35 +01:00
utils/log: add indentcontext
Add indentcontext context manager to save having to add try/finally clauses around indenting code just to ensure dedenting.
This commit is contained in:
committed by
Marc Bonnici
parent
c1a0f842d0
commit
ecc68ee367
@@ -21,6 +21,7 @@ import os
|
||||
import string
|
||||
import subprocess
|
||||
import threading
|
||||
from contextlib import contextmanager
|
||||
|
||||
import colorama
|
||||
|
||||
@@ -148,6 +149,15 @@ def dedent():
|
||||
_indent_level -= 1
|
||||
|
||||
|
||||
@contextmanager
|
||||
def indentcontext():
|
||||
indent()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
dedent()
|
||||
|
||||
|
||||
def set_indent_level(level):
|
||||
global _indent_level
|
||||
old_level = _indent_level
|
||||
|
Reference in New Issue
Block a user