-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy path__init__.py
57 lines (41 loc) · 1.43 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import warnings
import functools
_future_flags = set()
def _assert_plotly_not_imported():
import sys
if 'plotly' in sys.modules:
raise ImportError("""\
The _plotly_future_ module must be imported before the plotly module""")
warnings.filterwarnings(
'default',
'.*?is deprecated, please use chart_studio*',
DeprecationWarning
)
def _chart_studio_warning(submodule):
if 'extract_chart_studio' in _future_flags:
warnings.warn(
'The plotly.{submodule} module is deprecated, '
'please use chart_studio.{submodule} instead'
.format(submodule=submodule),
DeprecationWarning,
stacklevel=2)
def _chart_studio_deprecation(fn):
fn_name = fn.__name__
fn_module = fn.__module__
plotly_name = '.'.join(
['plotly'] + fn_module.split('.')[1:] + [fn_name])
chart_studio_name = '.'.join(
['chart_studio'] + fn_module.split('.')[1:] + [fn_name])
msg = """\
{plotly_name} is deprecated, please use {chart_studio_name}\
""".format(plotly_name=plotly_name, chart_studio_name=chart_studio_name)
@functools.wraps(fn)
def wrapper(*args, **kwargs):
if 'extract_chart_studio' in _future_flags:
warnings.warn(
msg,
DeprecationWarning,
stacklevel=2)
return fn(*args, **kwargs)
return wrapper
__all__ = ['_future_flags', '_chart_studio_warning']