Coverage for src/ipyvizzustory/__init__.py: 100%
12 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-25 14:00 +0100
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-25 14:00 +0100
1"""
2Build, present and share animated data stories in `Jupyter Notebook` and similar environments.
4`ipyvizzu-story` package consists of two main parts:
6* [Storylib][ipyvizzustory.storylib]: environment independent modules
7* [Env][ipyvizzustory.env]: environment dependent modules
9`ipyvizzu-story` package tries to figure out the environment and import the correct type of `Story`,
10however `Story` could be imported with full path.
12`ipyvizzu-story` package imports the following objects in `__init__.py`:
15* `Story` from [Env.py.story][ipyvizzustory.env.py.story] or
16 [Env.ipy.story][ipyvizzustory.env.ipy.story] or
17 [Env.st.story][ipyvizzustory.env.st.story]
18* [Step][ipyvizzustory.storylib.story.Step]
19* [Slide][ipyvizzustory.storylib.story.Slide]
20"""
23from .storylib.story import Step, Slide
25from .env.py.story import Story as PythonStory
27try:
28 from .env.ipy.story import Story as JupyterStory
29 import IPython # type: ignore
31 if not IPython.get_ipython(): # pragma: no cover
32 raise ImportError("JupyterStory")
33except ImportError as e: # pragma: no cover
34 JupyterStory = None # type: ignore
36try:
37 from .env.st.story import Story as StreamlitStory
38 import streamlit as st
40 if not st.scriptrunner.script_run_context.get_script_run_ctx(): # pragma: no cover
41 raise ImportError("StreamlitStory")
42except ImportError: # pragma: no cover
43 StreamlitStory = None # type: ignore
46def get_story():
47 """
48 A method for returning the appropriate Story for the environment.
50 Returns:
51 (Union[ipyvizzustory.env.py.story.Story, ipyvizzustory.env.ipy.story.Story, ipyvizzustory.env.st.story.Story]):
52 The appropriate `Story` for the environment.
53 """ # pylint: disable=line-too-long
55 return JupyterStory or StreamlitStory or PythonStory
58Story = get_story()
59"""
60Available types:
62* [Jupyter/IPython Story][ipyvizzustory.env.ipy.story.Story]
63* [Streamlit Story][ipyvizzustory.env.st.story.Story]
64* [Python Story][ipyvizzustory.env.py.story.Story]
65"""