ó
mÜJ]c           @` s9  d  Z  d d l m Z m Z m Z m Z d d l Z e j e ƒ Z	 d d l
 Z
 d d l Z d d l m Z m Z m Z d d l m Z m Z d e f d „  ƒ  YZ e ƒ  Z e j ƒ  d k	 rõ e e j ƒ  ƒ d	 k  rõ d d l Z e j d
 ƒ qõ n  e j ƒ  r/e j ƒ  d k r/d d l Z e j d ƒ n  d Z d S(   uÜ   Control global configuration options with environment variables.
A global settings object that other parts of Bokeh can refer to.

``BOKEH_ALLOW_WS_ORIGIN`` --- List of websocket origins allowed to access bokeh.

  Comma separated list of domains that need to access bokeh websocket interface.
  This can also be provided using the --allow-websocket-origin parameter.

  Note: This option overrides the --allow-websocket-origin flag

``BOKEH_BROWSER`` --- What browser to use when opening plots.

  Valid values are any of the browser names understood by the python
  standard library webbrowser_ module.

``BOKEH_DEV`` --- Whether to use development mode.

  This uses absolute paths to development (non-minified) BokehJS components,
  sets logging to ``debug``, makes generated HTML and JSON human-readable,
  etc.

  This is a meta variable equivalent to the following environment variables:

  - ``BOKEH_BROWSER=none``
  - ``BOKEH_LOG_LEVEL=debug``
  - ``BOKEH_MINIFIED=false``
  - ``BOKEH_PRETTY=true``
  - ``BOKEH_PY_LOG_LEVEL=debug``
  - ``BOKEH_RESOURCES=absolute-dev``

  Accepted values are ``yes``/``no``, ``true``/``false`` or ``0``/``1``.

  .. note::
    When running server and notebook examples, the ``BOKEH_RESOURCES``
    setting that ``BOKEH_DEV`` sets will cause rendering problems.

    We recommend manually setting ``BOKEH_RESOURCES`` to ``server``
    for server work, and ``inline`` for notebooks (other
    :class:`~bokeh.resources.Resources` settings may also work)

``BOKEH_DOCS_CDN`` --- What version of BokehJS to use when building sphinx.

  See :ref:`bokeh.resources` module reference for full details.

``BOKEH_DOCS_VERSION`` --- What version of Bokeh to show when building sphinx docs locally.

  Useful for re-deployment purposes.

  Set to ``"local"`` to use a locally built dev version of BokehJS.

  .. note::
      This variable is only used when building documentation from the
      development version.

``BOKEH_LOG_LEVEL`` --- The BokehJS console logging level to use.

  Valid values are, in order of increasing severity:

  - ``trace``
  - ``debug``
  - ``info``
  - ``warn``
  - ``error``
  - ``fatal``

  The default logging level is ``info``.

  .. note::
      When running server examples, it is the value of this
      ``BOKEH_LOG_LEVEL`` that is set for the server that matters.

``BOKEH_MINIFIED`` --- Whether to emit minified JavaScript for ``bokeh.js``.

  Accepted values are ``yes``/``no``, ``true``/``false`` or ``0``/``1``.

``BOKEH_PRETTY`` --- Whether to emit "pretty printed" JSON.

  Accepted values are ``yes``/``no``, ``true``/``false`` or ``0``/``1``.

``BOKEH_PY_LOG_LEVEL`` --- The Python logging level to set.

  As in the JS side, valid values are, in order of increasing severity:

  - ``trace``
  - ``debug``
  - ``info``
  - ``warn``
  - ``error``
  - ``fatal``
  - ``none``

  The default logging level is ``none``.

``BOKEH_RESOURCES`` --- What kind of BokehJS resources to configure.

  For example:  ``inline``, ``cdn``, ``server``. See the
  :class:`~bokeh.core.resources.Resources` class reference for full details.

``BOKEH_ROOTDIR`` --- Root directory to use with ``relative`` resources.

  See the :class:`~bokeh.resources.Resources` class reference for full
  details.

``BOKEH_SIMPLE_IDS`` --- Whether to generate human-friendly object IDs.

  Accepted values are ``yes``/``no``, ``true``/``false`` or ``0``/``1``.
  Normally Bokeh generates UUIDs for object identifiers. Setting this variable
  to an affirmative value will result in more friendly simple numeric IDs
  counting up from 1000.

``BOKEH_VERSION`` --- What version of BokehJS to use with ``cdn`` resources.

  See the :class:`~bokeh.resources.Resources` class reference for full details.

.. _webbrowser: https://docs.python.org/2/library/webbrowser.html
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   joint   abspatht   isdiri   (   t   ROOT_DIRt
   bokehjsdirt	   _Settingsc           B` sš  e  Z d  Z d Z e Z e d „  ƒ Z d$ d „ Z	 e d „  ƒ Z
 e d „  ƒ Z d „  Z d$ d „ Z d$ d „ Z d$ d	 „ Z d$ d
 „ Z d$ d „ Z d$ d „ Z d$ d „ Z d$ d „ Z d$ d „ Z d$ d „ Z d$ d „ Z d$ d „ Z d d „ Z d$ d „ Z d$ d „ Z d$ d „ Z d$ d „ Z d „  Z e d „ Z e  d „ Z! d „  Z" d „  Z# d „  Z$ d „  Z% d$ d  „ Z& d$ d! „ Z' d" „  Z( d$ d# „ Z) RS(%   uK    A class to collect global, overridable Bokeh configuration settings.

    u   BOKEH_c         C` s   t  j S(   N(   t   ost   environ(   t   self(    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   _environ®   s    c         C` s   |  j  j |  j | | ƒ S(   N(   R   t   gett   _prefix(   R   t   keyt   default(    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   _get²   s    c         C` s   |  j  d t ƒ S(   Nu   DEV(   t	   _get_boolt   False(   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   _is_devµ   s    c         C` s   |  j  S(   N(   R   (   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   dev¹   s    c         C` s   | d  k	 r |  j r | S| S(   N(   t   NoneR   (   R   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   _dev_or_default¿   s    c         C` s   |  j  | |  j | | ƒ ƒ S(   N(   R   R   (   R   R   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   _get_strÂ   s    c         C` s"   t  |  j | |  j | | ƒ ƒ ƒ S(   N(   t   intR   R   (   R   R   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   _get_intÅ   s    c         C` s†   |  j  | ƒ } | d  k r0 |  j | | ƒ } nR | j ƒ  d
 k rK t } n7 | j ƒ  d k rf t } n t d	 | |  j | f ƒ ‚ | S(   Nu   trueu   yesu   onu   1u   falseu   nou   offu   0u*   invalid value %r for boolean property %s%s(   u   trueu   yesu   onu   1(   u   falseu   nou   offu   0(   R   R   R   t   lowert   TrueR   t
   ValueErrorR   (   R   R   R   R   t   value(    (    s-   lib/python2.7/site-packages/bokeh/settings.pyR   È   s    		c         C` s[   |  j  | ƒ } | d  k r0 |  j | | ƒ } n' |  j  | |  j | | ƒ ƒ j d ƒ } | S(   Nu   ,(   R   R   R   t   split(   R   R   R   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt	   _get_listÖ   s
    'c         C` s   |  j  d | d ƒ S(   uX    Set the default browser that Bokeh should use to show documents
        with.

        u   BROWSERu   none(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   browserà   s    c         C` s   |  j  d | d ƒ S(   uh    Set (override) the type of resources that Bokeh should use when
        outputting documents.

        u	   RESOURCESu   absolute-dev(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt	   resourcesç   s    c         C` s   |  j  d | ƒ S(   u;    Set the root directory for "relative" resources.

        u   ROOTDIR(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   rootdirî   s    c         C` s   |  j  d | ƒ S(   u>    Set (override) the standard reported Bokeh version.

        u   VERSION(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   versionô   s    c         C` s   |  j  d | ƒ S(   ub    Set the version of BokehJS should use for CDN resources when
        building the docs.

        u   DOCS_CDN(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   docs_cdnú   s    c         C` s   |  j  d | ƒ S(   u8    Set the version to use for building the docs.

        u   DOCS_VERSION(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   docs_version  s    c         C` s   |  j  d | t ƒ S(   uC    Set whether Bokeh should use minified BokehJS resources.

        u   MINIFIED(   R   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   minified  s    c         C` s   |  j  d | d ƒ S(   u9    Set the log level for JavaScript BokehJS code.

        u	   LOG_LEVELu   debug(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt	   log_level  s    u   nonec         C` sf   |  j  d | d ƒ } i t j d 6t j d 6t j d 6t j d 6t j d 6t j d 6d	 d 6} | | S(
   u3    Set the log level for python Bokeh code.

        u   PY_LOG_LEVELu   debugu   traceu   infou   warnu   erroru   fatalu   noneN(	   R   t   loggingt   TRACEt   DEBUGt   INFOt   WARNINGt   ERRORt   CRITICALR   (   R   R   t   levelt   LEVELS(    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   py_log_level  s    





c         C` s   |  j  d | t ƒ S(   u=    Set whether JSON strings should be pretty-printed.

        u   PRETTY(   R   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   pretty!  s    c         C` s   |  j  d | t ƒ S(   uF    Set whether Bokeh should generate simple numeric model IDs.

        u
   SIMPLE_IDS(   R   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt
   simple_ids'  s    c         C` s   |  j  d | t ƒ S(   u?    Set whether validation should be performed strictly.

        u   STRICT(   R   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   strict-  s    c         C` s   |  j  d | ƒ S(   u}    Set the secret key.

        Should be a long, cryptographically-random secret unique the
        Bokeh deployment.
        u
   SECRET_KEY(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt
   secret_key3  s    c         C` sR   t  |  d ƒ sK |  j ƒ  } | d k r3 d |  _ qK t j | d ƒ |  _ n  |  j S(   u@    Return the secret_key, converted to bytes and cached.

        u   _secret_key_bytesu   utf-8N(   t   hasattrR7   R   t   _secret_key_bytest   codecst   encode(   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   secret_key_bytes;  s    c         C` s   |  j  d | ƒ S(   u•    Set whether the server should only allow sessions signed with
        our secret key.

        If True, BOKEH_SECRET_KEY must also be set.

        u   SIGN_SESSIONS(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   sign_sessionsG  s    c         C` s   |  j  d | ƒ S(   uK    Set whether Bokeh should perform validation checks on documents.

        u   VALIDATE_DOC(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   perform_document_validationP  s    c         C` sD   |  j  s |  j r@ t t t d d d ƒ ƒ } t | ƒ r@ | Sn  d S(   uc    The absolute path of the BokehJS source code in the installed
        Bokeh source tree.

        u   ..u   bokehjsu   srcN(   R   t   debugjsR   R   R   R   R   (   R   t   bokehjssrcdir(    (    s-   lib/python2.7/site-packages/bokeh/settings.pyR@   X  s
    c         C` s   t  |  j p |  j ƒ S(   u
   

        (   R   R   R?   (   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyR   e  s    c         C` sr   |  j  ƒ  } g  } xY t j | ƒ D]H \ } } } x6 | D]. } | j d ƒ r8 | j t | | ƒ ƒ q8 q8 Wq" W| S(   u1    The JS files in the BokehJS directory.

        u   .js(   R   R
   t   walkt   endswitht   appendR   (   R   R   t   js_filest   roott   dirnamest   filest   fname(    (    s-   lib/python2.7/site-packages/bokeh/settings.pyRD   k  s    !c         C` sr   |  j  ƒ  } g  } xY t j | ƒ D]H \ } } } x6 | D]. } | j d ƒ r8 | j t | | ƒ ƒ q8 q8 Wq" W| S(   u2    The CSS files in the BokehJS directory.

        u   .css(   R   R
   RA   RB   RC   R   (   R   R   RD   RE   RF   RG   RH   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt	   css_filesw  s    !c         C` s   |  j  d | ƒ S(   Nu   NODEJS_PATH(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   nodejs_pathƒ  s    c         C` s   |  j  d | ƒ S(   Nu   PHANTOMJS_PATH(   R   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   phantomjs_path†  s    c         C` s   |  j  d t ƒ S(   Nu   IGNORE_FILENAME(   R   R   (   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   ignore_filename‰  s    c         C` s   |  j  d | ƒ S(   Nu   ALLOW_WS_ORIGIN(   R!   (   R   R   (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   allowed_ws_originŒ  s    N(*   t   __name__t
   __module__t   __doc__R   R   R?   t   propertyR   R   R   R   R   R   R   R   R   R!   R"   R#   R$   R%   R&   R'   R(   R)   R3   R4   R5   R6   R7   R<   R=   R   R>   R@   R   RD   RI   RJ   RK   RL   RM   (    (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyR	   ¤   sH   	
							i    uu   BOKEH_SECRET_KEY is recommended to have at least 32 bytes of entropy chosen with a cryptographically-random algorithmuB   BOKEH_SECRET_KEY must be set if BOKEH_SIGN_SESSIONS is set to trueu   settings(   u   settings(   RP   t
   __future__R    R   R   R   R*   t	   getLoggerRN   t   logR:   R
   t   os.pathR   R   R   t
   util.pathsR   R   t   objectR	   t   settingsR7   R   t   lent   warningst   warnR=   t   __all__(    (    (    s-   lib/python2.7/site-packages/bokeh/settings.pyt   <module>z   s"   "ï	