-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: reference service interface
Make a reference service to make it a bit easier to define interfaces for the different types of models wer have.
- Loading branch information
Showing
13 changed files
with
139 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/libecalc/presentation/yaml/domain/reference_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import Iterable, Protocol | ||
|
||
from libecalc.dto import CompressorModel, FuelType, GeneratorSetSampled, PumpModel, TabulatedData | ||
|
||
|
||
class InvalidReferenceException(Exception): | ||
def __init__(self, reference_type: str, reference: str, available_references: Iterable[str] = None): | ||
if available_references is not None: | ||
available_message = f"Available references: {', '.join(available_references)}" | ||
else: | ||
available_message = "" | ||
super().__init__(f"Invalid {reference_type} reference '{reference}'. {available_message}") | ||
|
||
|
||
class ReferenceService(Protocol): | ||
def get_fuel_reference(self, reference: str) -> FuelType: ... | ||
|
||
def get_generator_set_model(self, reference: str) -> GeneratorSetSampled: ... | ||
|
||
def get_compressor_model(self, reference: str) -> CompressorModel: ... | ||
|
||
def get_pump_model(self, reference: str) -> PumpModel: ... | ||
|
||
def get_tabulated_model(self, reference: str) -> TabulatedData: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.