Coverage for bioimageio/spec/utils.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-27 09:20 +0000

1import json 

2from typing import List, TypedDict 

3 

4from ._description import ensure_description_is_dataset, ensure_description_is_model 

5from ._internal.io import ( 

6 download, 

7 extract_file_name, 

8 get_reader, 

9 get_sha256, 

10 identify_bioimageio_yaml_file_name, 

11 is_valid_bioimageio_yaml_name, 

12) 

13from ._internal.io_utils import load_array, save_array, write_yaml 

14from ._internal.utils import files 

15 

16__all__ = [ 

17 "download", 

18 "ensure_description_is_dataset", 

19 "ensure_description_is_model", 

20 "extract_file_name", 

21 "get_file_name", 

22 "get_reader", 

23 "get_sha256", 

24 "get_spdx_licenses", 

25 "identify_bioimageio_yaml_file_name", 

26 "is_valid_bioimageio_yaml_name", 

27 "load_array", 

28 "save_array", 

29 "SpdxLicenseEntry", 

30 "SpdxLicenses", 

31 "write_yaml", 

32] 

33 

34get_file_name = extract_file_name 

35 

36 

37class SpdxLicenseEntry(TypedDict): 

38 isDeprecatedLicenseId: bool 

39 isKnownByZenodo: bool 

40 isOsiApproved: bool 

41 licenseId: str 

42 name: str 

43 reference: str 

44 

45 

46class SpdxLicenses(TypedDict): 

47 licenseListVersion: str 

48 licenses: List[SpdxLicenseEntry] 

49 releaseDate: str 

50 

51 

52def get_spdx_licenses() -> SpdxLicenses: 

53 """get details of the SPDX licenses known to bioimageio.spec""" 

54 with files("bioimageio.spec").joinpath("static/spdx_licenses.json").open( 

55 "r", encoding="utf-8" 

56 ) as f: 

57 return json.load(f)