@@ -137,7 +137,7 @@ def strip_style(self):
137
137
stripping process, though they made be left empty. This is allowable.
138
138
139
139
Keys that will be stripped in this process are tagged with
140
- `'type': 'style'` in the INFO dictionary listed in graph_objs_meta.py .
140
+ `'type': 'style'` in graph_objs_meta.json .
141
141
142
142
This process first attempts to convert nested collections from dicts
143
143
or lists to subclasses of PlotlyList/PlotlyDict. This process forces
@@ -363,7 +363,7 @@ def strip_style(self):
363
363
stripping process, though they made be left empty. This is allowable.
364
364
365
365
Keys that will be stripped in this process are tagged with
366
- `'type': 'style'` in the INFO dictionary listed in graph_objs_meta.py .
366
+ `'type': 'style'` in graph_objs_meta.json .
367
367
368
368
This process first attempts to convert nested collections from dicts
369
369
or lists to subclasses of PlotlyList/PlotlyDict. This process forces
@@ -382,7 +382,7 @@ def strip_style(self):
382
382
self [key ].strip_style ()
383
383
else :
384
384
try :
385
- if INFO [obj_key ][key ]['type' ] == 'style' :
385
+ if INFO [obj_key ]['keymeta' ][ key ]['type' ] == 'style' :
386
386
if isinstance (self [key ], six .string_types ):
387
387
del self [key ]
388
388
elif not hasattr (self [key ], '__iter__' ):
@@ -403,7 +403,7 @@ def get_data(self):
403
403
else :
404
404
try :
405
405
# TODO: Update the JSON
406
- if INFO [obj_key ][key ]['type' ] == 'data' :
406
+ if INFO [obj_key ]['keymeta' ][ key ]['type' ] == 'data' :
407
407
d [key ] = val
408
408
except KeyError :
409
409
pass
@@ -446,14 +446,17 @@ def to_graph_objs(self, caller=True):
446
446
err .add_to_error_path (key )
447
447
err .prepare ()
448
448
raise
449
- elif key in INFO [info_key ] and 'type' in INFO [info_key ][key ]:
450
- if INFO [info_key ][key ]['type' ] == 'object' :
449
+ elif (key in INFO [info_key ]['keymeta' ] and
450
+ 'type' in INFO [info_key ]['keymeta' ][key ]):
451
+ if INFO [info_key ]['keymeta' ][key ]['type' ] == 'object' :
451
452
class_name = KEY_TO_NAME [key ]
452
453
obj = _factory (class_name )
453
454
if isinstance (obj , PlotlyDict ):
454
455
if not isinstance (self [key ], dict ):
455
456
try :
456
- val_types = INFO [info_key ][key ]['val_types' ]
457
+ val_types = (
458
+ INFO [info_key ]['keymeta' ][key ]['val_types' ]
459
+ )
457
460
except KeyError :
458
461
val_types = 'undocumented'
459
462
raise exceptions .PlotlyDictValueError (
@@ -468,7 +471,9 @@ def to_graph_objs(self, caller=True):
468
471
else : # if not PlotlyDict, it MUST be a PlotlyList
469
472
if not isinstance (self [key ], list ):
470
473
try :
471
- val_types = INFO [info_key ][key ]['val_types' ]
474
+ val_types = (
475
+ INFO [info_key ]['keymeta' ][key ]['val_types' ]
476
+ )
472
477
except KeyError :
473
478
val_types = 'undocumented'
474
479
raise exceptions .PlotlyDictValueError ( # TODO!!!
@@ -491,7 +496,7 @@ def validate(self, caller=True): # TODO: validate values too?
491
496
"""Recursively check the validity of the keys in a PlotlyDict.
492
497
493
498
The valid keys constitute the entries in each object
494
- dictionary in INFO stored in graph_objs_meta.py.
499
+ dictionary in graph_objs_meta.json
495
500
496
501
The validation process first requires that all nested collections be
497
502
converted to the appropriate subclass of PlotlyDict/PlotlyList. Then,
@@ -515,12 +520,13 @@ def validate(self, caller=True): # TODO: validate values too?
515
520
err .prepare ()
516
521
raise
517
522
else :
518
- if key in INFO [obj_key ]:
519
- if 'type' not in INFO [obj_key ][key ]:
523
+ if key in INFO [obj_key ][ 'keymeta' ] :
524
+ if 'type' not in INFO [obj_key ]['keymeta' ][ key ]:
520
525
continue # TODO: 'type' may not be documented yet!
521
- if INFO [obj_key ][key ]['type' ] == 'object' :
526
+ if INFO [obj_key ]['keymeta' ][ key ]['type' ] == 'object' :
522
527
try :
523
- val_types = INFO [obj_key ][key ]['val_types' ]
528
+ val_types = (
529
+ INFO [obj_key ]['keymeta' ][key ]['val_types' ])
524
530
except KeyError :
525
531
val_types = 'undocumented'
526
532
raise exceptions .PlotlyDictValueError (
@@ -531,15 +537,16 @@ def validate(self, caller=True): # TODO: validate values too?
531
537
)
532
538
else :
533
539
matching_objects = [obj for obj in
534
- INFO if key in INFO [obj ]]
540
+ INFO if key in INFO [obj ][ 'keymeta' ] ]
535
541
notes = ''
536
542
if len (matching_objects ):
537
543
notes += "That key is valid only in these objects:\n \n "
538
544
for obj in matching_objects :
539
545
notes += "\t {0}" .format (KEY_TO_NAME [obj ])
540
546
try :
541
547
notes += '({0}="{1}")\n ' .format (
542
- repr (key ), INFO [obj ][key ]['val_types' ])
548
+ repr (key ),
549
+ INFO [obj ]['keymeta' ][key ]['val_types' ])
543
550
except KeyError :
544
551
notes += '({0}="..")\n ' .format (repr (key ))
545
552
notes .expandtabs ()
@@ -572,7 +579,8 @@ def to_string(self, level=0, indent=4, eol='\n',
572
579
string = "{name}(" .format (name = self .__class__ .__name__ )
573
580
index = 0
574
581
obj_key = NAME_TO_KEY [self .__class__ .__name__ ]
575
- for key in INFO [obj_key ]: # this sets the order of the keys! nice.
582
+ # This sets the order of the keys! nice.
583
+ for key in INFO [obj_key ]['keymeta' ]:
576
584
if key in self :
577
585
index += 1
578
586
string += "{eol}{indent}{key}=" .format (
@@ -637,8 +645,9 @@ def get_ordered(self, caller=True):
637
645
obj_type = NAME_TO_KEY [self .__class__ .__name__ ]
638
646
ordered_dict = OrderedDict ()
639
647
# grab keys like xaxis1, xaxis2, etc...
640
- unordered_keys = [key for key in self if key not in INFO [obj_type ]]
641
- for key in INFO [obj_type ]:
648
+ unordered_keys = [key for key in self
649
+ if key not in INFO [obj_type ]['keymeta' ]]
650
+ for key in INFO [obj_type ]['keymeta' ]:
642
651
if key in self :
643
652
if isinstance (self [key ], (PlotlyDict , PlotlyList )):
644
653
ordered_dict [key ] = self [key ].get_ordered (caller = False )
@@ -664,7 +673,8 @@ def force_clean(self, caller=True):
664
673
obj_key = NAME_TO_KEY [self .__class__ .__name__ ]
665
674
if caller :
666
675
self .to_graph_objs (caller = False )
667
- del_keys = [key for key in self if str (key ) not in INFO [obj_key ]]
676
+ del_keys = [key for key in self
677
+ if str (key ) not in INFO [obj_key ]['keymeta' ]]
668
678
for key in del_keys :
669
679
del self [key ]
670
680
keys = list (self .keys ())
@@ -935,7 +945,7 @@ def to_string(self, level=0, indent=4, eol='\n',
935
945
string = "{name}(" .format (name = self .__class__ .__name__ )
936
946
index = 0
937
947
obj_key = NAME_TO_KEY [self .__class__ .__name__ ]
938
- for key in INFO [obj_key ]:
948
+ for key in INFO [obj_key ][ 'keymeta' ] :
939
949
if key in self :
940
950
string += "{eol}{indent}{key}=" .format (
941
951
eol = eol ,
@@ -984,7 +994,8 @@ def to_string(self, level=0, indent=4, eol='\n',
984
994
index += 1
985
995
if index == len (self ): # TODO: extraneous...
986
996
break
987
- left_over_keys = [key for key in self if key not in INFO [obj_key ]]
997
+ left_over_keys = [key for key in self
998
+ if key not in INFO [obj_key ]['keymeta' ]]
988
999
left_over_keys .sort ()
989
1000
for key in left_over_keys :
990
1001
string += "{eol}{indent}{key}=" .format (
@@ -1023,7 +1034,8 @@ def force_clean(self, caller=True): # TODO: can't make call to super...
1023
1034
obj_key = NAME_TO_KEY [self .__class__ .__name__ ]
1024
1035
if caller :
1025
1036
self .to_graph_objs (caller = False )
1026
- del_keys = [key for key in self if str (key ) not in INFO [obj_key ]]
1037
+ del_keys = [key for key in self
1038
+ if str (key ) not in INFO [obj_key ]['keymeta' ]]
1027
1039
for key in del_keys :
1028
1040
if (key [:5 ] == 'xaxis' ) or (key [:5 ] == 'yaxis' ):
1029
1041
try :
0 commit comments