Coverage for src/ipyvizzustory/__init__.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-25 14:02 +0100

1"""Python integration of Vizzu-Story.""" 

2 

3 

4from .storylib.story import Step, Slide 

5 

6from .env.py.story import Story as PythonStory 

7 

8try: 

9 from .env.ipy.story import Story as JupyterStory 

10 import IPython # type: ignore 

11 

12 if not IPython.get_ipython(): # pragma: no cover 

13 raise ImportError("JupyterStory") 

14except ImportError as e: # pragma: no cover 

15 JupyterStory = None # type: ignore 

16 

17try: 

18 from .env.st.story import Story as StreamlitStory 

19 import streamlit as st 

20 

21 if not st.scriptrunner.script_run_context.get_script_run_ctx(): # pragma: no cover 

22 raise ImportError("StreamlitStory") 

23except ImportError: # pragma: no cover 

24 StreamlitStory = None # type: ignore 

25 

26 

27def get_story(): 

28 """A method for returning the appropriate Story for the environment.""" 

29 

30 return JupyterStory or StreamlitStory or PythonStory 

31 

32 

33Story = get_story()