44"""
55import webbrowser
66
7- from statsmodels .compat .python import urlencode
7+ from statsmodels .compat .python import urlencode , string_types
88from statsmodels import __version__
99
1010BASE_URL = 'https://www.statsmodels.org/'
1111
1212
1313def _generate_url (arg , stable ):
1414 """
15- Parse inputs and return a correctly formatted URL or an error if the input
16- is not understandable
15+ Parse inputs and return a correctly formatted URL or raises ValueError
16+ if the input is not understandable
1717 """
1818 url = BASE_URL
1919 if stable :
@@ -23,7 +23,7 @@ def _generate_url(arg, stable):
2323
2424 if arg is None :
2525 return url
26- elif type (arg ) is str :
26+ elif isinstance (arg , string_types ) :
2727 url += 'search.html?'
2828 url += urlencode ({'q' : arg })
2929 url += '&check_keywords=yes&area=default'
@@ -33,11 +33,11 @@ def _generate_url(arg, stable):
3333 func_name = func .__name__
3434 func_module = func .__module__
3535 if not func_module .startswith ('statsmodels.' ):
36- return ValueError ('Function must be from statsmodels' )
36+ raise ValueError ('Function must be from statsmodels' )
3737 url += 'generated/'
3838 url += func_module + '.' + func_name + '.html'
39- except :
40- return ValueError ('Input not understood' )
39+ except AttributeError :
40+ raise ValueError ('Input not understood' )
4141 return url
4242
4343
@@ -71,7 +71,5 @@ def webdoc(arg=None, stable=None):
7171 """
7272 stable = __version__ if 'dev' not in __version__ else stable
7373 url_or_error = _generate_url (arg , stable )
74- if isinstance (url_or_error , ValueError ):
75- raise url_or_error
7674 webbrowser .open (url_or_error )
7775 return None
0 commit comments