#-----------------------------------------------------------------------------# Copyright (c) Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Standard library importsfrompathlibimportPath# Bokeh importsfrom.deprecationimportdeprecated#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------# Root dir of Bokeh packageROOT_DIR=Path(__file__).absolute().resolve().parent.parent__all__=("bokehjs_path","bokehjsdir","server_path","serverdir","static_path",)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------
[docs]defserver_path()->Path:""" Get the location of the server subpackage. """returnROOT_DIR/"server"
[docs]defstatic_path()->Path:""" Get the location of server's static directory. """returnserver_path()/"static"
[docs]defbokehjs_path(dev:bool=False)->Path:""" Get the location of the bokehjs source files. By default the files in ``bokeh/server/static`` are used. If ``dev`` is ``True``, then the files in ``bokehjs/build`` preferred. However, if not available, then a warning is issued and the former files are used as a fallback. .. note: This is a low-level API. Prefer using ``settings.bokehjs_path()`` instead of this function. """ifdev:js_dir=ROOT_DIR.parent.parent/"bokehjs"/"build"ifjs_dir.is_dir():returnjs_direlse:log.warning(f"bokehjs' build directory '{js_dir}' doesn't exist; required by 'settings.dev'")returnstatic_path()
[docs]defserverdir()->str:""" Get the location of the server subpackage. .. deprecated:: 3.4.0 Use ``server_path()`` instead. """deprecated((3,4,0),"serverdir()","server_path()")returnstr(server_path())
[docs]defbokehjsdir(dev:bool=False)->str:""" Get the location of the bokehjs source files. By default the files in ``bokeh/server/static`` are used. If ``dev`` is ``True``, then the files in ``bokehjs/build`` preferred. However, if not available, then a warning is issued and the former files are used as a fallback. .. note: This is a low-level API. Prefer using ``settings.bokehjsdir()`` instead of this function. .. deprecated:: 3.4.0 Use ``bokehjs_path()`` instead. """deprecated((3,4,0),"bokehjsdir()","bokehjs_path()")returnstr(bokehjs_path(dev))
#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Private API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Code#-----------------------------------------------------------------------------