Return the instance of the subclass with the given style name.
(cls, stylename, **kwargs)
| 2416 | }) |
| 2417 | |
| 2418 | def __new__(cls, stylename, **kwargs): |
| 2419 | """Return the instance of the subclass with the given style name.""" |
| 2420 | # The "class" should have the _style_list attribute, which is a mapping |
| 2421 | # of style names to style classes. |
| 2422 | _list = stylename.replace(" ", "").split(",") |
| 2423 | _name = _list[0].lower() |
| 2424 | try: |
| 2425 | _cls = cls._style_list[_name] |
| 2426 | except KeyError as err: |
| 2427 | raise ValueError(f"Unknown style: {stylename!r}") from err |
| 2428 | try: |
| 2429 | _args_pair = [cs.split("=") for cs in _list[1:]] |
| 2430 | _args = {k: float(v) for k, v in _args_pair} |
| 2431 | except ValueError as err: |
| 2432 | raise ValueError( |
| 2433 | f"Incorrect style argument: {stylename!r}") from err |
| 2434 | return _cls(**{**_args, **kwargs}) |
| 2435 | |
| 2436 | @classmethod |
| 2437 | def get_styles(cls): |
no outgoing calls
no test coverage detected