Skip to content

Commit

Permalink
Add codec option in list command
Browse files Browse the repository at this point in the history
  • Loading branch information
rgonzalezfluendo committed Nov 22, 2024
1 parent 0a2a41c commit 86b406d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
3 changes: 3 additions & 0 deletions fluster/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class Codec(Enum):
AAC = "AAC"
AV1 = "AV1"

def __str__(self):
return self.value


class OutputFormat(Enum):
"""Output format"""
Expand Down
28 changes: 17 additions & 11 deletions fluster/fluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _load_test_suites(self) -> None:
if len(self.test_suites) == 0:
raise Exception(f'No test suites found in "{self.test_suites_dir}"')

def list_decoders(self, check: bool, verbose: bool) -> None:
def list_decoders(self, codec: Optional[Codec], check: bool, verbose: bool) -> None:
"""List all the available decoders"""
print("\nList of available decoders:")
decoders_dict: Dict[Codec, List[Decoder]] = {}
Expand All @@ -194,8 +194,10 @@ def list_decoders(self, check: bool, verbose: bool) -> None:
decoders_dict[dec.codec] = []
decoders_dict[dec.codec].append(dec)

for codec, decoder_list in decoders_dict.items():
print(f'\n{str(codec).split(".")[1]}')
for codec2, decoder_list in decoders_dict.items():
if codec and codec != codec2:
continue
print(f'\n{str(codec2).split(".")[1]}')
for decoder in decoder_list:
string = f"{decoder}"
if check:
Expand All @@ -208,23 +210,27 @@ def list_decoders(self, check: bool, verbose: bool) -> None:

def list_test_suites(
self,
codec: Optional[Codec],
show_test_vectors: bool = False,
test_suites: Optional[List[str]] = None,
test_suites_filter: Optional[List[str]] = None,
) -> None:
"""List all test suites"""
self._load_test_suites()
print("\nList of available test suites:")
if test_suites:
test_suites = [x.lower() for x in test_suites]
for test_suite in self.test_suites:
if test_suites:
if test_suite.name.lower() not in test_suites:
continue
if test_suites_filter:
test_suites_filter = [x.lower() for x in test_suites_filter]

test_suites = self.test_suites
for test_suite in test_suites:
if test_suites_filter and test_suite.name.lower() not in test_suites_filter:
continue
if codec and test_suite.codec != codec:
continue
print(test_suite)
if show_test_vectors:
for test_vector in test_suite.test_vectors.values():
print(test_vector)
if len(self.test_suites) == 0:
if len(test_suites) == 0:
print(f' No test suites found in "{self.test_suites_dir}"')

@staticmethod
Expand Down
15 changes: 12 additions & 3 deletions fluster/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from typing import Any, Tuple
from tempfile import gettempdir

from fluster.fluster import Fluster, Context, SummaryFormat
from fluster.fluster import Fluster, Context, SummaryFormat, Codec
from fluster import utils

APPNAME = "fluster"
Expand Down Expand Up @@ -190,6 +190,13 @@ def _add_list_cmd(self, subparsers: Any) -> None:
help="show stdout and stderr of commands executed",
action="store_true",
)
subparser.add_argument(
"-d",
"--codec",
help="show decoders and test suites of a codec",
type=Codec,
choices=list(Codec),
)
subparser.set_defaults(func=self._list_cmd)

def _add_run_cmd(self, subparsers: Any) -> None:
Expand Down Expand Up @@ -366,9 +373,11 @@ def _add_download_cmd(self, subparsers: Any) -> None:
@staticmethod
def _list_cmd(args: Any, fluster: Fluster) -> None:
fluster.list_test_suites(
show_test_vectors=args.testvectors, test_suites=args.testsuites
codec=args.codec,
show_test_vectors=args.testvectors,
test_suites_filter=args.testsuites,
)
fluster.list_decoders(check=args.check, verbose=args.verbose)
fluster.list_decoders(codec=args.codec, check=args.check, verbose=args.verbose)

@staticmethod
def _run_cmd(args: Any, fluster: Fluster) -> None:
Expand Down

0 comments on commit 86b406d

Please sign in to comment.