Skip to content

Commit e57d5c6

Browse files
committed
everything works but graph objs and __init__ is deleted
1 parent 5d493f9 commit e57d5c6

File tree

13 files changed

+2227
-954
lines changed

13 files changed

+2227
-954
lines changed

_plotly_utils/basevalidators.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
except ImportError:
2828
pass
2929

30-
# TODO: replace re.fullmatch with function below
30+
3131
# back-port of fullmatch from Py3.4+
3232
def fullmatch(regex, string, flags=0):
3333
"""Emulate python-3.4 re.fullmatch()."""
34-
return re.match("(?:" + regex + r")\Z", string, flags=flags)
34+
return re.match("(?:" + regex.pattern + r")\Z", string, flags=flags)
3535

3636

3737
# Utility functions
@@ -274,7 +274,7 @@ class DataArrayValidator(BaseValidator):
274274
"""
275275

276276
def __init__(self, plotly_name, parent_name, **kwargs):
277-
super().__init__(
277+
super(DataArrayValidator, self).__init__(
278278
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
279279

280280
def description(self):
@@ -320,7 +320,7 @@ def __init__(self,
320320
array_ok=False,
321321
coerce_number=False,
322322
**kwargs):
323-
super().__init__(
323+
super(EnumeratedValidator, self).__init__(
324324
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
325325

326326
# Save params
@@ -440,7 +440,8 @@ def in_values(self, e):
440440
is_str = isinstance(e, str)
441441
for v, regex in zip(self.values, self.val_regexs):
442442
if is_str and regex:
443-
in_values = regex.fullmatch(e) is not None
443+
in_values = fullmatch(regex, e) is not None
444+
#in_values = regex.fullmatch(e) is not None
444445
else:
445446
in_values = e == v
446447

@@ -483,7 +484,7 @@ class BooleanValidator(BaseValidator):
483484
"""
484485

