Skip to content

Commit eba5a1f

Browse files
committed
fixed upload function for pres
1 parent 7121495 commit eba5a1f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

plotly/plotly/plotly.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ class presentation_ops:
15271527
@classmethod
15281528
def upload(cls, presentation, filename, sharing='public', auto_open=True):
15291529
"""
1530-
BETA function for uploading presentations to Plotly.
1530+
Function for uploading presentations to Plotly.
15311531
15321532
:param (dict) presentation: the JSON presentation to be uploaded. Use
15331533
plotly.presentation_objs.Presentation to create the presentation
@@ -1563,20 +1563,18 @@ def upload(cls, presentation, filename, sharing='public', auto_open=True):
15631563
lookup_res = v2.files.lookup(filename)
15641564
matching_file = json.loads(lookup_res.content)
15651565

1566-
if matching_file['filetype'] == 'presentation':
1567-
old_fid = matching_file['fid']
1568-
res = v2.spectacle_presentations.update(old_fid, data)
1569-
else:
1566+
if matching_file['filetype'] != 'spectacle_presentation':
15701567
raise exceptions.PlotlyError(
15711568
"'{filename}' is already a {filetype} in your account. "
1572-
"While you can overwrite presentation with the same name, "
1573-
"you can't change overwrite files with a different type. "
1574-
"Try deleting '{filename}' in your account or changing "
1575-
"the filename.".format(
1569+
"You can't overwrite a file that is not a spectacle_"
1570+
"presentation. Please pick another filename.".format(
15761571
filename=filename,
15771572
filetype=matching_file['filetype']
15781573
)
15791574
)
1575+
else:
1576+
old_fid = matching_file['fid']
1577+
res = v2.spectacle_presentations.update(old_fid, data)
15801578

15811579
except exceptions.PlotlyRequestError:
15821580
res = v2.spectacle_presentations.create(data)

0 commit comments

Comments
 (0)