If "children" is in props, then move it to the front to respect dash convention, then 'id', then the remaining props sorted by prop name Parameters ---------- props: dict Dictionary with {propName: propMetadata} structure Returns ------- dict Dictionary wi
(props)
| 445 | |
| 446 | |
| 447 | def reorder_props(props): |
| 448 | """If "children" is in props, then move it to the front to respect dash |
| 449 | convention, then 'id', then the remaining props sorted by prop name |
| 450 | Parameters |
| 451 | ---------- |
| 452 | props: dict |
| 453 | Dictionary with {propName: propMetadata} structure |
| 454 | Returns |
| 455 | ------- |
| 456 | dict |
| 457 | Dictionary with {propName: propMetadata} structure |
| 458 | """ |
| 459 | |
| 460 | # Constructing an OrderedDict with duplicate keys, you get the order |
| 461 | # from the first one but the value from the last. |
| 462 | # Doing this to avoid mutating props, which can cause confusion. |
| 463 | props1 = [("children", "")] if "children" in props else [] |
| 464 | props2 = [("id", "")] if "id" in props else [] |
| 465 | return OrderedDict(props1 + props2 + sorted(list(props.items()))) |
| 466 | |
| 467 | |
| 468 | def filter_props(props, ignored_props=tuple()): |
no outgoing calls
no test coverage detected
searching dependent graphs…