MCPcopy Index your code
hub / github.com/pydata/xarray / DummyFileManager

Class DummyFileManager

xarray/backends/file_manager.py:453–483  ·  view source on GitHub ↗

FileManager that simply wraps an open file in the FileManager interface.

Source from the content-addressed store, hash-verified

451
452
453class DummyFileManager(FileManager[T_File]):
454 """FileManager that simply wraps an open file in the FileManager interface."""
455
456 def __init__(
457 self,
458 value: T_File,
459 *,
460 close: Callable[[], None] | None = None,
461 lock: Lock | None | Literal[False] = None,
462 ):
463 if close is None:
464 close = value.close
465 self._lock = lock
466 self._value = value
467 self._close = close
468
469 def acquire(self, needs_lock: bool = True) -> T_File:
470 del needs_lock # unused
471 return self._value
472
473 @contextmanager
474 def acquire_context(self, needs_lock: bool = True) -> Iterator[T_File]:
475 del needs_lock # unused
476 yield self._value
477
478 def close(self, needs_lock: bool = True) -> None:
479 if needs_lock and self._lock:
480 with self._lock:
481 self._close()
482 else:
483 self._close()

Callers 4

__init__Method · 0.90
openMethod · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…