485486
def __init__(self, plotly_name, parent_name, **kwargs):
486-
super().__init__(
487+
super(BooleanValidator, self).__init__(
487488
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
488489

489490
def description(self):
@@ -525,7 +526,7 @@ def __init__(self,
525526
max=None,
526527
array_ok=False,
527528
**kwargs):
528-
super().__init__(
529+
super(NumberValidator, self).__init__(
529530
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
530531

531532
# Handle min
@@ -646,7 +647,7 @@ def __init__(self,
646647
max=None,
647648
array_ok=False,
648649
**kwargs):
649-
super().__init__(
650+
super(IntegerValidator, self).__init__(
650651
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
651652

652653
# Handle min
@@ -767,7 +768,7 @@ def __init__(self,
767768
array_ok=False,
768769
values=None,
769770
**kwargs):
770-
super().__init__(
771+
super(StringValidator, self).__init__(
771772
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
772773
self.no_blank = no_blank
773774
self.strict = strict
@@ -934,7 +935,7 @@ def __init__(self,
934935
array_ok=False,
935936
colorscale_path=None,
936937
**kwargs):
937-
super().__init__(
938+
super(ColorValidator, self).__init__(
938939
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
939940

940941
self.array_ok = array_ok
@@ -1062,10 +1063,12 @@ def perform_validate_coerce(v, allow_number=None):
10621063
# Remove spaces so regexes don't need to bother with them.
10631064
v_normalized = v.replace(' ', '').lower()
10641065

1065-
if ColorValidator.re_hex.fullmatch(v_normalized):
1066+
# if ColorValidator.re_hex.fullmatch(v_normalized):
1067+
if fullmatch(ColorValidator.re_hex, v_normalized):
10661068
# valid hex color (e.g. #f34ab3)
10671069
return v
1068-
elif ColorValidator.re_rgb_etc.fullmatch(v_normalized):
1070+
elif fullmatch(ColorValidator.re_rgb_etc, v_normalized):
1071+
# elif ColorValidator.re_rgb_etc.fullmatch(v_normalized):
10691072
# Valid rgb(a), hsl(a), hsv(a) color
10701073
# (e.g. rgba(10, 234, 200, 50%)
10711074
return v
@@ -1090,7 +1093,7 @@ class ColorlistValidator(BaseValidator):
10901093
"""
10911094

10921095
def __init__(self, plotly_name, parent_name, **kwargs):
1093-
super().__init__(
1096+
super(ColorlistValidator, self).__init__(
10941097
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
10951098

10961099
def description(self):
@@ -1148,7 +1151,7 @@ class ColorscaleValidator(BaseValidator):
11481151
]
11491152

11501153
def __init__(self, plotly_name, parent_name, **kwargs):
1151-
super().__init__(
1154+
super(ColorscaleValidator, self).__init__(
11521155
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
11531156

11541157
def description(self):
@@ -1226,7 +1229,7 @@ class AngleValidator(BaseValidator):
12261229
"""
12271230

12281231
def __init__(self, plotly_name, parent_name, **kwargs):
1229-
super().__init__(
1232+
super(AngleValidator, self).__init__(
12301233
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
12311234

12321235
def description(self):
@@ -1267,7 +1270,7 @@ class SubplotidValidator(BaseValidator):
12671270
"""
12681271

12691272
def __init__(self, plotly_name, parent_name, dflt, **kwargs):
1270-
super().__init__(
1273+
super(SubplotidValidator, self).__init__(
12711274
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
12721275
self.base = dflt
12731276
self.regex = dflt + "(\d*)"
@@ -1289,7 +1292,8 @@ def validate_coerce(self, v):
12891292
elif not isinstance(v, str):
12901293
self.raise_invalid_val(v)
12911294
else:
1292-
match = re.fullmatch(self.regex, v)
1295+
# match = re.fullmatch(self.regex, v)
1296+
match = fullmatch(self.regex, v)
12931297
if not match:
12941298
is_valid = False
12951299
else:
@@ -1334,7 +1338,7 @@ def __init__(self,
13341338
extras=None,
13351339
array_ok=False,
13361340
**kwargs):
1337-
super().__init__(
1341+
super(FlaglistValidator, self).__init__(
13381342
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
13391343
self.flags = flags
13401344
self.extras = extras if extras is not None else []
@@ -1440,7 +1444,7 @@ def __init__(self,
14401444
values=None,
14411445
array_ok=False,
14421446
**kwargs):
1443-
super().__init__(
1447+
super(AnyValidator, self).__init__(
14441448
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
14451449
self.values = values
14461450
self.array_ok = array_ok
@@ -1483,7 +1487,7 @@ def __init__(self,
14831487
items,
14841488
free_length=None,
14851489
**kwargs):
1486-
super().__init__(
1490+
super(InfoArrayValidator, self).__init__(
14871491
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
14881492
self.items = items
14891493

@@ -1568,7 +1572,7 @@ class LiteralValidator(BaseValidator):
15681572
Validator for readonly literal values
15691573
"""
15701574
def __init__(self, plotly_name, parent_name, **kwargs):
1571-
super().__init__(plotly_name=plotly_name,
1575+
super(LiteralValidator, self).__init__(plotly_name=plotly_name,
15721576
parent_name=parent_name,
15731577
**kwargs)
15741578

@@ -1588,7 +1592,7 @@ class ImageUriValidator(BaseValidator):
15881592
pass
15891593

15901594
def __init__(self, plotly_name, parent_name, **kwargs):
1591-
super().__init__(
1595+
super(ImageUriValidator, self).__init__(
15921596
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
15931597

15941598
def description(self):
@@ -1634,7 +1638,7 @@ class CompoundValidator(BaseValidator):
16341638

16351639
def __init__(self, plotly_name, parent_name, data_class_str, data_docs,
16361640
**kwargs):
1637-
super(BaseValidator, self).__init__(
1641+
super(CompoundValidator, self).__init__(
16381642
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
16391643

16401644
# Save element class string
@@ -1707,7 +1711,7 @@ class CompoundArrayValidator(BaseValidator):
17071711

17081712
def __init__(self, plotly_name, parent_name, data_class_str, data_docs,
17091713
**kwargs):
1710-
super().__init__(
1714+
super(CompoundArrayValidator, self).__init__(
17111715
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
17121716

17131717
# Save element class string
@@ -1774,7 +1778,7 @@ def validate_coerce(self, v):
17741778
class BaseDataValidator(BaseValidator):
17751779

17761780
def __init__(self, class_strs_map, plotly_name, parent_name, **kwargs):
1777-
super().__init__(
1781+
super(BaseDataValidator, self).__init__(
17781782
plotly_name=plotly_name, parent_name=parent_name, **kwargs)
17791783
self.class_strs_map = class_strs_map
17801784
self._class_map = None

codegen/compatibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def __init__(self, *args, **kwargs):
131131
{depr_msg}
132132
\"\"\"
133133
warnings.warn(\"\"\"{depr_msg}\"\"\", DeprecationWarning)
134-
super().__init__(*args, **kwargs)\n\n\n""")
134+
super({class_name}, self).__init__(*args, **kwargs)\n\n\n""")
135135

136136
# Return source string
137137
# --------------------

codegen/datatypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def __init__(self""")
190190
add_docstring(buffer, node, header=header)
191191

192192
buffer.write(f"""
193-
super({node.name_base_datatype}, self).__init__('{node.name_property}')
193+
super({datatype_class}, self).__init__('{node.name_property}')
194194
195195
# Import validators
196196
# -----------------

codegen/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, data=None, layout=None, frames=None):
8080
frames
8181
{frames_description}
8282
\"\"\"
83-
super({base_classname}, self).__init__(data, layout, frames)
83+
super({fig_classname} ,self).__init__(data, layout, frames)
8484
""")
8585

8686
# ### add_trace methods for each trace type ###

codegen/validators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(self, plotly_name={params['plotly_name']},
5353

5454
# ### Write constructor ###
5555
buffer.write(f"""
56-
super({superclass_name}, self).__init__(plotly_name=plotly_name,
56+
super({class_name}, self).__init__(plotly_name=plotly_name,
5757
parent_name=parent_name""")
5858

5959
# Write out remaining constructor parameters
@@ -65,9 +65,9 @@ def __init__(self, plotly_name={params['plotly_name']},
6565
buffer.write(f""",
6666
{attr_name}={attr_val}""")
6767

68-
# write **kwargs at the end to make Py2 compatible
6968
buffer.write(f""",
70-
**kwargs""")
69+
**kwargs""")
70+
7171

7272
buffer.write(')')
7373

@@ -180,7 +180,7 @@ def __init__(self, plotly_name={params['plotly_name']},
180180
parent_name={params['parent_name']},
181181
**kwargs):
182182
183-
super(_plotly_utils.basevalidators.BaseDataValidator, self).__init__(class_strs_map={params['class_strs_map']},
183+
super(DataValidator, self).__init__(class_strs_map={params['class_strs_map']},
184184
plotly_name=plotly_name,
185185
parent_name=parent_name,
186186
**kwargs)""")

makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ update_default_schema :
2626
sort_keys=True, separators=(',', ': '));\
2727
f.close()"
2828
@echo "Auto-generating graph objects based on updated default-schema."
29-
python codegen/__init__.py
29+
@echo "Warning: Make sure you are running 'make update_default_schema' with Python 3.6.
30+
Code Generation requires 3.6."
31+
#python -c "from codegen import perform_codegen;\
32+
# perform_codegen()"
33+
python setup.py codegen
34+
# python codegen/__init__.py
3035

3136
install : sync_subs
3237
@echo ""

plotly/animation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class EasingValidator(EnumeratedValidator):
55

66
def __init__(self, plotly_name='easing'):
7-
super().__init__(plotly_name=plotly_name,
7+
super(EasingValidator, self).__init__(plotly_name=plotly_name,
88
parent_name='batch_animate',
99
values=[
1010
"linear",
@@ -49,4 +49,6 @@ def __init__(self, plotly_name='easing'):
4949
class DurationValidator(NumberValidator):
5050

5151
def __init__(self, plotly_name='duration'):
52-
super().__init__(plotly_name=plotly_name, parent_name='batch_animate', min=0)
52+
super(DurationValidator, self).__init__(plotly_name=plotly_name,
53+
parent_name='batch_animate',
54+
min=0)

0 commit comments

Comments
 (0)