FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-api/plotly/exceptions.py at master · ramosapf/python-api · GitHub
ramosapf
/
python-api
Public
forked from
plotly/plotly.py
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-api
/
plotly
/
exceptions.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
190 lines (148 loc) · 6.38 KB
Breadcrumbs
python-api
/
plotly
/
exceptions.py
Copy path
File metadata and controls
190 lines (148 loc) · 6.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
"""
exceptions
==========
A module that contains plotly's exception hierarchy.
message (required!) (should be root message + caller message)
info: (required!)
path_to_error (required!)
minimal_message (required!)
- minimal_message is set inside this module, should not be set elsewhere
- message is set inside this module, should not be set elsewhere
"""
## Base Plotly Error ##
class
PlotlyError
(
Exception
):
pass
## Would Cause Server Errors ##
class
PlotlyEmptyDataError
(
PlotlyError
):
pass
## Graph Objects Errors ##
class
PlotlyGraphObjectError
(
PlotlyError
):
def
__init__
(
self
,
message
=
''
,
path
=
None
,
notes
=
None
,
plain_message
=
''
):
self
.
message
=
message
self
.
plain_message
=
plain_message
if
isinstance
(
path
,
list
):
self
.
path
=
path
elif
path
is
None
:
self
.
path
=
[]
else
:
self
.
path
=
[
path
]
if
isinstance
(
notes
,
list
):
self
.
notes
=
notes
elif
notes
is
None
:
self
.
notes
=
[]
else
:
self
.
notes
=
[
notes
]
super
(
PlotlyGraphObjectError
,
self
).
__init__
(
message
)
self
.
prepare
()
def
add_note
(
self
,
note
):
if
isinstance
(
note
,
list
):
self
.
notes
+=
note
else
:
self
.
notes
+=
[
note
]
def
add_to_error_path
(
self
,
path
):
if
isinstance
(
path
,
list
):
self
.
path
=
path
+
self
.
path
else
:
self
.
path
=
[
path
]
+
self
.
path
def
prepare
(
self
):
message
=
self
.
message
message
+=
"
\n
\n
Path To Error:
\n
["
for
iii
,
key
in
enumerate
(
self
.
path
):
message
+=
repr
(
key
)
if
iii
<
len
(
self
.
path
)
-
1
:
message
+=
"]["
message
+=
"]"
if
len
(
self
.
notes
):
message
+=
"
\n
\n
Additional Notes:
\n
{0}"
.
format
(
"
\n
"
.
join
(
self
.
notes
))
if
len
(
self
.
args
)
>
1
:
self
.
args
=
(
message
,
self
.
args
[
1
:][
0
])
else
:
self
.
args
=
message
,
class
PlotlyDictKeyError
(
PlotlyGraphObjectError
):
def
__init__
(
self
,
obj
=
''
,
key
=
''
,
**
kwargs
):
message
=
(
"Invalid key, '{key}', for class, '{obj_name}'.
\n
\n
Run "
"'help(plotly.graph_objs.{obj_name})' for more information."
""
.
format
(
key
=
key
,
obj_name
=
obj
.
__class__
.
__name__
)
)
plain_message
=
(
"Invalid key, '{key}', found in '{obj}' object"
""
.
format
(
key
=
key
,
obj
=
obj
.
__class__
.
__name__
))
super
(
PlotlyDictKeyError
,
self
).
__init__
(
message
=
message
,
path
=
[
key
],
plain_message
=
plain_message
,
**
kwargs
)
class
PlotlyDictValueError
(
PlotlyGraphObjectError
):
def
__init__
(
self
,
obj
=
''
,
key
=
''
,
value
=
''
,
val_types
=
''
,
**
kwargs
):
message
=
(
"Invalid value type, '{value_name}', associated with key, "
"'{key}', for class, '{obj_name}'.
\n
Valid types for this key "
"are:
\n
'{val_types}'.
\n
\n
Run 'help(plotly.graph_objs.{obj_name})' "
"for more information."
.
format
(
key
=
key
,
value_name
=
value
.
__class__
.
__name__
,
val_types
=
val_types
,
obj_name
=
obj
.
__class__
.
__name__
)
)
plain_message
=
(
"Invalid value found in '{obj}' associated with key, "
"'{key}'"
.
format
(
key
=
key
,
obj
=
obj
.
__class__
.
__name__
))
super
(
PlotlyDictValueError
,
self
).
__init__
(
message
=
message
,
plain_message
=
plain_message
,
path
=
[
key
],
**
kwargs
)
class
PlotlyListEntryError
(
PlotlyGraphObjectError
):
def
__init__
(
self
,
obj
=
''
,
index
=
''
,
entry
=
''
,
**
kwargs
):
message
=
(
"The entry at index, '{0}', is invalid in a '{1}' object"
""
.
format
(
index
,
obj
.
__class__
.
__name__
)
)
plain_message
=
(
"Invalid entry found in '{obj}' object at index, '{index}'."
""
.
format
(
obj
=
obj
.
__class__
.
__name__
,
index
=
index
)
)
super
(
PlotlyListEntryError
,
self
).
__init__
(
message
=
message
,
plain_message
=
plain_message
,
path
=
[
index
],
**
kwargs
)
class
PlotlyDataTypeError
(
PlotlyGraphObjectError
):
def
__init__
(
self
,
obj
=
''
,
index
=
''
,
**
kwargs
):
message
=
(
"The entry at index, '{0}', is invalid because it does not "
"contain a valid 'type' key-value. This is required for valid "
"'{1}' lists."
.
format
(
index
,
obj
.
__class__
.
__name__
)
)
plain_message
=
(
"Invalid entry found in 'data' object at index, '{0}'. It "
"does not contain a valid 'type' key, required for 'data' "
"lists."
.
format
(
index
))
super
(
PlotlyDataTypeError
,
self
).
__init__
(
message
=
message
,
plain_message
=
plain_message
,
path
=
[
index
],
**
kwargs
)
## Local Config Errors ##
class
PlotlyLocalError
(
PlotlyError
):
pass
class
PlotlyLocalCredentialsError
(
PlotlyLocalError
):
def
__init__
(
self
):
message
=
(
"
\n
"
"Couldn't find a 'username', 'api-key' pair for you on your local "
"machine. To sign in temporarily (until you stop running Python), "
"run:
\n
"
">>> import plotly.plotly as py
\n
"
">>> py.sign_in('username', 'api_key')
\n
\n
"
"Even better, save your credentials permanently using the 'tools' "
"module:
\n
"
">>> import plotly.tools as tls
\n
"
">>> tls.set_credentials_file(username='username', api_key='api-key')
\n
\n
"
"For more help, see https://plot.ly/python.
\n
"
)
super
(
PlotlyLocalCredentialsError
,
self
).
__init__
(
message
)
## Server Errors ##
class
PlotlyServerError
(
PlotlyError
):
pass
class
PlotlyConnectionError
(
PlotlyServerError
):
pass
class
PlotlyCredentialError
(
PlotlyServerError
):
pass
class
PlotlyAccountError
(
PlotlyServerError
):
pass
class
PlotlyRateLimitError
(
PlotlyServerError
):
pass
Back
|
FazBrowse Home
|
New Git URL