human
Complete this python program:
def bind_row_action(action_name):
assistant
#Here is the Python program you requested.

    """A decorator to bind table region method to an actual row action button.
    Many table actions when started (by clicking a corresponding button
    in UI) lead to some form showing up. To further interact with this form,
    a Python/ Selenium wrapper needs to be created for it. It is very
    convenient to return this newly created wrapper in the same method that
    initiates clicking an actual action button. Row action could be
    either primary (if its name is written right away on row action
    button) or secondary (if its name is inside of a button drop-down). Binding
    the method to a button and toggling the button drop-down open (in case
    a row action is secondary) is performed behind the scenes in this
    decorator.
    .. param:: action_name
    Part of the action button id which is specific to action itself. It
    is safe to use action `name` attribute from the dashboard tables.py
    code.
    """
    primary_action_locator = (by.By.CSS_SELECTOR, 'td.actions_column    *.btn:nth-child(1)')
    secondary_actions_opener_locator = (by.By.CSS_SELECTOR, 'td.actions_column    >    .btn-group    >    *.btn:nth-child(2)')
    secondary_actions_locator = (by.By.CSS_SELECTOR, 'td.actions_column    >    .btn-group    >    ul.row_actions    >    li    >    a,    button')
    def decorator(method):
        @functools.wraps(method)
        def wrapper(table, row):
            def find_action(element):
                pattern = ('__action_%s' % action_name)
                return element.get_attribute('id').endswith(pattern)
            action_element = row._get_element(*primary_action_locator)
            if (not find_action(action_element)):
                action_element = None
                row._get_element(*secondary_actions_opener_locator).click()
                for element in row._get_elements(*secondary_actions_locator):
                    if find_action(element):
                        action_element = element
                        break
            if (action_element is None):
                msg = ("Could    not    bind    method    '%s'    to    action    control    '%s'" % (method.__name__, action_name))
                raise ValueError(msg)
            return method(table, action_element, row)
        return wrapper
    return decorator