Coverage for python / lsst / resources / mem.py: 0%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-28 08:32 +0000

1# This file is part of lsst-resources. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# Use of this source code is governed by a 3-clause BSD-style 

10# license that can be found in the LICENSE file. 

11 

12from __future__ import annotations 

13 

14__all__ = ("InMemoryResourcePath",) 

15 

16import contextlib 

17from collections.abc import Iterator 

18 

19from ._resourcePath import ResourceInfo, ResourcePath 

20 

21 

22class InMemoryResourcePath(ResourcePath): 

23 """Internal in-memory datastore URI (`mem://`). 

24 

25 Not used for any real purpose other than indicating that the dataset 

26 is in memory. 

27 """ 

28 

29 def exists(self) -> bool: 

30 """Test for existence and always return False.""" 

31 return True 

32 

33 def get_info(self) -> ResourceInfo: 

34 """Return placeholder metadata for an in-memory resource.""" 

35 return ResourceInfo( 

36 uri=str(self), 

37 is_file=True, 

38 size=0, 

39 last_modified=None, 

40 checksums={}, 

41 ) 

42 

43 @contextlib.contextmanager 

44 def _as_local( 

45 self, multithreaded: bool = True, tmpdir: ResourcePath | None = None 

46 ) -> Iterator[ResourcePath]: 

47 raise RuntimeError(f"Do not know how to retrieve data for URI '{self}'")