Coverage for python/lsst/daf/butler/script/butlerImport.py: 45%

9 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-08-12 09:20 +0000

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/>. 

21from __future__ import annotations 

22 

23from collections.abc import Iterable 

24from typing import TextIO 

25 

26from .._butler import Butler 

27 

28 

29def butlerImport( 

30 repo: str, 

31 directory: str | None, 

32 export_file: str | TextIO | None, 

33 transfer: str | None, 

34 skip_dimensions: Iterable[str] | None, 

35) -> None: 

36 """Import data into a butler repository. 

37 

38 Parameters 

39 ---------- 

40 repo : `str` 

41 URI to the location of the repo or URI to a config file describing the 

42 repo and its location. 

43 directory : `str`, or None 

44 Directory containing dataset files. If `None`, all file paths must be 

45 absolute. 

46 export_file : `TextIO`, or None 

47 Name for the file that contains database information associated with 

48 the exported datasets. If this is not an absolute path, does not exist 

49 in the current working directory, and `directory` is not `None`, it is 

50 assumed to be in `directory`. Defaults to "export.{format}". 

51 transfer : `str`, or None 

52 The external data transfer type. 

53 skip_dimensions : `list`, or `None` 

54 Dimensions that should be skipped. 

55 """ 

56 butler = Butler(repo, writeable=True) 

57 

58 if skip_dimensions is not None: 

59 skip_dimensions = set(skip_dimensions) 

60 

61 butler.import_( 

62 directory=directory, 

63 filename=export_file, 

64 transfer=transfer, 

65 format="yaml", 

66 skip_dimensions=skip_dimensions, 

67 )