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

21 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-02-05 13:53 +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_sha256, 

9 identify_bioimageio_yaml_file_name, 

10 is_valid_bioimageio_yaml_name, 

11) 

12from ._internal.io_utils import load_array, save_array 

13from ._internal.utils import files 

14 

15__all__ = [ 

16 "download", 

17 "ensure_description_is_dataset", 

18 "ensure_description_is_model", 

19 "extract_file_name", 

20 "get_sha256", 

21 "get_spdx_licenses", 

22 "identify_bioimageio_yaml_file_name", 

23 "is_valid_bioimageio_yaml_name", 

24 "load_array", 

25 "save_array", 

26 "SpdxLicenseEntry", 

27 "SpdxLicenses", 

28] 

29 

30 

31class SpdxLicenseEntry(TypedDict): 

32 isDeprecatedLicenseId: bool 

33 isKnownByZenodo: bool 

34 isOsiApproved: bool 

35 licenseId: str 

36 name: str 

37 reference: str 

38 

39 

40class SpdxLicenses(TypedDict): 

41 licenseListVersion: str 

42 licenses: List[SpdxLicenseEntry] 

43 releaseDate: str 

44 

45 

46def get_spdx_licenses() -> SpdxLicenses: 

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

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

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

50 ) as f: 

51 return json.load(f)