def test_arguments(self): doc__ = "-- {}{as_parameter} --" assert bus.format_docstring( doc__, 'hello ', as_parameter='world') == "-- hello world --" doc__ = None assert bus.format_docstring(doc__, 'hello ', as_parameter='world') == None
from bokeh.util.logconfig import basicConfig from bokeh.util.string import nice_join, format_docstring from bokeh.settings import settings from os import getpid from ..subcommand import Subcommand from ..util import build_single_handler_applications, die, report_server_init_errors LOGLEVELS = ('debug', 'info', 'warning', 'error', 'critical') SESSION_ID_MODES = ('unsigned', 'signed', 'external-signed') DEFAULT_LOG_FORMAT = "%(asctime)s %(message)s" __doc__ = format_docstring(__doc__, DEFAULT_PORT=DEFAULT_SERVER_PORT, LOGLEVELS=nice_join(LOGLEVELS), SESSION_ID_MODES=nice_join(SESSION_ID_MODES), DEFAULT_LOG_FORMAT=DEFAULT_LOG_FORMAT) def _fixup_deprecated_host_args(args): if args.host is not None and len(args.host) > 0: if args.allow_websocket_origin is None: args.allow_websocket_origin = [] args.allow_websocket_origin += args.host args.allow_websocket_origin = list(set(args.allow_websocket_origin)) warnings.warn( "The --host parameter is deprecated because it is no longer needed. " "It will be removed and trigger an error in a future release. " "Values set now will be copied to --allow-websocket-origin. " "Depending on your use case, you may need to set current --host "
BINARY_ARRAY_TYPES = set([ np.dtype(np.float32), np.dtype(np.float64), np.dtype(np.uint8), np.dtype(np.int8), np.dtype(np.uint16), np.dtype(np.int16), np.dtype(np.uint32), np.dtype(np.int32), ]) except ImportError: is_numpy = False BINARY_ARRAY_TYPES = set() __doc__ = format_docstring(__doc__, binary_array_types="\n".join( "* ``np." + str(x) + "``" for x in BINARY_ARRAY_TYPES)) pd = import_optional('pandas') import logging log = logging.getLogger(__name__) _simple_id = 1000 def make_id(): """ Return a new unique ID for a Bokeh object. Normally this function will return UUIDs to use for identifying Bokeh objects. This is especally important for Bokeh objects stored on a
def test_no_argument(self): doc__ = "hello world" assert bus.format_docstring(doc__) == doc__ doc__ = None assert bus.format_docstring(doc__) == None
def test_arguments_unused(self): doc__ = "hello world" assert bus.format_docstring(doc__, 'hello ', not_used='world') == doc__ doc__ = None assert bus.format_docstring(doc__, 'hello ', not_used='world') == None
hours = List(String, help=_DATETIME_TICK_FORMATTER_HELP("``hours``"), default=['%Hh', '%H:%M']).accepts(String, lambda fmt: [fmt]) days = List(String, help=_DATETIME_TICK_FORMATTER_HELP("``days``"), default=['%m/%d', '%a%d']).accepts(String, lambda fmt: [fmt]) months = List(String, help=_DATETIME_TICK_FORMATTER_HELP("``months``"), default=['%m/%Y', '%b%y']).accepts(String, lambda fmt: [fmt]) years = List(String, help=_DATETIME_TICK_FORMATTER_HELP("``years``"), default=['%Y']).accepts(String, lambda fmt: [fmt]) # This is to automate documentation of DatetimeTickFormatter formats and their defaults _df = DatetimeTickFormatter() _df_fields = [ 'microseconds', 'milliseconds', 'seconds', 'minsec', 'minutes', 'hourmin', 'hours', 'days', 'months', 'years' ] _df_defaults = _df.properties_with_values() _df_defaults_string = "\n\n ".join( "%s = %s" % (name, _df_defaults[name]) for name in _df_fields) DatetimeTickFormatter.__doc__ = format_docstring(DatetimeTickFormatter.__doc__, defaults=_df_defaults_string) del _df, _df_fields, _df_defaults, _df_defaults_string
from bokeh.util.string import nice_join, format_docstring from bokeh.server.tornado import DEFAULT_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES from bokeh.settings import settings from os import getpid from ..subcommand import Subcommand from ..util import build_single_handler_applications, die, report_server_init_errors LOGLEVELS = ('trace', 'debug', 'info', 'warning', 'error', 'critical') SESSION_ID_MODES = ('unsigned', 'signed', 'external-signed') DEFAULT_LOG_FORMAT = "%(asctime)s %(message)s" __doc__ = format_docstring(__doc__, DEFAULT_PORT=DEFAULT_SERVER_PORT, LOGLEVELS=nice_join(LOGLEVELS), SESSION_ID_MODES=nice_join(SESSION_ID_MODES), DEFAULT_LOG_FORMAT=DEFAULT_LOG_FORMAT ) base_serve_args = ( ('--port', dict( metavar = 'PORT', type = int, help = "Port to listen on", default = DEFAULT_SERVER_PORT )), ('--address', dict( metavar = 'ADDRESS', type = str, help = "Address to listen on",
def test_format_docstring_no_argument(): doc__ = "hello world" assert format_docstring(doc__) == doc__ doc__ = None assert format_docstring(doc__) == None
def test_format_docstring_no_argument(): doc__ = "hello world" assert format_docstring(doc__) == doc__ doc__ = None assert format_docstring(doc__) == None
def test_format_docstring_arguments_unused(): doc__ = "hello world" assert format_docstring(doc__, 'hello ', not_used='world') == doc__ doc__ = None assert format_docstring(doc__, 'hello ', not_used='world') == None
def test_format_docstring_arguments(): doc__ = "-- {}{as_parameter} --" assert format_docstring(doc__, 'hello ', as_parameter='world') == "-- hello world --" doc__ = None assert format_docstring(doc__, 'hello ', as_parameter='world') == None
nice_join(x.name for x in subcommands.all)) parser = argparse.ArgumentParser(prog=argv[0]) # we don't use settings.version() because the point of this option # is to report the actual version of Bokeh, while settings.version() # lets people change the version used for CDN for example. parser.add_argument('-v', '--version', action='version', version=__version__) subs = parser.add_subparsers(help="Sub-commands") for cls in subcommands.all: subparser = subs.add_parser(cls.name, help=cls.help) subcommand = cls(parser=subparser) subparser.set_defaults(invoke=subcommand.invoke) args = parser.parse_args(argv[1:]) try: args.invoke(args) except Exception as e: die("ERROR:" + str(e)) main.__doc__ = format_docstring( main.__doc__, subcmds="\n * ".join(":ref:`%s <bokeh.command.subcommands.%s>`" % (x.name, x.name) for x in subcommands.all))
def test_no_argument(self): doc__ = "hello world" assert bus.format_docstring(doc__) == doc__ doc__ = None assert bus.format_docstring(doc__) == None
default=['%Hh', '%H:%M']).accepts(String, lambda fmt: [fmt]) days = List(String, help=_DATETIME_TICK_FORMATTER_HELP("``days``"), default=['%m/%d', '%a%d']).accepts(String, lambda fmt: [fmt]) months = List(String, help=_DATETIME_TICK_FORMATTER_HELP("``months``"), default=['%m/%Y', '%b %Y']).accepts(String, lambda fmt: [fmt]) years = List(String, help=_DATETIME_TICK_FORMATTER_HELP("``years``"), default=['%Y']).accepts(String, lambda fmt: [fmt]) #----------------------------------------------------------------------------- # Dev API #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Code #----------------------------------------------------------------------------- # This is to automate documentation of DatetimeTickFormatter formats and their defaults _df = DatetimeTickFormatter() _df_fields = ['microseconds', 'milliseconds', 'seconds', 'minsec', 'minutes', 'hourmin', 'hours', 'days', 'months', 'years'] _df_defaults = _df.properties_with_values() _df_defaults_string = "\n\n ".join("%s = %s" % (name, _df_defaults[name]) for name in _df_fields) DatetimeTickFormatter.__doc__ = format_docstring(DatetimeTickFormatter.__doc__, defaults=_df_defaults_string) del _df, _df_fields, _df_defaults, _df_defaults_string
* {subcmds} ''' if len(argv) == 1: die("ERROR: Must specify subcommand, one of: %s" % nice_join(x.name for x in subcommands.all)) parser = argparse.ArgumentParser( prog=argv[0], epilog="See '<command> --help' to read about a specific subcommand.") # we don't use settings.version() because the point of this option # is to report the actual version of Bokeh, while settings.version() # lets people change the version used for CDN for example. parser.add_argument('-v', '--version', action='version', version=__version__) subs = parser.add_subparsers(help="Sub-commands") for cls in subcommands.all: subparser = subs.add_parser(cls.name, help=cls.help) subcommand = cls(parser=subparser) subparser.set_defaults(invoke=subcommand.invoke) args = parser.parse_args(argv[1:]) try: args.invoke(args) except Exception as e: die("ERROR:" + str(e)) main.__doc__ = format_docstring(main.__doc__, subcmds="\n * ".join(":ref:`%s <bokeh.command.subcommands.%s>`" % (x.name, x.name) for x in subcommands.all))
is_numpy = True BINARY_ARRAY_TYPES = set([ np.dtype(np.float32), np.dtype(np.float64), np.dtype(np.uint8), np.dtype(np.int8), np.dtype(np.uint16), np.dtype(np.int16), np.dtype(np.uint32), np.dtype(np.int32), ]) except ImportError: is_numpy = False BINARY_ARRAY_TYPES = set() __doc__ = format_docstring(__doc__, binary_array_types="\n".join("* ``np." + str(x) + "``" for x in BINARY_ARRAY_TYPES)) pd = import_optional('pandas') import logging log = logging.getLogger(__name__) _simple_id = 1000 def make_id(): """ Return a new unique ID for a Bokeh object. Normally this function will return UUIDs to use for identifying Bokeh objects. This is especally important for Bokeh objects stored on a Bokeh server. However, it is convenient to have more human-readable IDs during development, so this behavior can be overridden by