Skip to content

Commit

Permalink
sort server types
Browse files Browse the repository at this point in the history
  • Loading branch information
s-m-e committed Feb 8, 2022
1 parent b41aeff commit d36f2b9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/scherbelberg/_core/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def get_servertypes(client: Client, location: str = 'fsn1') -> List[Dict[str, An
servertypes = [_parse_prices(servertype, location = location) for servertype in servertypes]
servertypes = [servertype for servertype in servertypes if servertype is not None]

servertypes.sort(key = _sort_key)

return servertypes

@typechecked
Expand Down Expand Up @@ -110,3 +112,8 @@ def _parse_prices(servertype: Dict[str, Any], location: str = 'fsn1') -> Optiona
price.update({f'{price_type:s}_{k:s}': v for k, v in price.pop(price_type).items()})
servertype.update(price)
return servertype

@typechecked
def _sort_key(servertype: Dict[str, Any]):

return servertype['cpu_type'].ljust(100) + f"{servertype['cores']:05d}"

0 comments on commit d36f2b9

Please sign in to comment.