Gets the CSS for this class and inherited from bases. Default CSS is inherited from base classes, unless `inherit_css` is set to `False` when subclassing. Returns: A list of tuples containing (LOCATION, SOURCE, SPECIFICITY, SCOPE) for this class
(self)
| 711 | yield "classes", " ".join(self._classes) |
| 712 | |
| 713 | def _get_default_css(self) -> list[tuple[CSSLocation, str, int, str]]: |
| 714 | """Gets the CSS for this class and inherited from bases. |
| 715 | |
| 716 | Default CSS is inherited from base classes, unless `inherit_css` is set to |
| 717 | `False` when subclassing. |
| 718 | |
| 719 | Returns: |
| 720 | A list of tuples containing (LOCATION, SOURCE, SPECIFICITY, SCOPE) for this |
| 721 | class and inherited from base classes. |
| 722 | """ |
| 723 | |
| 724 | css_stack: list[tuple[CSSLocation, str, int, str]] = [] |
| 725 | |
| 726 | def get_location(base: Type[DOMNode]) -> CSSLocation: |
| 727 | """Get the original location of this DEFAULT_CSS. |
| 728 | |
| 729 | Args: |
| 730 | base: The class from which the default css was extracted. |
| 731 | |
| 732 | Returns: |
| 733 | The filename where the class was defined (if possible) and the class |
| 734 | variable the CSS was extracted from. |
| 735 | """ |
| 736 | try: |
| 737 | return (getfile(base), f"{base.__name__}.DEFAULT_CSS") |
| 738 | except (TypeError, OSError): |
| 739 | return ("", f"{base.__name__}.DEFAULT_CSS") |
| 740 | |
| 741 | for tie_breaker, base in enumerate(self._node_bases): |
| 742 | css: str = base.__dict__.get("DEFAULT_CSS", "") |
| 743 | if css: |
| 744 | scoped: bool = base.__dict__.get("SCOPED_CSS", True) |
| 745 | css_stack.append( |
| 746 | ( |
| 747 | get_location(base), |
| 748 | css, |
| 749 | -tie_breaker, |
| 750 | base._css_type_name if scoped else "", |
| 751 | ) |
| 752 | ) |
| 753 | return css_stack |
| 754 | |
| 755 | @classmethod |
| 756 | @lru_cache(maxsize=None) |