Skip to content

Commit cc66004

Browse files
committed
add the changes from running 2to3
1 parent cc045dc commit cc66004

9 files changed

Lines changed: 67 additions & 60 deletions

File tree

plotly/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@
2626
2727
"""
2828

29-
from . version import __version__
30-
import graph_objs
31-
import plotly
32-
import tools
33-
import utils
29+
from plotly import plotly, graph_objs, tools, utils

plotly/graph_objs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
99
"""
10-
from graph_objs import *
10+
from .plotly.graph_objs.graph_objs import *
1111

1212
__all__ = ["Data",
1313
"Annotations",

plotly/graph_objs/graph_objs.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
import collections
2727
import json
2828
import textwrap
29+
2930
from .. import exceptions
30-
from .. import utils
31+
from plotly import utils
32+
3133

3234
__all__ = ["Data",
3335
"Annotations",
@@ -268,7 +270,7 @@ def __new__(mcs, name, bases, attrs):
268270
return super(DictMeta, mcs).__new__(mcs, name, bases, attrs)
269271

270272

271-
class PlotlyList(list):
273+
class PlotlyList(list, metaclass=ListMeta):
272274
"""A container for PlotlyDicts, inherits from standard list.
273275
274276
Plotly uses lists and dicts as collections to hold information about a
@@ -287,7 +289,6 @@ class PlotlyList(list):
287289
288290
289291
"""
290-
__metaclass__ = ListMeta
291292

292293
def __init__(self, *args):
293294
super(PlotlyList, self).__init__(*args)
@@ -493,7 +494,7 @@ def force_clean(self, caller=True):
493494
del_ct += 1
494495

495496

496-
class PlotlyDict(dict):
497+
class PlotlyDict(dict, metaclass=DictMeta):
497498
"""A base dict class for all objects that style a figure in plotly.
498499
499500
A PlotlyDict can be instantiated like any dict object. This class
@@ -506,7 +507,6 @@ class PlotlyDict(dict):
506507
Any available methods that hold for a dict hold for a PlotlyDict.
507508
508509
"""
509-
__metaclass__ = DictMeta
510510

511511
def __init__(self, *args, **kwargs):
512512
class_name = self.__class__.__name__
@@ -552,7 +552,7 @@ def update(self, dict1=None, **dict2):
552552
self.to_graph_objs()
553553

554554
if dict1 is not None:
555-
for key, val in dict1.items():
555+
for key, val in list(dict1.items()):
556556
if key in self:
557557
if isinstance(self[key], (PlotlyDict, PlotlyList)):
558558
self[key].update(val)
@@ -562,7 +562,7 @@ def update(self, dict1=None, **dict2):
562562
self[key] = val
563563

564564
if len(dict2):
565-
for key, val in dict2.items():
565+
for key, val in list(dict2.items()):
566566
if key in self:
567567
if isinstance(self[key], (PlotlyDict, PlotlyList)):
568568
self[key].update(val)
@@ -592,7 +592,7 @@ def strip_style(self):
592592
"""
593593
self.to_graph_objs()
594594
obj_key = NAME_TO_KEY[self.__class__.__name__]
595-
keys = self.keys()
595+
keys = list(self.keys())
596596
for key in keys:
597597
if isinstance(self[key], (PlotlyDict, PlotlyList)):
598598
self[key].strip_style()
@@ -611,7 +611,7 @@ def get_data(self):
611611
class_name = self.__class__.__name__
612612
obj_key = NAME_TO_KEY[class_name]
613613
d = dict()
614-
for key, val in self.items():
614+
for key, val in list(self.items()):
615615
if isinstance(val, (PlotlyDict, PlotlyList)):
616616
d[key] = val.get_data()
617617
else:
@@ -620,13 +620,13 @@ def get_data(self):
620620
d[key] = val
621621
except KeyError:
622622
pass
623-
keys = d.keys()
623+
keys = list(d.keys())
624624
for key in keys:
625625
if isinstance(d[key], (dict, list)):
626626
if len(d[key]) == 0:
627627
del d[key]
628628
if len(d) == 1:
629-
d = d.values()[0]
629+
d = list(d.values())[0]
630630
return d
631631

632632
def to_graph_objs(self, caller=True):
@@ -639,7 +639,7 @@ def to_graph_objs(self, caller=True):
639639
640640
"""
641641
info_key = NAME_TO_KEY[self.__class__.__name__]
642-
keys = self.keys()
642+
keys = list(self.keys())
643643
for key in keys:
644644
if isinstance(self[key], (PlotlyDict, PlotlyList)):
645645
try:
@@ -665,7 +665,7 @@ def to_graph_objs(self, caller=True):
665665
val_types=val_types,
666666
notes="value needs to be dictionary-like"
667667
)
668-
for k, v in self.pop(key).items():
668+
for k, v in list(self.pop(key).items()):
669669
obj[k] = v # finish up momentarily...
670670
else: # if not PlotlyDict, it MUST be a PlotlyList
671671
if not isinstance(self[key], list):
@@ -708,7 +708,7 @@ def validate(self, caller=True): # TODO: validate values too?
708708
err.prepare()
709709
raise
710710
obj_key = NAME_TO_KEY[self.__class__.__name__]
711-
for key, val in self.items():
711+
for key, val in list(self.items()):
712712
if isinstance(val, (PlotlyDict, PlotlyList)):
713713
try:
714714
val.validate(caller=False)
@@ -843,7 +843,7 @@ def force_clean(self, caller=True):
843843
del_keys = [key for key in self if str(key) not in INFO[obj_key]]
844844
for key in del_keys:
845845
del self[key]
846-
keys = self.keys()
846+
keys = list(self.keys())
847847
for key in keys:
848848
try:
849849
self[key].force_clean(caller=False) # TODO: add error handling
@@ -889,7 +889,7 @@ def to_graph_objs(self, caller=True): # TODO TODO TODO! check logic!
889889
index=index
890890
)
891891
obj = NAME_TO_CLASS[obj_name]() # don't hide if KeyError!
892-
for k, v in entry.items():
892+
for k, v in list(entry.items()):
893893
obj[k] = v
894894
self[index] = obj
895895
if not isinstance(self[index], PlotlyTrace): # Trace ONLY!!!
@@ -939,7 +939,7 @@ def to_graph_objs(self, caller=True):
939939
)
940940
elif isinstance(entry, dict):
941941
obj = Annotation()
942-
for k, v in entry.items():
942+
for k, v in list(entry.items()):
943943
obj[k] = v
944944
self[index] = obj
945945
else:
@@ -1253,7 +1253,7 @@ def to_graph_objs(self, caller=True):
12531253
appropriate `kind`.
12541254
12551255
"""
1256-
keys = self.keys()
1256+
keys = list(self.keys())
12571257
for key in keys:
12581258
if key[:5] in ['xaxis', 'yaxis']: # allows appended integers!
12591259
try:
@@ -1267,7 +1267,7 @@ def to_graph_objs(self, caller=True):
12671267
obj = XAxis()
12681268
else:
12691269
obj = YAxis()
1270-
for k, v in self.pop(key).items():
1270+
for k, v in list(self.pop(key).items()):
12711271
obj[k] = v
12721272
self[key] = obj # call to super will call 'to_graph_objs'
12731273
super(Layout, self).to_graph_objs(caller=caller)
@@ -1366,7 +1366,7 @@ def force_clean(self, caller=True): # TODO: can't make call to super...
13661366
del self[key]
13671367
else:
13681368
del self[key]
1369-
keys = self.keys()
1369+
keys = list(self.keys())
13701370
for key in keys:
13711371
try:
13721372
self[key].force_clean(caller=False) # TODO error handling??

plotly/matplotlylib/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@
99
'tools' module or 'plotly' package.
1010
1111
"""
12-
from . renderer import PlotlyRenderer
13-
from . mplexporter import Exporter

