4
4
"""
5
5
import webbrowser
6
6
7
- from statsmodels .compat .python import urlencode
7
+ from statsmodels .compat .python import urlencode , string_types
8
8
from statsmodels import __version__
9
9
10
10
BASE_URL = 'https://www.statsmodels.org/'
11
11
12
12
13
13
def _generate_url (arg , stable ):
14
14
"""
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
17
17
"""
18
18
url = BASE_URL
19
19
if stable :
@@ -23,7 +23,7 @@ def _generate_url(arg, stable):
23
23
24
24
if arg is None :
25
25
return url
26
- elif type (arg ) is str :
26
+ elif isinstance (arg , string_types ) :
27
27
url += 'search.html?'
28
28
url += urlencode ({'q' : arg })
29
29
url += '&check_keywords=yes&area=default'
@@ -33,11 +33,11 @@ def _generate_url(arg, stable):
33
33
func_name = func .__name__
34
34
func_module = func .__module__
35
35
if not func_module .startswith ('statsmodels.' ):
36
- return ValueError ('Function must be from statsmodels' )
36
+ raise ValueError ('Function must be from statsmodels' )
37
37
url += 'generated/'
38
38
url += func_module + '.' + func_name + '.html'
39
- except :
40
- return ValueError ('Input not understood' )
39
+ except AttributeError :
40
+ raise ValueError ('Input not understood' )
41
41
return url
42
42
43
43
@@ -71,7 +71,5 @@ def webdoc(arg=None, stable=None):
71
71
"""
72
72
stable = __version__ if 'dev' not in __version__ else stable
73
73
url_or_error = _generate_url (arg , stable )
74
- if isinstance (url_or_error , ValueError ):
75
- raise url_or_error
76
74
webbrowser .open (url_or_error )
77
75
return None
0 commit comments