[apple] Refactor script (#213)
Make the script more readable, mostly by: - using the endoflife.Product class, - removing the unnecessary use of functions, - a little bit of renaming.
This commit is contained in:
@@ -42,6 +42,7 @@ def parse_datetime(text, formats=frozenset([
|
||||
"""
|
||||
# so that we don't have to deal with some special characters in formats
|
||||
text = text.strip().replace(", ", " ").replace(". ", " ").replace("(", "").replace(")", "")
|
||||
text = text.replace("Sept ", "Sep ") # common typo, for ex. on Apple and Artifactory products
|
||||
for fmt in formats:
|
||||
try:
|
||||
date = datetime.strptime(text, fmt)
|
||||
|
||||
@@ -43,6 +43,13 @@ class Product:
|
||||
for (version, date) in dates_by_version.items():
|
||||
self.declare_version(version, date)
|
||||
|
||||
def replace_version(self, version: str, date: datetime) -> None:
|
||||
if version not in self.versions:
|
||||
raise ValueError(f"version {version} cannot be replaced as it does not exist for {self.name}")
|
||||
|
||||
logging.info(f"replacing version {version} ({self.versions[version]} -> {date}) to {self.name}")
|
||||
self.versions[version] = date
|
||||
|
||||
def remove_version(self, version: str) -> None:
|
||||
if not self.has_version(version):
|
||||
logging.warning(f"version {version} cannot be removed as it does not exist for {self.name}")
|
||||
|
||||
Reference in New Issue
Block a user