Get kwargs to pass to the constructor of this node's validator superclass. Returns ------- dict The keys are strings matching the names of the constructor params of this node's validator superclass. The values are repr-str
(self)
| 427 | |
| 428 | # Validators |
| 429 | def get_validator_params(self): |
| 430 | """ |
| 431 | Get kwargs to pass to the constructor of this node's validator |
| 432 | superclass. |
| 433 | |
| 434 | Returns |
| 435 | ------- |
| 436 | dict |
| 437 | The keys are strings matching the names of the constructor |
| 438 | params of this node's validator superclass. The values are |
| 439 | repr-strings of the values to be passed to the constructor. |
| 440 | These values are ready to be used to code generate calls to the |
| 441 | constructor. The values should be evald before being passed to |
| 442 | the constructor directly. |
| 443 | |
| 444 | """ |
| 445 | params = { |
| 446 | "plotly_name": repr(self.name_property), |
| 447 | "parent_name": repr(self.parent_path_str), |
| 448 | } |
| 449 | |
| 450 | if self.is_compound: |
| 451 | params["data_class_str"] = repr(self.name_datatype_class) |
| 452 | params["data_docs"] = '"""\n"""' |
| 453 | else: |
| 454 | assert self.is_simple |
| 455 | |
| 456 | # Exclude general properties |
| 457 | excluded_props = ["valType", "description", "dflt"] |
| 458 | if self.datatype == "subplotid": |
| 459 | # Default is required for subplotid validator |
| 460 | excluded_props.remove("dflt") |
| 461 | |
| 462 | attr_nodes = [ |
| 463 | n for n in self.simple_attrs if n.plotly_name not in excluded_props |
| 464 | ] |
| 465 | |
| 466 | for node in attr_nodes: |
| 467 | params[node.name_undercase] = repr(node.node_data) |
| 468 | |
| 469 | # Add extra properties |
| 470 | if self.datatype == "color" and self.parent: |
| 471 | # Check for colorscale sibling. We use the presence of a |
| 472 | # colorscale sibling to determine whether numeric color |
| 473 | # values are permissible |
| 474 | colorscale_node_list = [ |
| 475 | node |
| 476 | for node in self.parent.child_datatypes |
| 477 | if node.datatype == "colorscale" |
| 478 | ] |
| 479 | if colorscale_node_list: |
| 480 | colorscale_path = colorscale_node_list[0].path_str |
| 481 | params["colorscale_path"] = repr(colorscale_path) |
| 482 | elif self.datatype == "literal": |
| 483 | params["val"] = self.node_data |
| 484 | |
| 485 | return params |
| 486 |
no test coverage detected