Coverage for python/lsst/daf/butler/core/fileDescriptor.py : 18%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of daf_butler.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22__all__ = ("FileDescriptor",)
25class FileDescriptor:
26 """Describes a particular file.
28 Parameters
29 ----------
30 location : `Location`
31 Storage location.
32 storageClass : `StorageClass`
33 `StorageClass` associated with this file when it was stored.
34 readStorageClass : `StorageClass`, optional
35 Storage class associated with reading the file. Defines the
36 Python type that the in memory Dataset will have. Will default
37 to the ``storageClass`` if not specified.
38 parameters : `dict`, optional
39 Additional parameters that can be used for reading and writing.
40 """
42 __slots__ = ("location", "storageClass", "_readStorageClass", "parameters")
44 def __init__(self, location, storageClass, readStorageClass=None, parameters=None):
45 self.location = location
46 self._readStorageClass = readStorageClass
47 self.storageClass = storageClass
48 self.parameters = parameters
50 def __repr__(self):
51 optionals = {}
52 if self._readStorageClass is not None:
53 optionals["readStorageClass"] = self._readStorageClass
54 if self.parameters:
55 optionals["parameters"] = self.parameters
57 # order is preserved in the dict
58 options = ", ".join(f"{k}={v!r}" for k, v in optionals.items())
60 r = f"{self.__class__.__name__}({self.location!r}, {self.storageClass!r}"
61 if options:
62 r = r + ", " + options
63 r = r + ")"
64 return r
66 @property
67 def readStorageClass(self):
68 """Storage class to use when reading. (`StorageClass`)
70 Will default to ``storageClass`` if none specified."""
71 if self._readStorageClass is None:
72 return self.storageClass
73 return self._readStorageClass