@@ -30,6 +30,9 @@ def __init__(self, *args, **kwargs):
30
30
self .__path = None
31
31
self .__fields = None
32
32
self .__contributors_as_maintainers = None
33
+ self .__homepage_label = None
34
+ self .__bugs_label = None
35
+ self .__repository_label = None
33
36
34
37
@property
35
38
def path (self ) -> str :
@@ -57,9 +60,8 @@ def fields(self) -> None | set[str]:
57
60
isinstance (fields , list ) and all (isinstance (f , str ) for f in fields )
58
61
):
59
62
raise TypeError (
60
- "Option `fields` for build hook `{}` must be a list of strings" .format (
61
- self .PLUGIN_NAME
62
- )
63
+ "Option `fields` for build hook `{}` "
64
+ "must be a list of strings" .format (self .PLUGIN_NAME )
63
65
)
64
66
self .__fields = set (fields )
65
67
return self .__fields
@@ -72,13 +74,52 @@ def contributors_as_maintainers(self) -> bool:
72
74
)
73
75
if not isinstance (contributors_as_maintainers , bool ):
74
76
raise TypeError (
75
- "Option `contributors-as-maintainers` for build hook `{}` must be a boolean" .format (
76
- self .PLUGIN_NAME
77
- )
77
+ "Option `contributors-as-maintainers` for build hook `{}` "
78
+ "must be a boolean" .format (self .PLUGIN_NAME )
78
79
)
79
80
self .__contributors_as_maintainers = contributors_as_maintainers
80
81
return self .__contributors_as_maintainers
81
82
83
+ @property
84
+ def homepage_label (self ) -> bool :
85
+ if self .__homepage_label is None :
86
+ homepage_label = self .config .get ("homepage-label" , "Homepage" )
87
+
88
+ if not isinstance (homepage_label , str ):
89
+ raise TypeError (
90
+ "Option `homepage-label` for build hook `{}` "
91
+ "must be a string" .format (self .PLUGIN_NAME )
92
+ )
93
+ self .__homepage_label = homepage_label
94
+ return self .__homepage_label
95
+
96
+ @property
97
+ def bugs_label (self ) -> bool :
98
+ if self .__bugs_label is None :
99
+ bug_tracker_label = self .config .get ("bugs-label" , "Bug Tracker" )
100
+
101
+ if not isinstance (bug_tracker_label , str ):
102
+ raise TypeError (
103
+ "Option `bugs-label` for build hook `{}` must be a string" .format (
104
+ self .PLUGIN_NAME
105
+ )
106
+ )
107
+ self .__bugs_label = bug_tracker_label
108
+ return self .__bugs_label
109
+
110
+ @property
111
+ def repository_label (self ) -> bool :
112
+ if self .__repository_label is None :
113
+ bug_tracker_label = self .config .get ("repository-label" , "Repository" )
114
+
115
+ if not isinstance (bug_tracker_label , str ):
116
+ raise TypeError (
117
+ "Option `repository-label` for build hook `{}` "
118
+ "must be a string" .format (self .PLUGIN_NAME )
119
+ )
120
+ self .__repository_label = bug_tracker_label
121
+ return self .__repository_label
122
+
82
123
def load_package_data (self ):
83
124
path = os .path .normpath (os .path .join (self .root , self .path ))
84
125
if not os .path .isfile (path ):
@@ -136,19 +177,17 @@ def update(self, metadata: dict[str, Any]):
136
177
authors = [self ._parse_person (package ["author" ])]
137
178
138
179
if "contributors" in package :
139
- contributors = [
140
- self ._parse_person (p ) for p in package ["contributors" ]
141
- ]
180
+ contributors = [self ._parse_person (p ) for p in package ["contributors" ]]
142
181
if self .contributors_as_maintainers :
143
182
maintainers = contributors
144
183
else :
145
184
authors = [* (authors or []), * contributors ]
146
185
147
186
if authors is not None :
148
- new_metadata [' authors' ] = authors
187
+ new_metadata [" authors" ] = authors
149
188
150
189
if maintainers is not None :
151
- new_metadata [' maintainers' ] = maintainers
190
+ new_metadata [" maintainers" ] = maintainers
152
191
153
192
if "keywords" in package :
154
193
new_metadata ["keywords" ] = package ["keywords" ]
@@ -162,13 +201,13 @@ def update(self, metadata: dict[str, Any]):
162
201
# Construct URLs
163
202
urls = {}
164
203
if "homepage" in package :
165
- urls ["homepage" ] = package ["homepage" ]
204
+ urls [self . homepage_label ] = package ["homepage" ]
166
205
if "bugs" in package :
167
206
bugs_url = self ._parse_bugs (package ["bugs" ])
168
207
if bugs_url is not None :
169
- urls ["bug tracker" ] = bugs_url
208
+ urls [self . bugs_label ] = bugs_url
170
209
if "repository" in package :
171
- urls ["repository" ] = self ._parse_repository (package ["repository" ])
210
+ urls [self . repository_label ] = self ._parse_repository (package ["repository" ])
172
211
173
212
# Write URLs
174
213
if urls :
0 commit comments