Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfa7468

Browse files
committed
No newline for empty objects in to_string now. updated refs.
1 parent e9d22cf commit cfa7468

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

plotly/graph_objs/graph_objs.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
415415
416416
"""
417417
self.to_graph_objs()
418+
if not len(self):
419+
return "{name}()".format(name=self.__class__.__name__)
418420
string = "{name}([{eol}{indent}".format(
419421
name=self.__class__.__name__,
420422
eol=eol,
@@ -429,8 +431,7 @@ def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
429431
string += ",{eol}{indent}".format(
430432
eol=eol,
431433
indent=' ' * indent * (level + 1))
432-
string += "{eol}{indent}])".format(eol=eol,
433-
indent=' ' * indent * level)
434+
string += "{eol}{indent}])".format(eol=eol, indent=' ' * indent * level)
434435
return string
435436

436437
def force_clean(self, caller=True):
@@ -720,10 +721,12 @@ def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
720721
721722
"""
722723
self.to_graph_objs() # todo, consider catching and re-raising?
724+
if not len(self):
725+
return "{name}()".format(name=self.__class__.__name__)
723726
string = "{name}(".format(name=self.__class__.__name__)
724727
index = 0
725728
obj_key = NAME_TO_KEY[self.__class__.__name__]
726-
for key in INFO[obj_key]:
729+
for key in INFO[obj_key]: # this sets the order of the keys! nice.
727730
if key in self:
728731
string += "{eol}{indent}{key}=".format(
729732
eol=eol,
@@ -1212,6 +1215,8 @@ def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
12121215
"""
12131216
# TODO: can't call super
12141217
self.to_graph_objs()
1218+
if not len(self):
1219+
return "{name}()".format(name=self.__class__.__name__)
12151220
string = "{name}(".format(name=self.__class__.__name__)
12161221
index = 0
12171222
obj_key = NAME_TO_KEY[self.__class__.__name__]

plotly/graph_reference

Submodule graph_reference updated from e3b2a62 to 49ab274

0 commit comments

Comments
 (0)