Added compiler by name

This commit is contained in:
thematdev 2023-01-22 12:31:32 +03:00
parent 4090a25471
commit b098840586
Signed by: thematdev
GPG Key ID: D12878639B090D90

View File

@ -22,11 +22,14 @@ ALL_LANGUAGE_COMPILERS = parse_obj_as(
) )
def compiler_by_name(name: str) -> LanguageCompiler:
"""Return compiler model by name"""
return next(filter(lambda comp: comp.name == name, ALL_LANGUAGE_COMPILERS))
def compiler_by_id(id: int) -> LanguageCompiler: def compiler_by_id(id: int) -> LanguageCompiler:
"""Return compiler model by id""" """Return compiler model by id"""
for comp in ALL_LANGUAGE_COMPILERS: return next(filter(lambda comp: comp.id == id, ALL_LANGUAGE_COMPILERS))
if comp.id == id:
return comp
def all_compilers_by_ext(extension: str) -> Iterable[LanguageCompiler]: def all_compilers_by_ext(extension: str) -> Iterable[LanguageCompiler]: