Coverage for src/pythia/applications/command_line.py: 75%

10 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2022-10-07 19:27 +0000

1"""Class defeinitions from pythia apps deisgned to be run from the cli.""" 

2from typing import NoReturn 

3 

4from pythia.applications.base import Application 

5from pythia.utils.message_handlers import on_message_eos 

6from pythia.utils.message_handlers import on_message_error 

7 

8 

9class CliApplication(Application): 

10 """Command-line application.""" 

11 

12 on_message_eos = on_message_eos 

13 

14 def on_message_error(self, *args, **kwargs) -> NoReturn: 

15 """Print error and exit. 

16 

17 Args: 

18 args: forwarded to :func:`on_message_error`. 

19 kwargs: forwarded to :func:`on_message_error`. 

20 

21 Raises: 

22 RuntimeError: Always raises this error. You can wrap this in 

23 a try/except block to handle. 

24 

25 """ 

26 on_message_error(self, *args, **kwargs) 

27 self.stop() 

28 raise RuntimeError("Unhandled pipeline error")