MCPcopy Index your code
hub / github.com/plotly/plotly.py / __init__

Method __init__

_plotly_utils/basevalidators.py:444–488  ·  view source on GitHub ↗
(
        self,
        plotly_name,
        parent_name,
        values,
        array_ok=False,
        coerce_number=False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

442 """
443
444 def __init__(
445 self,
446 plotly_name,
447 parent_name,
448 values,
449 array_ok=False,
450 coerce_number=False,
451 **kwargs,
452 ):
453 super(EnumeratedValidator, self).__init__(
454 plotly_name=plotly_name, parent_name=parent_name, **kwargs
455 )
456
457 # Save params
458 # -----------
459 self.values = values
460 self.array_ok = array_ok
461 # coerce_number is rarely used and not implemented
462 self.coerce_number = coerce_number
463 self.kwargs = kwargs
464
465 # Handle regular expressions
466 # --------------------------
467 # Compiled regexs
468 self.val_regexs = []
469
470 # regex replacements that run before the matching regex
471 # So far, this is only used to cast 'x1' -> 'x' for anchor-style
472 # enumeration properties
473 self.regex_replacements = []
474
475 # Loop over enumeration values
476 # ----------------------------
477 # Look for regular expressions
478 for v in self.values:
479 if v and isinstance(v, str) and v[0] == "/" and v[-1] == "/" and len(v) > 1:
480 # String is a regex with leading and trailing '/' character
481 regex_str = v[1:-1]
482 self.val_regexs.append(re.compile(regex_str))
483 self.regex_replacements.append(
484 EnumeratedValidator.build_regex_replacement(regex_str)
485 )
486 else:
487 self.val_regexs.append(None)
488 self.regex_replacements.append(None)
489
490 def __deepcopy__(self, memodict={}):
491 """

Callers

nothing calls this directly

Calls 2

__init__Method · 0.45

Tested by

no test coverage detected