Coverage for C: \ Users \ peaco \ OneDrive \ Documents \ GitHub \ mt_metadata \ mt_metadata \ transfer_functions \ io \ emtfxml \ metadata \ copyright.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-10 00:11 -0800

1# ===================================================== 

2# Imports 

3# ===================================================== 

4from typing import Annotated 

5 

6from pydantic import Field 

7 

8from mt_metadata.base import MetadataBase 

9from mt_metadata.common.enumerations import ReleaseStatusEnum 

10from mt_metadata.transfer_functions.io.emtfxml.metadata import helpers 

11 

12from . import Citation 

13 

14 

15# ===================================================== 

16 

17 

18class Copyright(MetadataBase): 

19 citation: Annotated[ 

20 Citation, 

21 Field( 

22 default_factory=Citation, # type: ignore 

23 description="The citation information for the data", 

24 alias=None, 

25 json_schema_extra={ 

26 "units": None, 

27 "required": True, 

28 "examples": [ 

29 "Citation(authors='Doe, J.', year='2023', title='Title of the paper', journal='Journal Name', volume='45', pages='123-145')" 

30 ], 

31 }, 

32 ), 

33 ] 

34 selected_publications: Annotated[ 

35 str | None, 

36 Field( 

37 default=None, 

38 description="Any publications that use this data", 

39 alias=None, 

40 json_schema_extra={ 

41 "units": None, 

42 "required": False, 

43 "examples": ["my paper"], 

44 }, 

45 ), 

46 ] 

47 

48 release_status: Annotated[ 

49 ReleaseStatusEnum, 

50 Field( 

51 default="Unrestricted Release", 

52 description="the release status of the data", 

53 alias=None, 

54 json_schema_extra={ 

55 "units": None, 

56 "required": True, 

57 "examples": ["Unrestricted release"], 

58 }, 

59 ), 

60 ] 

61 

62 conditions_of_use: Annotated[ 

63 str, 

64 Field( 

65 default="All data and metadata for this survey are available free of charge and may be copied freely, duplicated and further distributed provided this data set is cited as the reference. While the author(s) strive to provide data and metadata of best possible quality, neither the author(s) of this data set, not IRIS make any claims, promises, or guarantees about the accuracy, completeness, or adequacy of this information, and expressly disclaim liability for errors and omissions in the contents of this file. Guidelines about the quality or limitations of the data and metadata, as obtained from the author(s), are included for informational purposes only.", 

66 description="Any notes on conditions of use", 

67 alias=None, 

68 json_schema_extra={ 

69 "units": None, 

70 "required": True, 

71 "examples": ["Cite data upon usage."], 

72 }, 

73 ), 

74 ] 

75 

76 acknowledgement: Annotated[ 

77 str | None, 

78 Field( 

79 default=None, 

80 description="any acknowledgments the transfer function should have.", 

81 alias=None, 

82 json_schema_extra={ 

83 "units": None, 

84 "required": False, 

85 "examples": ["This project was funded by x."], 

86 }, 

87 ), 

88 ] 

89 

90 additional_info: Annotated[ 

91 str | None, 

92 Field( 

93 default=None, 

94 description="any additional information about the data.", 

95 alias=None, 

96 json_schema_extra={ 

97 "units": None, 

98 "required": False, 

99 "examples": ["This purpose of this project is ..."], 

100 }, 

101 ), 

102 ] 

103 

104 def read_dict(self, input_dict): 

105 """ 

106 

107 :param input_dict: DESCRIPTION 

108 :type input_dict: TYPE 

109 :return: DESCRIPTION 

110 :rtype: TYPE 

111 

112 """ 

113 helpers._read_element(self, input_dict, "copyright") 

114 

115 def to_xml(self, string=False, required=True): 

116 """ """ 

117 # Create a shallow copy to avoid mutating the original object 

118 import copy 

119 

120 xml_copy = copy.copy(self) 

121 # Set the title-cased release_status on the copy using object.__setattr__ 

122 # to bypass Pydantic validation 

123 object.__setattr__(xml_copy, "release_status", self.release_status.title()) 

124 

125 return helpers.to_xml( 

126 xml_copy, 

127 string=string, 

128 required=required, 

129 order=[ 

130 "citation", 

131 "selected_publications", 

132 "acknowledgement", 

133 "release_status", 

134 "conditions_of_use", 

135 "additional_info", 

136 ], 

137 )