Skip to content

Commit c8d731e

Browse files
committed
part of chris' comments
1 parent 06bb679 commit c8d731e

File tree

4 files changed

+153
-149
lines changed

4 files changed

+153
-149
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [2.1.1] - 2017-10-20
5+
## [2.2.0] - 2017-10-20
66
### Added
77
- NEW Presentations API for Python! Run `help(plotly.presentation_objs.Presentations)` for help or check out the new [documentation](https://plot.ly/python/presentations-api/)
88

plotly/figure_factory/_scatterplot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import absolute_import
22

3-
from plotly import exceptions, optional_imports
3+
from plotly import colors, exceptions, optional_imports
44
from plotly.figure_factory import utils
55
from plotly.graph_objs import graph_objs
66
from plotly.tools import make_subplots
@@ -386,9 +386,9 @@ def scatterplot_theme(dataframe, headers, diag, size, height, width, title,
386386

387387
# Convert colormap to list of n RGB tuples
388388
if colormap_type == 'seq':
389-
foo = utils.color_parser(colormap, utils.unlabel_rgb)
389+
foo = colors.color_parser(colormap, colors.unlabel_rgb)
390390
foo = utils.n_colors(foo[0], foo[1], n_colors_len)
391-
theme = utils.color_parser(foo, utils.label_rgb)
391+
theme = colors.color_parser(foo, colors.label_rgb)
392392

393393
if colormap_type == 'cat':
394394
# leave list of colors the same way
@@ -556,9 +556,9 @@ def scatterplot_theme(dataframe, headers, diag, size, height, width, title,
556556

557557
# Convert colormap to list of n RGB tuples
558558
if colormap_type == 'seq':
559-
foo = utils.color_parser(colormap, utils.unlabel_rgb)
559+
foo = colors.color_parser(colormap, colors.unlabel_rgb)
560560
foo = utils.n_colors(foo[0], foo[1], len(intervals))
561-
theme = utils.color_parser(foo, utils.label_rgb)
561+
theme = colors.color_parser(foo, colors.label_rgb)
562562

563563
if colormap_type == 'cat':
564564
# leave list of colors the same way

plotly/plotly/plotly.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
'sharing': files.FILE_CONTENT[files.CONFIG_FILE]['sharing']
4848
}
4949

50+
SHARING_ERROR_MSG = (
51+
"Whoops, sharing can only be set to either 'public', 'private', or "
52+
"'secret'."
53+
)
54+
5055
# test file permissions and make sure nothing is corrupted
5156
tools.ensure_local_plotly_files()
5257

@@ -1530,28 +1535,31 @@ def upload(cls, presentation, filename, sharing='public', auto_open=True):
15301535
Function for uploading presentations to Plotly.
15311536
15321537
:param (dict) presentation: the JSON presentation to be uploaded. Use
1533-
plotly.presentation_objs.Presentation to create the presentation
1534-
from a string.
1538+
plotly.presentation_objs.Presentation to create presentations
1539+
from a Markdown-like string.
15351540
:param (str) filename: the name of the presentation to be saved in
15361541
your Plotly account. Will overwrite a presentation of the same
15371542
name if it already exists in your files.
15381543
:param (str) sharing: can be set to either 'public', 'private'
15391544
or 'secret'. If 'public', your presentation will be viewable by
15401545
all other users. If 'private' only you can see your presentation.
1541-
If 'secret', the url will be returned with a sharekey appended
1542-
to the url. Anyone with the url may view the presentation.
1546+
If it is set to 'secret', the url will be returned with a string
1547+
of random characters appended to the url which is called a
1548+
sharekey. The point of a sharekey is that it makes the url very
1549+
hard to guess, but anyone with the url can view the presentation.
15431550
:param (bool) auto_open: automatically opens the presentation in the
15441551
browser.
15451552
15461553
See the documentation online for examples.
15471554
"""
15481555
if sharing == 'public':
15491556
world_readable = True
1550-
elif sharing == 'private':
1551-
world_readable = False
1552-
elif sharing == 'secret':
1557+
elif sharing in ['private', 'secret']:
15531558
world_readable = False
1554-
1559+
else:
1560+
raise exceptions.PlotlyError(
1561+
SHARING_ERROR_MSG
1562+
)
15551563
data = {
15561564
'content': json.dumps(presentation),
15571565
'filename': filename,
@@ -1561,6 +1569,7 @@ def upload(cls, presentation, filename, sharing='public', auto_open=True):
15611569
# lookup if pre-existing filename already exists
15621570
try:
15631571
lookup_res = v2.files.lookup(filename)
1572+
lookup_res.raise_for_status()
15641573
matching_file = json.loads(lookup_res.content)
15651574

15661575
if matching_file['filetype'] != 'spectacle_presentation':
@@ -1783,8 +1792,7 @@ def create_animations(figure, filename=None, sharing='public', auto_open=True):
17831792
body['share_key_enabled'] = True
17841793
else:
17851794
raise exceptions.PlotlyError(
1786-
"Whoops, sharing can only be set to either 'public', 'private', "
1787-
"or 'secret'."
1795+
SHARING_ERROR_MSG
17881796
)
17891797

17901798
response = v2.plots.create(body)

0 commit comments

Comments
 (0)