Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 26, 2024
1 parent a95806b commit f4eefd7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ dynamic = [
"version",
]
dependencies = [
"argcomplete>=3.4",
"httpx>=0.19",
"platformdirs",
"prettytable>=2.4",
"pytablewriter[html]>=0.63",
"python-dateutil",
"python-slugify",
"termcolor>=2.1",
"argcomplete>=3.4"
]
optional-dependencies.tests = [
"freezegun",
Expand Down
3 changes: 3 additions & 0 deletions src/norwegianblue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ def norwegianblue(

return output


def all_products() -> list[str]:
"""Get all known products from the API or cache"""
return norwegianblue("all").splitlines()


@lru_cache(maxsize=None)
def suggest_product(product: str) -> str:
"""Provide the best suggestion based on a typed product"""
Expand All @@ -113,6 +115,7 @@ def suggest_product(product: str) -> str:
logging.info("Suggestion:\t%s (score: %d)", *result)
return result[0] if result else ""


def _ltsify(data: list[dict]) -> list[dict]:
"""If a cycle is LTS, append LTS to the cycle version and remove the LTS column"""
for cycle in data:
Expand Down
6 changes: 4 additions & 2 deletions src/norwegianblue/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@
from __future__ import annotations

import argparse
import argcomplete
import atexit
import logging
import platform
import sys

import argcomplete
from termcolor import colored

import norwegianblue
from norwegianblue import _cache

atexit.register(_cache.clear)


def ProductCompleter(**kwargs):
"""The list of all products to feed autocompletion"""
return norwegianblue.all_products()


def main() -> None:
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
Expand All @@ -40,7 +42,7 @@ def main() -> None:
nargs="*",
default=["all"],
help="product to check, or 'all' to list all available (default: 'all')",
).completer = ProductCompleter
).completer = ProductCompleter
parser.add_argument(
"-f",
"--format",
Expand Down

0 comments on commit f4eefd7

Please sign in to comment.