class_docstr: Create a ``Style`` instance from a list of style rules.
  
  The `style_rules` is supposed to be a list of ('classnames', 'style') tuples.
  The classnames are a whitespace separated string of class names and the
  style string is just like a Pygments style definition, but with a few
  additions: it supports 'reverse' and 'blink'.
  
  Later rules always override previous rules.
  
  Usage::
  
      Style([
          ('title', '#ff0000 bold underline'),
          ('something-else', 'reverse'),
          ('class1 class2', 'reverse'),
      ])
  
  The ``from_dict`` classmethod is similar, but takes a dictionary as input.
class_docstr_tok: ["Create","a","``","Style","``","instance","from","a","list","of","style","rules",".","The","`","style_rules","`","is","supposed","to","be","a","list","of","(","'classnames","'",",","'style","'",")","tuples",".","The","classnames","are","a","whitespace","separated","string","of","class","names","and","the","style","string","is","just","like","a","Pygments","style","definition",",","but","with","a","few","additions",":","it","supports","'reverse","'","and","'blink","'",".","Later","rules","always","override","previous","rules",".","Usage",":",":","Style","(","[","(","'title","'",",","'","#","ff0000","bold","underline","'",")",",","(","'something-else","'",",","'reverse","'",")",",","(","'class1","class2","'",",","'reverse","'",")",",","]",")","The","``","from_dict","``","classmethod","is","similar",",","but","takes","a","dictionary","as","input","."]
docstr: Get `Attrs` for the given style string.
docstr_tok: ["Get","`","Attrs","`","for","the","given","style","string","."]
code: def get_attrs_for_style_str(
      self, style_str: str, default: Attrs = DEFAULT_ATTRS
  ) -> Attrs:
      """
      Get `Attrs` for the given style string.
      """
      list_of_attrs = [default]
      class_names: set[str] = set()
  
      # Apply default styling.
      for names, attr in self.class_names_and_attrs:
          if not names:
              list_of_attrs.append(attr)
  
      # Go from left to right through the style string. Things on the right
      # take precedence.
      for part in style_str.split():
          # This part represents a class.
          # Do lookup of this class name in the style definition, as well
          # as all class combinations that we have so far.
          if part.startswith("class:"):
              # Expand all class names (comma separated list).
              new_class_names = []
              for p in part[6:].lower().split(","):
                  new_class_names.extend(_expand_classname(p))
  
              for new_name in new_class_names:
                  # Build a set of all possible class combinations to be applied.
                  combos = set()
                  combos.add(frozenset([new_name]))
  
                  for count in range(1, len(class_names) + 1):
                      for c2 in itertools.combinations(
                          class_names, count
                      ):
                          combos.add(frozenset(c2 + (new_name,)))
  
                  # Apply the styles that match these class names.
                  for names, attr in self.class_names_and_attrs:
                      if names in combos:
                          list_of_attrs.append(attr)
  
                  class_names.add(new_name)
  
          # Process inline style.
          else:
              inline_attrs = _parse_style_str(part)
              list_of_attrs.append(inline_attrs)
  
      return _merge_attrs(list_of_attrs)
  
imports: from __future__ import annotations
  import itertools
  import re
  from enum import Enum
  from typing import Hashable, TypeVar
  from prompt_toolkit.cache import SimpleCache
  from .base import ANSI_COLOR_NAMES, ANSI_COLOR_NAMES_ALIASES, DEFAULT_ATTRS, Attrs, BaseStyle
  from .named_colors import NAMED_COLORS
label_desc: Use image node_id 4 for calling the Style obj's underlying member method code with example usage: obj.get_attrs_for_style_str(style_str, default) and returns: _merge_attrs