66
77import re
88from configparser import UNNAMED_SECTION , ConfigParser
9- from os import PathLike
9+ from os import environ , PathLike
1010from pathlib import Path
1111from typing import List , Optional
1212
@@ -51,8 +51,9 @@ def __init__(self, cname, arch=None, commit_hash=None, version=None):
5151 self ._commit_id = None
5252 self ._feature_elements_cached = None
5353 self ._feature_flags_cached = None
54- self ._feature_platforms_cached = None
54+ self ._feature_platform_cached = None
5555 self ._feature_set_cached = None
56+ self ._flag_multiple_platforms = bool (environ .get ("GL_ALLOW_FRANKENSTEIN" , False ))
5657 self ._flavor = None
5758 self ._version = None
5859
@@ -117,7 +118,7 @@ def cname(self) -> str:
117118 :return: (str) CName
118119 :since: 0.7.0
119120 """
120- assert self . _flavor is not None , "CName flavor is not set!"
121+
121122 cname = self ._flavor
122123
123124 if self ._arch is not None :
@@ -134,7 +135,7 @@ def commit_hash(self) -> str:
134135 Returns the commit hash if part of the cname parsed.
135136
136137 :return: (str) Commit hash
137- :since: 0.11 .0
138+ :since: 1.0 .0
138139 """
139140
140141 if self ._commit_hash is None :
@@ -151,7 +152,7 @@ def commit_hash(self, commit_hash) -> None:
151152
152153 :param commit_hash: Commit hash
153154
154- :since: 0.11 .0
155+ :since: 1.0 .0
155156 """
156157
157158 if self ._commit_id is not None and not commit_hash .startswith (self ._commit_id ):
@@ -202,7 +203,7 @@ def feature_set_element(self) -> str:
202203 Returns the feature set of type "element" for the cname parsed.
203204
204205 :return: (str) Feature set elements
205- :since: 0.11 .0
206+ :since: 1.0 .0
206207 """
207208
208209 if self ._feature_elements_cached is not None :
@@ -216,7 +217,7 @@ def feature_set_flag(self) -> str:
216217 Returns the feature set of type "flag" for the cname parsed.
217218
218219 :return: (str) Feature set flags
219- :since: 0.11 .0
220+ :since: 1.0 .0
220221 """
221222
222223 if self ._feature_flags_cached is not None :
@@ -229,29 +230,38 @@ def feature_set_platform(self) -> str:
229230 """
230231 Returns the feature set of type "platform" for the cname parsed.
231232
232- :return: (str) Feature set platforms
233- :since: 0.11 .0
233+ :return: (str) Feature set platform
234+ :since: 1.0 .0
234235 """
235236
236- if self ._feature_platforms_cached is not None :
237- return "," .join (self ._feature_platforms_cached )
237+ if self ._feature_platform_cached is not None :
238+ return self ._feature_platform_cached
239+
240+ platforms = Parser ().filter_as_dict (self .flavor )["platform" ]
241+
242+ if self ._flag_multiple_platforms :
243+ return "," .join (platforms )
238244
239- return "," .join (Parser ().filter_as_dict (self .flavor )["platform" ])
245+ assert len (platforms ) < 2 ; "Only one platform is supported"
246+ return platforms [0 ]
240247
241248 @property
242249 def release_metadata_string (self ) -> str :
243250 """
244251 Returns the release metadata describing the given CName instance.
245252
246253 :return: (str) Release metadata describing the given CName instance
247- :since: 0.11 .0
254+ :since: 1.0 .0
248255 """
249256
250257 features = Parser ().filter_as_dict (self .flavor )
251258
259+ if not self ._flag_multiple_platforms :
260+ assert len (features ["platform" ]) < 2 ; "Only one platform is supported"
261+
252262 elements = "," .join (features ["element" ])
253263 flags = "," .join (features ["flag" ])
254- platforms = "," .join (features ["platform" ])
264+ platform = "," .join (features ["platform" ])
255265
256266 metadata = f"""
257267ID={ GL_RELEASE_ID }
@@ -264,7 +274,7 @@ def release_metadata_string(self) -> str:
264274BUG_REPORT_URL="{ GL_BUG_REPORT_URL } "
265275GARDENLINUX_CNAME="{ self .cname } "
266276GARDENLINUX_FEATURES="{ self .feature_set } "
267- GARDENLINUX_FEATURES_PLATFORMS ="{ platforms } "
277+ GARDENLINUX_FEATURES_PLATFORM ="{ platform } "
268278GARDENLINUX_FEATURES_ELEMENTS="{ elements } "
269279GARDENLINUX_FEATURES_FLAGS="{ flags } "
270280GARDENLINUX_VERSION="{ self .version } "
@@ -282,24 +292,9 @@ def platform(self) -> str:
282292 :return: (str) Feature set platforms
283293 :since: 0.7.0
284294 """
285- assert self ._flavor is not None , "Flavor not set!"
286295
287296 return self .feature_set_platform
288297
289- @property
290- def platforms (self ) -> List [str ]:
291- """
292- Returns the platforms for the cname parsed.
293-
294- :return: (str) Platforms
295- :since: 0.11.0
296- """
297-
298- if self ._feature_platforms_cached is not None :
299- return self ._feature_platforms_cached
300-
301- return Parser ().filter_as_dict (self .flavor )["platform" ]
302-
303298 @property
304299 def version (self ) -> Optional [str ]:
305300 """
@@ -331,7 +326,7 @@ def load_from_release_file(self, release_file: PathLike | str) -> None:
331326
332327 :param release_file: Release metadata file
333328
334- :since: 0.11 .0
329+ :since: 1.0 .0
335330 """
336331
337332 if not isinstance (release_file , PathLike ):
@@ -350,7 +345,7 @@ def load_from_release_file(self, release_file: PathLike | str) -> None:
350345 "GARDENLINUX_FEATURES" ,
351346 "GARDENLINUX_FEATURES_ELEMENTS" ,
352347 "GARDENLINUX_FEATURES_FLAGS" ,
353- "GARDENLINUX_FEATURES_PLATFORMS " ,
348+ "GARDENLINUX_FEATURES_PLATFORM " ,
354349 "GARDENLINUX_VERSION" ,
355350 ):
356351 if not release_config .has_option (UNNAMED_SECTION , release_field ):
@@ -395,9 +390,9 @@ def load_from_release_file(self, release_file: PathLike | str) -> None:
395390 UNNAMED_SECTION , "GARDENLINUX_FEATURES_FLAGS"
396391 ).split ("," )
397392
398- self ._feature_platforms_cached = release_config .get (
399- UNNAMED_SECTION , "GARDENLINUX_FEATURES_PLATFORMS "
400- ). split ( "," )
393+ self ._feature_platform_cached = release_config .get (
394+ UNNAMED_SECTION , "GARDENLINUX_FEATURES_PLATFORM "
395+ )
401396
402397 def save_to_release_file (
403398 self , release_file : PathLike | str , overwrite : Optional [bool ] = False
@@ -407,7 +402,7 @@ def save_to_release_file(
407402
408403 :param release_file: Release metadata file
409404
410- :since: 0.11 .0
405+ :since: 1.0 .0
411406 """
412407
413408 if not isinstance (release_file , PathLike ):
0 commit comments