27
27
except ImportError :
28
28
pass
29
29
30
- # TODO: replace re.fullmatch with function below
30
+
31
31
# back-port of fullmatch from Py3.4+
32
32
def fullmatch (regex , string , flags = 0 ):
33
33
"""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 )
35
35
36
36
37
37
# Utility functions
@@ -274,7 +274,7 @@ class DataArrayValidator(BaseValidator):
274
274
"""
275
275
276
276
def __init__ (self , plotly_name , parent_name , ** kwargs ):
277
- super ().__init__ (
277
+ super (DataArrayValidator , self ).__init__ (
278
278
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
279
279
280
280
def description (self ):
@@ -320,7 +320,7 @@ def __init__(self,
320
320
array_ok = False ,
321
321
coerce_number = False ,
322
322
** kwargs ):
323
- super ().__init__ (
323
+ super (EnumeratedValidator , self ).__init__ (
324
324
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
325
325
326
326
# Save params
@@ -440,7 +440,8 @@ def in_values(self, e):
440
440
is_str = isinstance (e , str )
441
441
for v , regex in zip (self .values , self .val_regexs ):
442
442
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
444
445
else :
445
446
in_values = e == v
446
447
@@ -483,7 +484,7 @@ class BooleanValidator(BaseValidator):
483
484
"""
484
485
485
486
def __init__ (self , plotly_name , parent_name , ** kwargs ):
486
- super ().__init__ (
487
+ super (BooleanValidator , self ).__init__ (
487
488
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
488
489
489
490
def description (self ):
@@ -525,7 +526,7 @@ def __init__(self,
525
526
max = None ,
526
527
array_ok = False ,
527
528
** kwargs ):
528
- super ().__init__ (
529
+ super (NumberValidator , self ).__init__ (
529
530
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
530
531
531
532
# Handle min
@@ -646,7 +647,7 @@ def __init__(self,
646
647
max = None ,
647
648
array_ok = False ,
648
649
** kwargs ):
649
- super ().__init__ (
650
+ super (IntegerValidator , self ).__init__ (
650
651
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
651
652
652
653
# Handle min
@@ -767,7 +768,7 @@ def __init__(self,
767
768
array_ok = False ,
768
769
values = None ,
769
770
** kwargs ):
770
- super ().__init__ (
771
+ super (StringValidator , self ).__init__ (
771
772
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
772
773
self .no_blank = no_blank
773
774
self .strict = strict
@@ -934,7 +935,7 @@ def __init__(self,
934
935
array_ok = False ,
935
936
colorscale_path = None ,
936
937
** kwargs ):
937
- super ().__init__ (
938
+ super (ColorValidator , self ).__init__ (
938
939
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
939
940
940
941
self .array_ok = array_ok
@@ -1062,10 +1063,12 @@ def perform_validate_coerce(v, allow_number=None):
1062
1063
# Remove spaces so regexes don't need to bother with them.
1063
1064
v_normalized = v .replace (' ' , '' ).lower ()
1064
1065
1065
- if ColorValidator .re_hex .fullmatch (v_normalized ):
1066
+ # if ColorValidator.re_hex.fullmatch(v_normalized):
1067
+ if fullmatch (ColorValidator .re_hex , v_normalized ):
1066
1068
# valid hex color (e.g. #f34ab3)
1067
1069
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):
1069
1072
# Valid rgb(a), hsl(a), hsv(a) color
1070
1073
# (e.g. rgba(10, 234, 200, 50%)
1071
1074
return v
@@ -1090,7 +1093,7 @@ class ColorlistValidator(BaseValidator):
1090
1093
"""
1091
1094
1092
1095
def __init__ (self , plotly_name , parent_name , ** kwargs ):
1093
- super ().__init__ (
1096
+ super (ColorlistValidator , self ).__init__ (
1094
1097
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1095
1098
1096
1099
def description (self ):
@@ -1148,7 +1151,7 @@ class ColorscaleValidator(BaseValidator):
1148
1151
]
1149
1152
1150
1153
def __init__ (self , plotly_name , parent_name , ** kwargs ):
1151
- super ().__init__ (
1154
+ super (ColorscaleValidator , self ).__init__ (
1152
1155
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1153
1156
1154
1157
def description (self ):
@@ -1226,7 +1229,7 @@ class AngleValidator(BaseValidator):
1226
1229
"""
1227
1230
1228
1231
def __init__ (self , plotly_name , parent_name , ** kwargs ):
1229
- super ().__init__ (
1232
+ super (AngleValidator , self ).__init__ (
1230
1233
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1231
1234
1232
1235
def description (self ):
@@ -1267,7 +1270,7 @@ class SubplotidValidator(BaseValidator):
1267
1270
"""
1268
1271
1269
1272
def __init__ (self , plotly_name , parent_name , dflt , ** kwargs ):
1270
- super ().__init__ (
1273
+ super (SubplotidValidator , self ).__init__ (
1271
1274
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1272
1275
self .base = dflt
1273
1276
self .regex = dflt + "(\d*)"
@@ -1289,7 +1292,8 @@ def validate_coerce(self, v):
1289
1292
elif not isinstance (v , str ):
1290
1293
self .raise_invalid_val (v )
1291
1294
else :
1292
- match = re .fullmatch (self .regex , v )
1295
+ # match = re.fullmatch(self.regex, v)
1296
+ match = fullmatch (self .regex , v )
1293
1297
if not match :
1294
1298
is_valid = False
1295
1299
else :
@@ -1334,7 +1338,7 @@ def __init__(self,
1334
1338
extras = None ,
1335
1339
array_ok = False ,
1336
1340
** kwargs ):
1337
- super ().__init__ (
1341
+ super (FlaglistValidator , self ).__init__ (
1338
1342
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1339
1343
self .flags = flags
1340
1344
self .extras = extras if extras is not None else []
@@ -1440,7 +1444,7 @@ def __init__(self,
1440
1444
values = None ,
1441
1445
array_ok = False ,
1442
1446
** kwargs ):
1443
- super ().__init__ (
1447
+ super (AnyValidator , self ).__init__ (
1444
1448
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1445
1449
self .values = values
1446
1450
self .array_ok = array_ok
@@ -1483,7 +1487,7 @@ def __init__(self,
1483
1487
items ,
1484
1488
free_length = None ,
1485
1489
** kwargs ):
1486
- super ().__init__ (
1490
+ super (InfoArrayValidator , self ).__init__ (
1487
1491
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1488
1492
self .items = items
1489
1493
@@ -1568,7 +1572,7 @@ class LiteralValidator(BaseValidator):
1568
1572
Validator for readonly literal values
1569
1573
"""
1570
1574
def __init__ (self , plotly_name , parent_name , ** kwargs ):
1571
- super ().__init__ (plotly_name = plotly_name ,
1575
+ super (LiteralValidator , self ).__init__ (plotly_name = plotly_name ,
1572
1576
parent_name = parent_name ,
1573
1577
** kwargs )
1574
1578
@@ -1588,7 +1592,7 @@ class ImageUriValidator(BaseValidator):
1588
1592
pass
1589
1593
1590
1594
def __init__ (self , plotly_name , parent_name , ** kwargs ):
1591
- super ().__init__ (
1595
+ super (ImageUriValidator , self ).__init__ (
1592
1596
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1593
1597
1594
1598
def description (self ):
@@ -1634,7 +1638,7 @@ class CompoundValidator(BaseValidator):
1634
1638
1635
1639
def __init__ (self , plotly_name , parent_name , data_class_str , data_docs ,
1636
1640
** kwargs ):
1637
- super (BaseValidator , self ).__init__ (
1641
+ super (CompoundValidator , self ).__init__ (
1638
1642
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1639
1643
1640
1644
# Save element class string
@@ -1707,7 +1711,7 @@ class CompoundArrayValidator(BaseValidator):
1707
1711
1708
1712
def __init__ (self , plotly_name , parent_name , data_class_str , data_docs ,
1709
1713
** kwargs ):
1710
- super ().__init__ (
1714
+ super (CompoundArrayValidator , self ).__init__ (
1711
1715
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1712
1716
1713
1717
# Save element class string
@@ -1774,7 +1778,7 @@ def validate_coerce(self, v):
1774
1778
class BaseDataValidator (BaseValidator ):
1775
1779
1776
1780
def __init__ (self , class_strs_map , plotly_name , parent_name , ** kwargs ):
1777
- super ().__init__ (
1781
+ super (BaseDataValidator , self ).__init__ (
1778
1782
plotly_name = plotly_name , parent_name = parent_name , ** kwargs )
1779
1783
self .class_strs_map = class_strs_map
1780
1784
self ._class_map = None
0 commit comments