mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-23 04:11:54 +01:00
target: Use Target._xfer_cache_file() context manager
Use the context manager to simplify the file transfer cache management. Also introduce devlib.utils.misc.nullcontext() mirroring the behavior of contextlib.nullcontext().
This commit is contained in:
committed by
Marc Bonnici
parent
24e6de67ae
commit
f23fbd22b6
@@ -737,6 +737,23 @@ def batch_contextmanager(f, kwargs_list):
|
||||
stack.enter_context(f(**kwargs))
|
||||
yield
|
||||
|
||||
|
||||
@contextmanager
|
||||
def nullcontext(enter_result=None):
|
||||
"""
|
||||
Backport of Python 3.7 ``contextlib.nullcontext``
|
||||
|
||||
This context manager does nothing, so it can be used as a default
|
||||
placeholder for code that needs to select at runtime what context manager
|
||||
to use.
|
||||
|
||||
:param enter_result: Object that will be bound to the target of the with
|
||||
statement, or `None` if nothing is specified.
|
||||
:type enter_result: object
|
||||
"""
|
||||
yield enter_result
|
||||
|
||||
|
||||
class tls_property:
|
||||
"""
|
||||
Use it like `property` decorator, but the result will be memoized per
|
||||
|
Reference in New Issue
Block a user