Coverage for python/lsst/daf/butler/core/fileDataset.py: 59%
Shortcuts 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
Shortcuts 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/>.
22from __future__ import annotations
24__all__ = ["FileDataset"]
26from dataclasses import dataclass
27from typing import Any, List, Optional, Union
29from ._butlerUri import ButlerURI
30from .datasets import DatasetRef
31from .formatter import FormatterParameter
34@dataclass
35class FileDataset:
36 """A struct that represents a dataset exported to a file."""
38 __slots__ = ("refs", "path", "formatter")
40 refs: List[DatasetRef]
41 """Registry information about the dataset. (`list` of `DatasetRef`).
42 """
44 path: Union[str, ButlerURI]
45 """Path to the dataset (`str` or `ButlerURI`).
47 If the dataset was exported with ``transfer=None`` (i.e. in-place),
48 this is relative to the datastore root (only datastores that have a
49 well-defined root in the local filesystem can be expected to support
50 in-place exports). Otherwise this is relative to the directory passed
51 to `Datastore.export`.
52 """
54 formatter: Optional[FormatterParameter]
55 """A `Formatter` class or fully-qualified name.
56 """
58 def __init__(
59 self,
60 path: Union[str, ButlerURI],
61 refs: Union[DatasetRef, List[DatasetRef]],
62 *,
63 formatter: Optional[FormatterParameter] = None,
64 ):
65 self.path = path
66 if isinstance(refs, DatasetRef):
67 refs = [refs]
68 self.refs = refs
69 self.formatter = formatter
71 def __lt__(self, other: Any) -> bool:
72 # Sort on path alone
73 if not isinstance(other, type(self)):
74 return NotImplemented
75 return str(self.path) < str(other.path)