ó
įp7]c           @   sZ   d  Z  d d l Z d d l m Z m Z d d l m Z d Z d   Z d d d  Z
 d S(   sj   
Provides a function to open the system browser to either search or go directly
to a function's reference
i’’’’N(   t	   urlencodet   string_types(   t   __version__s   https://www.statsmodels.org/c         C   sī   t  } | r | d 7} n
 | d 7} |  d k r3 | St |  t  rp | d 7} | t i |  d 6 7} | d 7} nz yZ |  } | j } | j } | j d  s© t d   n  | d 7} | | d	 | d
 7} Wn t	 k
 ré t d   n X| S(   sw   
    Parse inputs and return a correctly formatted URL or raises ValueError
    if the input is not understandable
    s   stable/s   devel/s   search.html?t   qs    &check_keywords=yes&area=defaults   statsmodels.s!   Function must be from statsmodelss
   generated/t   .s   .htmls   Input not understoodN(
   t   BASE_URLt   Nonet
   isinstanceR   R    t   __name__t
   __module__t
   startswitht
   ValueErrort   AttributeError(   t   argt   stablet   urlt   funct	   func_namet   func_module(    (    s4   lib/python2.7/site-packages/statsmodels/tools/web.pyt   _generate_url   s*    

		
c         C   s8   d t  k r t  n | } t |  |  } t j |  d S(   s  
    Opens a browser and displays online documentation

    Parameters
    ----------
    arg, optional : string or statsmodels function
        Either a string to search the documentation or a function
    stable, optional : bool
        Flag indicating whether to use the stable documentation (True) or
        the development documentation (False).  If not provided, opens
        the stable documentation if the current version of statsmodels is a
        release

    Examples
    --------
    >>> import statsmodels.api as sm
    >>> sm.webdoc()  # Documention site
    >>> sm.webdoc('glm')  # Search for glm in docs
    >>> sm.webdoc(sm.OLS, stable=False)  # Go to generated help for OLS, devel

    Notes
    -----
    By default, open stable documentation if the current version of statsmodels
    is a release.  Otherwise opens the development documentation.

    Uses the default system browser.
    t   devN(   R   R   t
   webbrowsert   openR   (   R   R   t   url_or_error(    (    s4   lib/python2.7/site-packages/statsmodels/tools/web.pyt   webdoc,   s    (   t   __doc__R   t   statsmodels.compat.pythonR    R   t   statsmodelsR   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/statsmodels/tools/web.pyt   <module>   s   	