r"""
    Args:
        browser_preferences (list): (default = [])
        fallback (bool): uses default if non of preferences work (default = True)

    CommandLine:
        python -m utool.util_grabdata --test-get_prefered_browser

    Ignore:
        import webbrowser
        webbrowser._tryorder
        pref_list = ['chrome', 'firefox', 'google-chrome']
        pref_list = ['firefox', 'google-chrome']

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_grabdata import *  # NOQA
        >>> browser_preferences = ['firefox', 'chrome', 'safari']
        >>> fallback = True
        >>> browser = get_prefered_browser(browser_preferences, fallback)
        >>> result = ('browser = %s' % (str(browser),))
        >>> print(result)
        >>> ut.quit_if_noshow()

def get_prefered_browser(pref_list=[], fallback=True):
    r"""
    Args:
        browser_preferences (list): (default = [])
        fallback (bool): uses default if non of preferences work (default = True)

    CommandLine:
        python -m utool.util_grabdata --test-get_prefered_browser

    Ignore:
        import webbrowser
        webbrowser._tryorder
        pref_list = ['chrome', 'firefox', 'google-chrome']
        pref_list = ['firefox', 'google-chrome']

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_grabdata import *  # NOQA
        >>> browser_preferences = ['firefox', 'chrome', 'safari']
        >>> fallback = True
        >>> browser = get_prefered_browser(browser_preferences, fallback)
        >>> result = ('browser = %s' % (str(browser),))
        >>> print(result)
        >>> ut.quit_if_noshow()
    """
    import webbrowser
    import utool as ut
    pref_list = ut.ensure_iterable(pref_list)
    error_list = []

    # Hack for finding chrome on win32
    if ut.WIN32:
        # http://stackoverflow.com/questions/24873302/webbrowser-chrome-exe-does-not-work
        win32_chrome_fpath = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'
        win32_chrome_browsername = win32_chrome_fpath + ' %s'
        win32_map = {
            'chrome': win32_chrome_browsername,
            'google-chrome': win32_chrome_browsername,
        }
        for browsername, win32_browsername in win32_map.items():
            index = ut.listfind(pref_list, browsername)
            if index is not None and True:  # ut.checkpath(win32_browsername):
                pref_list.insert(index + 1, win32_browsername)

    for browsername in pref_list:
        try:
            browser = webbrowser.get(browsername)
            return browser
        except webbrowser.Error as ex:
            error_list.append(ex)
            print(str(browsername) + ' failed. Reason: ' + str(ex))

    if fallback:
        browser = webbrowser
        return browser
    else:
        raise AssertionError('No browser meets preferences=%r. error_list=%r' %
                             (pref_list, error_list,))