plotly/matplotlylib/renderer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
88
"""
99
import warnings
10-
from . mplexporter import Exporter, Renderer
10+
11+
from . mplexporter import Renderer
1112
from . import mpltools
12-
from .. graph_objs import *
13+
from ..plotly.graph_objs import *
14+
15+
1316

1417
# Warning format
1518
def warning_on_one_line(message, category, filename, lineno, file=None, line=None):

plotly/plotly/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
verifiable account (username/api-key pair) and a network connection.
88
99
"""
10-
from plotly import *
10+
from .plotly.plotly.plotly import *
1111

1212
__all__ = ["sign_in", "update_plot_options", "get_plot_options",
1313
"get_credentials", "iplot", "plot", "iplot_mpl", "plot_mpl",

plotly/plotly/plotly.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@
1414
4. update plot_options with kwargs!
1515
1616
"""
17-
import requests
18-
import chunked_requests
1917
import json
2018
import warnings
2119
import copy
2220
import os
21+
22+
import requests
23+
24+
from . import chunked_requests
2325
from .. import utils # TODO make non-relative
2426
from .. import tools
2527
from .. import exceptions
26-
from .. import version
28+
from plotly import version
29+
2730

2831
__all__ = ["sign_in", "update_plot_options", "get_plot_options",
2932
"get_credentials", "iplot", "plot", "iplot_mpl", "plot_mpl",
@@ -160,7 +163,7 @@ def plot(figure_or_data, validate=True, **plot_options):
160163
"plot option.\nHere's why you're "
161164
"seeing this error:\n\n{}".format(err))
162165
for entry in figure['data']:
163-
for key, val in entry.items():
166+
for key, val in list(entry.items()):
164167
try:
165168
if len(val) > 40000:
166169
msg = ("Woah there! Look at all those points! Due to "
@@ -658,11 +661,11 @@ def _send_to_plotly(figure, **plot_options):
658661
r.raise_for_status()
659662
r = json.loads(r.text)
660663
if 'error' in r and r['error'] != '':
661-
print(r['error'])
664+
print((r['error']))
662665
if 'warning' in r and r['warning'] != '':
663666
warnings.warn(r['warning'])
664667
if 'message' in r and r['message'] != '':
665-
print(r['message'])
668+
print((r['message']))
666669

667670
return r
668671

0 commit comments

Comments
 (0)