-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
68 lines (50 loc) · 1.66 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from api import EOLApi
API = EOLApi()
def batch(iterable, n=1):
"""
Generator that yields slices of the iterable, each of size n.
Args:
iterable: The iterable to slice.
n (int): The size of each slice.
Yields:
slice: Slices of the iterable, each of size n.
"""
length = len(iterable)
for split in range(0, length, n):
yield iterable[split : min(split + n, length)]
def get_all_products_from_api():
"""
Fetches all products from the API.
Returns:
list: A list of all products.
"""
return API.get_all_products()
def get_product_details_from_api(product: str, majors_only: bool):
"""
Fetches the details of a product from the API.
Args:
product (str): The name of the product.
majors_only (bool): Whether to only include major versions.
Returns:
list: A list of product details.
"""
details = API.get_product_details(product=product)
if majors_only:
excluded_minors_products = []
latest_major = 0
for entry in details:
if entry["cycle"].split(".")[0] != latest_major:
excluded_minors_products.append(entry)
latest_major = entry["cycle"].split(".")[0]
details = excluded_minors_products
return details
def get_single_cycle_details_from_api(product, cycle):
"""
Fetches the details of a single cycle of a product from the API.
Args:
product (str): The name of the product.
cycle (str): The name of the cycle.
Returns:
dict: The details of the cycle.
"""
return API.get_single_cycle_details(product=product, cycle=cycle)