from bs4 import BeautifulSoup


def style_table_rows(table_html, tr_modifier):
    """Return a new HTML string of the table, with rows modified.

    Parameters
    ----------

    table_html
      A string "<table>...</table>" of an HTML table.

    tr_modifier
      A function that takes a BeautifulSoup ``tr`` element as argument
      and changes its attributes inplace. for instance with
      ``tr.text = new_text``, or with the ``add_css_class`` method.
    """
    soup = BeautifulSoup(table_html, "html.parser")
    for tr in soup.find_all("tr"):
        tr_modifier(tr)
    return str(soup)