project_name
stringlengths
6
104
file_name
stringlengths
4
89
full_name
stringlengths
1
102
func_name
stringlengths
1
85
docstring
stringlengths
13
836
docstring_tokens
listlengths
4
122
code
stringlengths
23
39.7k
code_tokens
stringlengths
29
44.6k
url
int64
3
986k
devashish-patel/webcam-motion-detector
hsl.py
HSL.from_rgb
from_rgb
Create an HSL color from an RGB color value.
[ "Create", "an", "HSL", "color", "from", "an", "RGB", "color", "value." ]
def from_rgb(cls, value): return value.to_hsl()
['def', 'from_rgb(cls,', 'value):', 'return', 'value.to_hsl()']
977,198
devashish-patel/webcam-motion-detector
rgb.py
RGB.from_hsl
from_hsl
Create an RGB color from an HSL color value.
[ "Create", "an", "RGB", "color", "from", "an", "HSL", "color", "value." ]
def from_hsl(self, value): return value.to_rgb()
['def', 'from_hsl(self,', 'value):', 'return', 'value.to_rgb()']
977,203
devashish-patel/webcam-motion-detector
rgb.py
RGB.from_rgb
from_rgb
Copy an RGB color from another RGB color value.
[ "Copy", "an", "RGB", "color", "from", "another", "RGB", "color", "value." ]
def from_rgb(self, value): return value.copy()
['def', 'from_rgb(self,', 'value):', 'return', 'value.copy()']
977,204
devashish-patel/webcam-motion-detector
util.py
report_server_init_errors
report_server_init_errors
A context manager to help print more informative error messages when a ``Server`` cannot be started due to a network problem.
[ "A", "context", "manager", "to", "help", "print", "more", "informative", "error", "messages", "when", "a", "``Server``", "cannot", "be", "started", "due", "to", "a", "network", "problem." ]
def report_server_init_errors(address=None, port=None, **kwargs): try: yield except EnvironmentError as e: if e.errno == errno.EADDRINUSE: log.critical('Cannot start Bokeh server, port %s is already in use', port) elif e.errno == errno.EADDRNOTAVAIL: log.critical(...
['def', 'report_server_init_errors(address=None,', 'port=None,', '**kwargs):', 'try:', 'yield', 'except', 'EnvironmentError', 'as', 'e:', 'if', 'e.errno', '==', 'errno.EADDRINUSE:', "log.critical('Cannot", 'start', 'Bokeh', 'server,', 'port', '%s', 'is', 'already', 'in', "use',", 'port)', 'elif', 'e.errno', '==', 'errn...
977,213
devashish-patel/webcam-motion-detector
has_props.py
HasProps.equals
equals
Structural equality of models.
[ "Structural", "equality", "of", "models." ]
def equals(self, other): if not isinstance(other, self.__class__): return False else: return self.properties_with_values() == other.properties_with_values()
['def', 'equals(self,', 'other):', 'if', 'not', 'isinstance(other,', 'self.__class__):', 'return', 'False', 'else:', 'return', 'self.properties_with_values()', '==', 'other.properties_with_values()']
977,220
devashish-patel/webcam-motion-detector
has_props.py
HasProps.set_from_json
set_from_json
Set a property value on this object from JSON.
[ "Set", "a", "property", "value", "on", "this", "object", "from", "JSON." ]
def set_from_json(self, name, json, models=None, setter=None): if name in self.properties(): log.trace('Patching attribute %r of %r with %r', name, self, json) descriptor = self.lookup(name) descriptor.set_from_json(self, json, models, setter) else: log.warn("JSON had attr %r on ...
['def', 'set_from_json(self,', 'name,', 'json,', 'models=None,', 'setter=None):', 'if', 'name', 'in', 'self.properties():', "log.trace('Patching", 'attribute', '%r', 'of', '%r', 'with', "%r',", 'name,', 'self,', 'json)', 'descriptor', '=', 'self.lookup(name)', 'descriptor.set_from_json(self,', 'json,', 'models,', 'sett...
977,221
devashish-patel/webcam-motion-detector
json_encoder.py
BokehJSONEncoder.default
default
The required ``default`` method for JSONEncoder subclasses.
[ "The", "required", "``default``", "method", "for", "JSONEncoder", "subclasses." ]
def default(self, obj): from ..model import Model from ..colors import Color from .has_props import HasProps if pd and isinstance(obj, (pd.Series, pd.Index)): return transform_series(obj, force_list=True) elif isinstance(obj, np.ndarray): return transform_array(obj, force_list=True) ...
['def', 'default(self,', 'obj):', 'from', '..model', 'import', 'Model', 'from', '..colors', 'import', 'Color', 'from', '.has_props', 'import', 'HasProps', 'if', 'pd', 'and', 'isinstance(obj,', '(pd.Series,', 'pd.Index)):', 'return', 'transform_series(obj,', 'force_list=True)', 'elif', 'isinstance(obj,', 'np.ndarray):',...
977,239
devashish-patel/webcam-motion-detector
query.py
match
match
Test whether a given Bokeh model matches a given selector.
[ "Test", "whether", "a", "given", "Bokeh", "model", "matches", "a", "given", "selector." ]
def match(obj, selector, context=None): context = context or {} for (key, val) in selector.items(): if isinstance(key, string_types): if key == 'type': if isinstance(val, dict) and list(val.keys()) == [IN]: if not any((isinstance(obj, x) for x in val[IN]))...
['def', 'match(obj,', 'selector,', 'context=None):', 'context', '=', 'context', 'or', '{}', 'for', '(key,', 'val)', 'in', 'selector.items():', 'if', 'isinstance(key,', 'string_types):', 'if', 'key', '==', "'type':", 'if', 'isinstance(val,', 'dict)', 'and', 'list(val.keys())', '==', '[IN]:', 'if', 'not', 'any((isinstanc...
977,240
devashish-patel/webcam-motion-detector
query.py
find
find
Query a collection of Bokeh models and yield any that match the a selector.
[ "Query", "a", "collection", "of", "Bokeh", "models", "and", "yield", "any", "that", "match", "the", "a", "selector." ]
def find(objs, selector, context=None): return (obj for obj in objs if match(obj, selector, context))
['def', 'find(objs,', 'selector,', 'context=None):', 'return', '(obj', 'for', 'obj', 'in', 'objs', 'if', 'match(obj,', 'selector,', 'context))']
977,241
devashish-patel/webcam-motion-detector
bases.py
Property.make_descriptors
make_descriptors
Return a list of ``BasicPropertyDescriptor`` instances to install on a class, in order to delegate attribute access to this property.
[ "Return", "a", "list", "of", "``BasicPropertyDescriptor``", "instances", "to", "install", "on", "a", "class,", "in", "order", "to", "delegate", "attribute", "access", "to", "this", "property." ]
def make_descriptors(self, base_name): return [BasicPropertyDescriptor(base_name, self)]
['def', 'make_descriptors(self,', 'base_name):', 'return', '[BasicPropertyDescriptor(base_name,', 'self)]']
977,242
devashish-patel/webcam-motion-detector
bases.py
Property.transform
transform
Change the value into the canonical format for this property.
[ "Change", "the", "value", "into", "the", "canonical", "format", "for", "this", "property." ]
def transform(self, value): return value
['def', 'transform(self,', 'value):', 'return', 'value']
977,249
devashish-patel/webcam-motion-detector
bases.py
Property.wrap
wrap
Some property types need to wrap their values in special containers, etc.
[ "Some", "property", "types", "need", "to", "wrap", "their", "values", "in", "special", "containers,", "etc." ]
def wrap(cls, value): return value
['def', 'wrap(cls,', 'value):', 'return', 'value']
977,252
devashish-patel/webcam-motion-detector
bases.py
Property.accepts
accepts
Declare that other types may be converted to this property type.
[ "Declare", "that", "other", "types", "may", "be", "converted", "to", "this", "property", "type." ]
def accepts(self, tp, converter): tp = ParameterizedProperty._validate_type_param(tp) self.alternatives.append((tp, converter)) return self
['def', 'accepts(self,', 'tp,', 'converter):', 'tp', '=', 'ParameterizedProperty._validate_type_param(tp)', 'self.alternatives.append((tp,', 'converter))', 'return', 'self']
977,253
devashish-patel/webcam-motion-detector
containers.py
notify_owner
notify_owner
A decorator for mutating methods of property container classes that notifies owners of the property container about mutating changes.
[ "A", "decorator", "for", "mutating", "methods", "of", "property", "container", "classes", "that", "notifies", "owners", "of", "the", "property", "container", "about", "mutating", "changes." ]
def notify_owner(func): def wrapper(self, *args, **kwargs): old = self._saved_copy() result = func(self, *args, **kwargs) self._notify_owners(old) return result wrapper.__doc__ = 'Container method ``%s`` instrumented to notify property owners' % func.__name__ return wrapper
['def', 'notify_owner(func):', 'def', 'wrapper(self,', '*args,', '**kwargs):', 'old', '=', 'self._saved_copy()', 'result', '=', 'func(self,', '*args,', '**kwargs)', 'self._notify_owners(old)', 'return', 'result', 'wrapper.__doc__', '=', "'Container", 'method', '``%s``', 'instrumented', 'to', 'notify', 'property', "owne...
977,255
devashish-patel/webcam-motion-detector
descriptors.py
PropertyDescriptor.trigger_if_changed
trigger_if_changed
Send a change event notification if the property is set to a value is not equal to ``old``.
[ "Send", "a", "change", "event", "notification", "if", "the", "property", "is", "set", "to", "a", "value", "is", "not", "equal", "to", "``old``." ]
def trigger_if_changed(self, obj, old): raise NotImplementedError('Implement trigger_if_changed()')
['def', 'trigger_if_changed(self,', 'obj,', 'old):', 'raise', "NotImplementedError('Implement", "trigger_if_changed()')"]
977,260
devashish-patel/webcam-motion-detector
descriptors.py
BasicPropertyDescriptor.class_default
class_default
Get the default value for a specific subtype of ``HasProps``, which may not be used for an individual instance.
[ "Get", "the", "default", "value", "for", "a", "specific", "subtype", "of", "``HasProps``,", "which", "may", "not", "be", "used", "for", "an", "individual", "instance." ]
def class_default(self, cls): return self.property.themed_default(cls, self.name, None)
['def', 'class_default(self,', 'cls):', 'return', 'self.property.themed_default(cls,', 'self.name,', 'None)']
977,264
devashish-patel/webcam-motion-detector
descriptor_factory.py
PropertyDescriptorFactory.make_descriptors
make_descriptors
Return a list of ``PropertyDescriptor`` instances to install on a class, in order to delegate attribute access to this property.
[ "Return", "a", "list", "of", "``PropertyDescriptor``", "instances", "to", "install", "on", "a", "class,", "in", "order", "to", "delegate", "attribute", "access", "to", "this", "property." ]
def make_descriptors(self, name): raise NotImplementedError('make_descriptors not implemented')
['def', 'make_descriptors(self,', 'name):', 'raise', "NotImplementedError('make_descriptors", 'not', "implemented')"]
977,274
devashish-patel/webcam-motion-detector
test_json_encoder.py
TestSerializeJson.test_deque
test_deque
Test that a deque is deserialized as a list.
[ "Test", "that", "a", "deque", "is", "deserialized", "as", "a", "list." ]
def test_deque(self): self.assertEqual(self.serialize(deque([0, 1, 2])), '[0,1,2]')
['def', 'test_deque(self):', 'self.assertEqual(self.serialize(deque([0,', '1,', '2])),', "'[0,1,2]')"]
977,278
devashish-patel/webcam-motion-detector
test_json_encoder.py
TestSerializeJson.test_slice
test_slice
Test that a slice is deserialized as a list.
[ "Test", "that", "a", "slice", "is", "deserialized", "as", "a", "list." ]
def test_slice(self): self.assertEqual(self.serialize(slice(2)), '{"start":null,"step":null,"stop":2}') self.assertEqual(self.serialize(slice(0, 2)), '{"start":0,"step":null,"stop":2}') self.assertEqual(self.serialize(slice(0, 10, 2)), '{"start":0,"step":2,"stop":10}') self.assertEqual(self.serialize(sl...
['def', 'test_slice(self):', 'self.assertEqual(self.serialize(slice(2)),', '\'{"start":null,"step":null,"stop":2}\')', 'self.assertEqual(self.serialize(slice(0,', '2)),', '\'{"start":0,"step":null,"stop":2}\')', 'self.assertEqual(self.serialize(slice(0,', '10,', '2)),', '\'{"start":0,"step":2,"stop":10}\')', 'self.asse...
977,279
devashish-patel/webcam-motion-detector
check.py
check_integrity
check_integrity
Apply validation and integrity checks to a collection of Bokeh models.
[ "Apply", "validation", "and", "integrity", "checks", "to", "a", "collection", "of", "Bokeh", "models." ]
def check_integrity(models): messages = dict(error=[], warning=[]) for model in models: validators = [] for name in dir(model): if not name.startswith('_check'): continue obj = getattr(model, name) if getattr(obj, 'validator_type', None): ...
['def', 'check_integrity(models):', 'messages', '=', 'dict(error=[],', 'warning=[])', 'for', 'model', 'in', 'models:', 'validators', '=', '[]', 'for', 'name', 'in', 'dir(model):', 'if', 'not', "name.startswith('_check'):", 'continue', 'obj', '=', 'getattr(model,', 'name)', 'if', 'getattr(obj,', "'validator_type',", 'No...
977,280
devashish-patel/webcam-motion-detector
document.py
Document.roots
roots
A list of all the root models in this Document.
[ "A", "list", "of", "all", "the", "root", "models", "in", "this", "Document." ]
def roots(self): return list(self._roots)
['def', 'roots(self):', 'return', 'list(self._roots)']
977,283
devashish-patel/webcam-motion-detector
document.py
Document.session_callbacks
session_callbacks
A list of all the session callbacks on this document.
[ "A", "list", "of", "all", "the", "session", "callbacks", "on", "this", "document." ]
def session_callbacks(self): return list(self._session_callbacks.values())
['def', 'session_callbacks(self):', 'return', 'list(self._session_callbacks.values())']
977,284
devashish-patel/webcam-motion-detector
document.py
Document.add_periodic_callback
add_periodic_callback
Add a callback to be invoked on a session periodically.
[ "Add", "a", "callback", "to", "be", "invoked", "on", "a", "session", "periodically." ]
def add_periodic_callback(self, callback, period_milliseconds): from ..server.callbacks import PeriodicCallback cb = PeriodicCallback(self, None, period_milliseconds) return self._add_session_callback(cb, callback, one_shot=False)
['def', 'add_periodic_callback(self,', 'callback,', 'period_milliseconds):', 'from', '..server.callbacks', 'import', 'PeriodicCallback', 'cb', '=', 'PeriodicCallback(self,', 'None,', 'period_milliseconds)', 'return', 'self._add_session_callback(cb,', 'callback,', 'one_shot=False)']
977,291
devashish-patel/webcam-motion-detector
document.py
Document.add_timeout_callback
add_timeout_callback
Add callback to be invoked once, after a specified timeout passes.
[ "Add", "callback", "to", "be", "invoked", "once,", "after", "a", "specified", "timeout", "passes." ]
def add_timeout_callback(self, callback, timeout_milliseconds): from ..server.callbacks import TimeoutCallback cb = TimeoutCallback(self, None, timeout_milliseconds) return self._add_session_callback(cb, callback, one_shot=True)
['def', 'add_timeout_callback(self,', 'callback,', 'timeout_milliseconds):', 'from', '..server.callbacks', 'import', 'TimeoutCallback', 'cb', '=', 'TimeoutCallback(self,', 'None,', 'timeout_milliseconds)', 'return', 'self._add_session_callback(cb,', 'callback,', 'one_shot=True)']
977,293
devashish-patel/webcam-motion-detector
document.py
Document.apply_json_patch
apply_json_patch
Apply a JSON patch object and process any resulting events.
[ "Apply", "a", "JSON", "patch", "object", "and", "process", "any", "resulting", "events." ]
def apply_json_patch(self, patch, setter=None): references_json = patch['references'] events_json = patch['events'] references = instantiate_references_json(references_json) for obj in references.values(): if obj._id in self._all_models: references[obj._id] = self._all_models[obj._id...
['def', 'apply_json_patch(self,', 'patch,', 'setter=None):', 'references_json', '=', "patch['references']", 'events_json', '=', "patch['events']", 'references', '=', 'instantiate_references_json(references_json)', 'for', 'obj', 'in', 'references.values():', 'if', 'obj._id', 'in', 'self._all_models:', 'references[obj._i...
977,294
devashish-patel/webcam-motion-detector
document.py
Document.get_model_by_id
get_model_by_id
Find the model for the given ID in this document, or ``None`` if it is not found.
[ "Find", "the", "model", "for", "the", "given", "ID", "in", "this", "document,", "or", "``None``", "if", "it", "is", "not", "found." ]
def get_model_by_id(self, model_id): return self._all_models.get(model_id)
['def', 'get_model_by_id(self,', 'model_id):', 'return', 'self._all_models.get(model_id)']
977,300
devashish-patel/webcam-motion-detector
document.py
Document.get_model_by_name
get_model_by_name
Find the model for the given name in this document, or ``None`` if it is not found.
[ "Find", "the", "model", "for", "the", "given", "name", "in", "this", "document,", "or", "``None``", "if", "it", "is", "not", "found." ]
def get_model_by_name(self, name): return self._all_models_by_name.get_one(name, "Found more than one model named '%s'" % name)
['def', 'get_model_by_name(self,', 'name):', 'return', 'self._all_models_by_name.get_one(name,', '"Found', 'more', 'than', 'one', 'model', 'named', '\'%s\'"', '%', 'name)']
977,301
devashish-patel/webcam-motion-detector
document.py
Document.select
select
Query this document for objects that match the given selector.
[ "Query", "this", "document", "for", "objects", "that", "match", "the", "given", "selector." ]
def select(self, selector): if self._is_single_string_selector(selector, 'name'): return self._all_models_by_name.get_all(selector['name']) else: return find(self._all_models.values(), selector)
['def', 'select(self,', 'selector):', 'if', 'self._is_single_string_selector(selector,', "'name'):", 'return', "self._all_models_by_name.get_all(selector['name'])", 'else:', 'return', 'find(self._all_models.values(),', 'selector)']
977,311
devashish-patel/webcam-motion-detector
events.py
ModelChangedEvent.generate
generate
Create a JSON representation of this event suitable for sending to clients.
[ "Create", "a", "JSON", "representation", "of", "this", "event", "suitable", "for", "sending", "to", "clients." ]
def generate(self, references, buffers): from ..model import collect_models if self.hint is not None: return self.hint.generate(references, buffers) value = self.serializable_new value_refs = set(collect_models(value)) if self.model != value: value_refs.discard(self.model) refere...
['def', 'generate(self,', 'references,', 'buffers):', 'from', '..model', 'import', 'collect_models', 'if', 'self.hint', 'is', 'not', 'None:', 'return', 'self.hint.generate(references,', 'buffers)', 'value', '=', 'self.serializable_new', 'value_refs', '=', 'set(collect_models(value))', 'if', 'self.model', '!=', 'value:'...
977,321
devashish-patel/webcam-motion-detector
locking.py
UnlockedDocumentProxy.add_next_tick_callback
add_next_tick_callback
Add a "next tick" callback.
[ "Add", "a", "\"next", "tick\"", "callback." ]
def add_next_tick_callback(self, callback): return self._doc.add_next_tick_callback(callback)
['def', 'add_next_tick_callback(self,', 'callback):', 'return', 'self._doc.add_next_tick_callback(callback)']
977,334
devashish-patel/webcam-motion-detector
locking.py
UnlockedDocumentProxy.remove_next_tick_callback
remove_next_tick_callback
Remove a "next tick" callback.
[ "Remove", "a", "\"next", "tick\"", "callback." ]
def remove_next_tick_callback(self, callback): return self._doc.remove_next_tick_callback(callback)
['def', 'remove_next_tick_callback(self,', 'callback):', 'return', 'self._doc.remove_next_tick_callback(callback)']
977,335
devashish-patel/webcam-motion-detector
util.py
instantiate_references_json
instantiate_references_json
Given a JSON representation of all the models in a graph, return a dict of new model objects.
[ "Given", "a", "JSON", "representation", "of", "all", "the", "models", "in", "a", "graph,", "return", "a", "dict", "of", "new", "model", "objects." ]
def instantiate_references_json(references_json): references = {} for obj in references_json: obj_id = obj['id'] obj_type = obj.get('subtype', obj['type']) cls = get_class(obj_type) instance = cls(id=obj_id, _block_events=True) if instance is None: raise Runti...
['def', 'instantiate_references_json(references_json):', 'references', '=', '{}', 'for', 'obj', 'in', 'references_json:', 'obj_id', '=', "obj['id']", 'obj_type', '=', "obj.get('subtype',", "obj['type'])", 'cls', '=', 'get_class(obj_type)', 'instance', '=', 'cls(id=obj_id,', '_block_events=True)', 'if', 'instance', 'is'...
977,337
devashish-patel/webcam-motion-detector
notebook.py
destroy_server
destroy_server
Given a UUID id of a div removed or replaced in the Jupyter notebook, destroy the corresponding server sessions and stop it.
[ "Given", "a", "UUID", "id", "of", "a", "div", "removed", "or", "replaced", "in", "the", "Jupyter", "notebook,", "destroy", "the", "corresponding", "server", "sessions", "and", "stop", "it." ]
def destroy_server(server_id): server = curstate().uuid_to_server.get(server_id, None) if server is None: log.debug('No server instance found for uuid: %r' % server_id) return try: for session in server.get_sessions(): session.destroy() server.stop() del c...
['def', 'destroy_server(server_id):', 'server', '=', 'curstate().uuid_to_server.get(server_id,', 'None)', 'if', 'server', 'is', 'None:', "log.debug('No", 'server', 'instance', 'found', 'for', 'uuid:', "%r'", '%', 'server_id)', 'return', 'try:', 'for', 'session', 'in', 'server.get_sessions():', 'session.destroy()', 'ser...
977,354
devashish-patel/webcam-motion-detector
notebook.py
load_notebook
load_notebook
Prepare the IPython notebook for displaying Bokeh plots.
[ "Prepare", "the", "IPython", "notebook", "for", "displaying", "Bokeh", "plots." ]
def load_notebook(resources=None, verbose=False, hide_banner=False, load_timeout=5000): global _NOTEBOOK_LOADED from .. import __version__ from ..core.templates import NOTEBOOK_LOAD from ..util.serialization import make_id from ..resources import CDN from ..util.compiler import bundle_all_models...
['def', 'load_notebook(resources=None,', 'verbose=False,', 'hide_banner=False,', 'load_timeout=5000):', 'global', '_NOTEBOOK_LOADED', 'from', '..', 'import', '__version__', 'from', '..core.templates', 'import', 'NOTEBOOK_LOAD', 'from', '..util.serialization', 'import', 'make_id', 'from', '..resources', 'import', 'CDN',...
977,356
devashish-patel/webcam-motion-detector
showing.py
show
show
Immediately display a Bokeh object or application.
[ "Immediately", "display", "a", "Bokeh", "object", "or", "application." ]
def show(obj, browser=None, new='tab', notebook_handle=False, notebook_url='localhost:8888'): state = curstate() if getattr(obj, '_is_a_bokeh_application_class', False) or callable(obj): return run_notebook_hook(state.notebook_type, 'app', obj, state, notebook_url) if obj not in state.document.roots...
['def', 'show(obj,', 'browser=None,', "new='tab',", 'notebook_handle=False,', "notebook_url='localhost:8888'):", 'state', '=', 'curstate()', 'if', 'getattr(obj,', "'_is_a_bokeh_application_class',", 'False)', 'or', 'callable(obj):', 'return', 'run_notebook_hook(state.notebook_type,', "'app',", 'obj,', 'state,', 'notebo...
977,362
devashish-patel/webcam-motion-detector
state.py
State.notebook_type
notebook_type
Notebook type, acceptable values are 'jupyter' as well as any names defined by external notebook hooks that have been installed.
[ "Notebook", "type,", "acceptable", "values", "are", "'jupyter'", "as", "well", "as", "any", "names", "defined", "by", "external", "notebook", "hooks", "that", "have", "been", "installed." ]
def notebook_type(self, notebook_type): if notebook_type is None or not isinstance(notebook_type, string_types): raise ValueError('Notebook type must be a string') self._notebook_type = notebook_type.lower()
['def', 'notebook_type(self,', 'notebook_type):', 'if', 'notebook_type', 'is', 'None', 'or', 'not', 'isinstance(notebook_type,', 'string_types):', 'raise', "ValueError('Notebook", 'type', 'must', 'be', 'a', "string')", 'self._notebook_type', '=', 'notebook_type.lower()']
977,367
devashish-patel/webcam-motion-detector
util.py
detect_current_filename
detect_current_filename
Attempt to return the filename of the currently running Python process Returns None if the filename cannot be detected.
[ "Attempt", "to", "return", "the", "filename", "of", "the", "currently", "running", "Python", "process", "Returns", "None", "if", "the", "filename", "cannot", "be", "detected." ]
def detect_current_filename(): import inspect filename = None frame = inspect.currentframe() try: while frame.f_back and frame.f_globals.get('name') != '__main__': frame = frame.f_back filename = frame.f_globals.get('__file__') finally: del frame return filena...
['def', 'detect_current_filename():', 'import', 'inspect', 'filename', '=', 'None', 'frame', '=', 'inspect.currentframe()', 'try:', 'while', 'frame.f_back', 'and', "frame.f_globals.get('name')", '!=', "'__main__':", 'frame', '=', 'frame.f_back', 'filename', '=', "frame.f_globals.get('__file__')", 'finally:', 'del', 'fr...
977,372
devashish-patel/webcam-motion-detector
plots.py
Plot.row
row
Return whether this plot is in a given row of a GridPlot.
[ "Return", "whether", "this", "plot", "is", "in", "a", "given", "row", "of", "a", "GridPlot." ]
def row(self, row, gridplot): return self in gridplot.row(row)
['def', 'row(self,', 'row,', 'gridplot):', 'return', 'self', 'in', 'gridplot.row(row)']
977,382
devashish-patel/webcam-motion-detector
plots.py
Plot.column
column
Return whether this plot is in a given column of a GridPlot.
[ "Return", "whether", "this", "plot", "is", "in", "a", "given", "column", "of", "a", "GridPlot." ]
def column(self, col, gridplot): return self in gridplot.column(col)
['def', 'column(self,', 'col,', 'gridplot):', 'return', 'self', 'in', 'gridplot.column(col)']
977,383
devashish-patel/webcam-motion-detector
plots.py
Plot.add_tools
add_tools
Adds tools to the plot.
[ "Adds", "tools", "to", "the", "plot." ]
def add_tools(self, *tools): for tool in tools: if not isinstance(tool, Tool): raise ValueError('All arguments to add_tool must be Tool subclasses.') if hasattr(tool, 'overlay'): self.renderers.append(tool.overlay) self.toolbar.tools.append(tool)
['def', 'add_tools(self,', '*tools):', 'for', 'tool', 'in', 'tools:', 'if', 'not', 'isinstance(tool,', 'Tool):', 'raise', "ValueError('All", 'arguments', 'to', 'add_tool', 'must', 'be', 'Tool', "subclasses.')", 'if', 'hasattr(tool,', "'overlay'):", 'self.renderers.append(tool.overlay)', 'self.toolbar.tools.append(tool)...
977,392
devashish-patel/webcam-motion-detector
sources.py
ColumnDataSource.remove
remove
Remove a column of data.
[ "Remove", "a", "column", "of", "data." ]
def remove(self, name): try: self.column_names.remove(name) del self.data[name] except (ValueError, KeyError): import warnings warnings.warn("Unable to find column '%s' in data source" % name)
['def', 'remove(self,', 'name):', 'try:', 'self.column_names.remove(name)', 'del', 'self.data[name]', 'except', '(ValueError,', 'KeyError):', 'import', 'warnings', 'warnings.warn("Unable', 'to', 'find', 'column', "'%s'", 'in', 'data', 'source"', '%', 'name)']
977,399
devashish-patel/webcam-motion-detector
buttons.py
Button.on_click
on_click
Set up a handler for button clicks.
[ "Set", "up", "a", "handler", "for", "button", "clicks." ]
def on_click(self, handler): self.on_change('clicks', lambda attr, old, new: handler())
['def', 'on_click(self,', 'handler):', "self.on_change('clicks',", 'lambda', 'attr,', 'old,', 'new:', 'handler())']
977,403
devashish-patel/webcam-motion-detector
buttons.py
Toggle.on_click
on_click
Set up a handler for button state changes (clicks).
[ "Set", "up", "a", "handler", "for", "button", "state", "changes", "(clicks)." ]
def on_click(self, handler): self.on_change('active', lambda attr, old, new: handler(new))
['def', 'on_click(self,', 'handler):', "self.on_change('active',", 'lambda', 'attr,', 'old,', 'new:', 'handler(new))']
977,405
devashish-patel/webcam-motion-detector
buttons.py
Toggle.js_on_click
js_on_click
Set up a JavaScript handler for button state changes (clicks).
[ "Set", "up", "a", "JavaScript", "handler", "for", "button", "state", "changes", "(clicks)." ]
def js_on_click(self, handler): self.js_on_change('active', handler)
['def', 'js_on_click(self,', 'handler):', "self.js_on_change('active',", 'handler)']
977,406
devashish-patel/webcam-motion-detector
buttons.py
Dropdown.on_click
on_click
Set up a handler for button or menu item clicks.
[ "Set", "up", "a", "handler", "for", "button", "or", "menu", "item", "clicks." ]
def on_click(self, handler): self.on_change('value', lambda attr, old, new: handler(new))
['def', 'on_click(self,', 'handler):', "self.on_change('value',", 'lambda', 'attr,', 'old,', 'new:', 'handler(new))']
977,407
devashish-patel/webcam-motion-detector
groups.py
AbstractGroup.on_click
on_click
Set up a handler for button check/radio box clicks including the selected indices.
[ "Set", "up", "a", "handler", "for", "button", "check/radio", "box", "clicks", "including", "the", "selected", "indices." ]
def on_click(self, handler): self.on_change('active', lambda attr, old, new: handler(new))
['def', 'on_click(self,', 'handler):', "self.on_change('active',", 'lambda', 'attr,', 'old,', 'new:', 'handler(new))']
977,409
devashish-patel/webcam-motion-detector
sliders.py
DateRangeSlider.value_as_datetime
value_as_datetime
Convenience property to retrieve the value tuple as a tuple of datetime objects.
[ "Convenience", "property", "to", "retrieve", "the", "value", "tuple", "as", "a", "tuple", "of", "datetime", "objects." ]
def value_as_datetime(self): if self.value is None: return None (v1, v2) = self.value if isinstance(v1, numbers.Number): d1 = datetime.utcfromtimestamp(v1 / 1000) else: d1 = v1 if isinstance(v2, numbers.Number): d2 = datetime.utcfromtimestamp(v2 / 1000) else: ...
['def', 'value_as_datetime(self):', 'if', 'self.value', 'is', 'None:', 'return', 'None', '(v1,', 'v2)', '=', 'self.value', 'if', 'isinstance(v1,', 'numbers.Number):', 'd1', '=', 'datetime.utcfromtimestamp(v1', '/', '1000)', 'else:', 'd1', '=', 'v1', 'if', 'isinstance(v2,', 'numbers.Number):', 'd2', '=', 'datetime.utcfr...
977,411
devashish-patel/webcam-motion-detector
figure.py
Figure.hbar_stack
hbar_stack
Generate multiple ``HBar`` renderers for levels stacked left to right.
[ "Generate", "multiple", "``HBar``", "renderers", "for", "levels", "stacked", "left", "to", "right." ]
def hbar_stack(self, stackers, **kw): for kw in _stack(stackers, 'left', 'right', **kw): self.hbar(**kw)
['def', 'hbar_stack(self,', 'stackers,', '**kw):', 'for', 'kw', 'in', '_stack(stackers,', "'left',", "'right',", '**kw):', 'self.hbar(**kw)']
977,415
devashish-patel/webcam-motion-detector
test_figure.py
TestMarkers.check_each_color_input
check_each_color_input
Runs assertions for each rgb provided with the given function.
[ "Runs", "assertions", "for", "each", "rgb", "provided", "with", "the", "given", "function." ]
def check_each_color_input(self, rgbs, func): for rgb in rgbs: p = plt.figure() func(p, rgb)
['def', 'check_each_color_input(self,', 'rgbs,', 'func):', 'for', 'rgb', 'in', 'rgbs:', 'p', '=', 'plt.figure()', 'func(p,', 'rgb)']
977,419
devashish-patel/webcam-motion-detector
test_figure.py
TestMarkers.color_only_checks
color_only_checks
Helper method for checks specific to color= input.
[ "Helper", "method", "for", "checks", "specific", "to", "color=", "input." ]
def color_only_checks(self, p, rgb): p.circle([1, 2, 3], [1, 2, 3], color=rgb) self.assertTupleEqual(p.renderers[-1].glyph.line_color, rgb) self.assertTupleEqual(p.renderers[-1].glyph.fill_color, rgb) [self.assertIsInstance(v, int) for v in p.renderers[-1].glyph.line_color[0:3]] [self.assertIsInstan...
['def', 'color_only_checks(self,', 'p,', 'rgb):', 'p.circle([1,', '2,', '3],', '[1,', '2,', '3],', 'color=rgb)', 'self.assertTupleEqual(p.renderers[-1].glyph.line_color,', 'rgb)', 'self.assertTupleEqual(p.renderers[-1].glyph.fill_color,', 'rgb)', '[self.assertIsInstance(v,', 'int)', 'for', 'v', 'in', 'p.renderers[-1].g...
977,420
devashish-patel/webcam-motion-detector
message.py
Message.assemble
assemble
Creates a new message, assembled from JSON fragments.
[ "Creates", "a", "new", "message,", "assembled", "from", "JSON", "fragments." ]
def assemble(cls, header_json, metadata_json, content_json): try: header = json_decode(header_json) except ValueError: raise MessageError('header could not be decoded') try: metadata = json_decode(metadata_json) except ValueError: raise MessageError('metadata could not be...
['def', 'assemble(cls,', 'header_json,', 'metadata_json,', 'content_json):', 'try:', 'header', '=', 'json_decode(header_json)', 'except', 'ValueError:', 'raise', "MessageError('header", 'could', 'not', 'be', "decoded')", 'try:', 'metadata', '=', 'json_decode(metadata_json)', 'except', 'ValueError:', 'raise', "MessageEr...
977,425
devashish-patel/webcam-motion-detector
message.py
Message.add_buffer
add_buffer
Associate a buffer header and payload with this message.
[ "Associate", "a", "buffer", "header", "and", "payload", "with", "this", "message." ]
def add_buffer(self, buf_header, buf_payload): if 'num_buffers' in self._header: self._header['num_buffers'] += 1 else: self._header['num_buffers'] = 1 self._header_json = None self._buffers.append((buf_header, buf_payload))
['def', 'add_buffer(self,', 'buf_header,', 'buf_payload):', 'if', "'num_buffers'", 'in', 'self._header:', "self._header['num_buffers']", '+=', '1', 'else:', "self._header['num_buffers']", '=', '1', 'self._header_json', '=', 'None', 'self._buffers.append((buf_header,', 'buf_payload))']
977,426
devashish-patel/webcam-motion-detector
message.py
Message.write_buffers
write_buffers
Write any buffer headers and payloads to the given connection.
[ "Write", "any", "buffer", "headers", "and", "payloads", "to", "the", "given", "connection." ]
def write_buffers(self, conn, locked=True): if conn is None: raise ValueError('Cannot write_buffers to connection None') sent = 0 for (header, payload) in self._buffers: yield conn.write_message(header, locked=locked) yield conn.write_message(payload, binary=True, locked=locked) ...
['def', 'write_buffers(self,', 'conn,', 'locked=True):', 'if', 'conn', 'is', 'None:', 'raise', "ValueError('Cannot", 'write_buffers', 'to', 'connection', "None')", 'sent', '=', '0', 'for', '(header,', 'payload)', 'in', 'self._buffers:', 'yield', 'conn.write_message(header,', 'locked=locked)', 'yield', 'conn.write_messa...
977,428
devashish-patel/webcam-motion-detector
message.py
Message.create_header
create_header
Return a message header fragment dict.
[ "Return", "a", "message", "header", "fragment", "dict." ]
def create_header(cls, request_id=None): header = {'msgid': bkserial.make_id(), 'msgtype': cls.msgtype} if request_id is not None: header['reqid'] = request_id return header
['def', 'create_header(cls,', 'request_id=None):', 'header', '=', "{'msgid':", 'bkserial.make_id(),', "'msgtype':", 'cls.msgtype}', 'if', 'request_id', 'is', 'not', 'None:', "header['reqid']", '=', 'request_id', 'return', 'header']
977,429
devashish-patel/webcam-motion-detector
message.py
Message.send
send
Send the message on the given connection.
[ "Send", "the", "message", "on", "the", "given", "connection." ]
def send(self, conn): if conn is None: raise ValueError('Cannot send to connection None') with (yield conn.write_lock.acquire()): sent = 0 yield conn.write_message(self.header_json, locked=False) sent += len(self.header_json) yield conn.write_message(self.metadata_json, l...
['def', 'send(self,', 'conn):', 'if', 'conn', 'is', 'None:', 'raise', "ValueError('Cannot", 'send', 'to', 'connection', "None')", 'with', '(yield', 'conn.write_lock.acquire()):', 'sent', '=', '0', 'yield', 'conn.write_message(self.header_json,', 'locked=False)', 'sent', '+=', 'len(self.header_json)', 'yield', 'conn.wri...
977,430
devashish-patel/webcam-motion-detector
callbacks.py
SessionCallback.callback
callback
The callable that this callback wraps.
[ "The", "callable", "that", "this", "callback", "wraps." ]
def callback(self): return self._callback
['def', 'callback(self):', 'return', 'self._callback']
977,435
devashish-patel/webcam-motion-detector
callbacks.py
PeriodicCallback.period
period
The period time (in milliseconds) that this callback should repeat execution at.
[ "The", "period", "time", "(in", "milliseconds)", "that", "this", "callback", "should", "repeat", "execution", "at." ]
def period(self): return self._period
['def', 'period(self):', 'return', 'self._period']
977,437
devashish-patel/webcam-motion-detector
callbacks.py
TimeoutCallback.timeout
timeout
The timeout (in milliseconds) that the callback should run after.
[ "The", "timeout", "(in", "milliseconds)", "that", "the", "callback", "should", "run", "after." ]
def timeout(self): return self._timeout
['def', 'timeout(self):', 'return', 'self._timeout']
977,438
devashish-patel/webcam-motion-detector
session.py
current_time
current_time
Return the time in milliseconds since the epoch as a floating point number.
[ "Return", "the", "time", "in", "milliseconds", "since", "the", "epoch", "as", "a", "floating", "point", "number." ]
def current_time(): try: return time.monotonic() * 1000 except: return time.time() * 1000
['def', 'current_time():', 'try:', 'return', 'time.monotonic()', '*', '1000', 'except:', 'return', 'time.time()', '*', '1000']
977,442
devashish-patel/webcam-motion-detector
tornado.py
BokehTornado.initialize
initialize
Start a Bokeh Server Tornado Application on a given Tornado IOLoop.
[ "Start", "a", "Bokeh", "Server", "Tornado", "Application", "on", "a", "given", "Tornado", "IOLoop." ]
def initialize(self, io_loop): self._loop = io_loop for app_context in self._applications.values(): app_context._loop = self._loop self._clients = set() self._stats_job = PeriodicCallback(self._log_stats, self._stats_log_frequency_milliseconds) self._cleanup_job = PeriodicCallback(self._clea...
['def', 'initialize(self,', 'io_loop):', 'self._loop', '=', 'io_loop', 'for', 'app_context', 'in', 'self._applications.values():', 'app_context._loop', '=', 'self._loop', 'self._clients', '=', 'set()', 'self._stats_job', '=', 'PeriodicCallback(self._log_stats,', 'self._stats_log_frequency_milliseconds)', 'self._cleanup...
977,450
devashish-patel/webcam-motion-detector
tornado.py
BokehTornado.secret_key
secret_key
A secret key for this Bokeh Server Tornado Application to use when signing session IDs, if configured.
[ "A", "secret", "key", "for", "this", "Bokeh", "Server", "Tornado", "Application", "to", "use", "when", "signing", "session", "IDs,", "if", "configured." ]
def secret_key(self): return self._secret_key
['def', 'secret_key(self):', 'return', 'self._secret_key']
977,455
devashish-patel/webcam-motion-detector
tornado.py
BokehTornado.stop
stop
Stop the Bokeh Server application.
[ "Stop", "the", "Bokeh", "Server", "application." ]
def stop(self, wait=True): for context in self._applications.values(): context.run_unload_hook() self._stats_job.stop() self._cleanup_job.stop() if self._ping_job is not None: self._ping_job.stop() self._clients.clear()
['def', 'stop(self,', 'wait=True):', 'for', 'context', 'in', 'self._applications.values():', 'context.run_unload_hook()', 'self._stats_job.stop()', 'self._cleanup_job.stop()', 'if', 'self._ping_job', 'is', 'not', 'None:', 'self._ping_job.stop()', 'self._clients.clear()']
977,460
devashish-patel/webcam-motion-detector
tornado.py
BokehTornado.get_session
get_session
Get an active a session by name application path and session ID.
[ "Get", "an", "active", "a", "session", "by", "name", "application", "path", "and", "session", "ID." ]
def get_session(self, app_path, session_id): if app_path not in self._applications: raise ValueError('Application %s does not exist on this server' % app_path) return self._applications[app_path].get_session(session_id)
['def', 'get_session(self,', 'app_path,', 'session_id):', 'if', 'app_path', 'not', 'in', 'self._applications:', 'raise', "ValueError('Application", '%s', 'does', 'not', 'exist', 'on', 'this', "server'", '%', 'app_path)', 'return', 'self._applications[app_path].get_session(session_id)']
977,461
devashish-patel/webcam-motion-detector
util.py
check_whitelist
check_whitelist
Check a given request host against a whitelist.
[ "Check", "a", "given", "request", "host", "against", "a", "whitelist." ]
def check_whitelist(host, whitelist): if ':' not in host: host = host + ':80' if host in whitelist: return True return any((match_host(host, pattern) for pattern in whitelist))
['def', 'check_whitelist(host,', 'whitelist):', 'if', "':'", 'not', 'in', 'host:', 'host', '=', 'host', '+', "':80'", 'if', 'host', 'in', 'whitelist:', 'return', 'True', 'return', 'any((match_host(host,', 'pattern)', 'for', 'pattern', 'in', 'whitelist))']
977,464
devashish-patel/webcam-motion-detector
ws.py
WSHandler.send_message
send_message
Send a Bokeh Server protocol message to the connected client.
[ "Send", "a", "Bokeh", "Server", "protocol", "message", "to", "the", "connected", "client." ]
def send_message(self, message): try: yield message.send(self) except WebSocketClosedError: log.warn('Failed sending message as connection was closed') raise gen.Return(None)
['def', 'send_message(self,', 'message):', 'try:', 'yield', 'message.send(self)', 'except', 'WebSocketClosedError:', "log.warn('Failed", 'sending', 'message', 'as', 'connection', 'was', "closed')", 'raise', 'gen.Return(None)']
977,470
devashish-patel/webcam-motion-detector
ws.py
WSHandler.write_message
write_message
Override parent write_message with a version that acquires a write lock before writing.
[ "Override", "parent", "write_message", "with", "a", "version", "that", "acquires", "a", "write", "lock", "before", "writing." ]
def write_message(self, message, binary=False, locked=True): def write_message_unlocked(): future = super(WSHandler, self).write_message(message, binary) raise gen.Return(future) if locked: with (yield self.write_lock.acquire()): write_message_unlocked() else: wr...
['def', 'write_message(self,', 'message,', 'binary=False,', 'locked=True):', 'def', 'write_message_unlocked():', 'future', '=', 'super(WSHandler,', 'self).write_message(message,', 'binary)', 'raise', 'gen.Return(future)', 'if', 'locked:', 'with', '(yield', 'self.write_lock.acquire()):', 'write_message_unlocked()', 'els...
977,471
devashish-patel/webcam-motion-detector
ws.py
WSHandler.on_close
on_close
Clean up when the connection is closed.
[ "Clean", "up", "when", "the", "connection", "is", "closed." ]
def on_close(self): log.info('WebSocket connection closed: code=%s, reason=%r', self.close_code, self.close_reason) if self.connection is not None: self.application.client_lost(self.connection)
['def', 'on_close(self):', "log.info('WebSocket", 'connection', 'closed:', 'code=%s,', "reason=%r',", 'self.close_code,', 'self.close_reason)', 'if', 'self.connection', 'is', 'not', 'None:', 'self.application.client_lost(self.connection)']
977,472
devashish-patel/webcam-motion-detector
bokeh_plot.py
html_page_context
html_page_context
Add BokehJS to pages that contain plots.
[ "Add", "BokehJS", "to", "pages", "that", "contain", "plots." ]
def html_page_context(app, pagename, templatename, context, doctree): if doctree and doctree.get('bokeh_plot_include_bokehjs'): context['bokeh_css_files'] = resources.css_files context['bokeh_js_files'] = resources.js_files
['def', 'html_page_context(app,', 'pagename,', 'templatename,', 'context,', 'doctree):', 'if', 'doctree', 'and', "doctree.get('bokeh_plot_include_bokehjs'):", "context['bokeh_css_files']", '=', 'resources.css_files', "context['bokeh_js_files']", '=', 'resources.js_files']
977,479
devashish-patel/webcam-motion-detector
bokeh_plot.py
env_purge_doc
env_purge_doc
Remove local files for a given document.
[ "Remove", "local", "files", "for", "a", "given", "document." ]
def env_purge_doc(app, env, docname): if docname in env.bokeh_plot_files: del env.bokeh_plot_files[docname]
['def', 'env_purge_doc(app,', 'env,', 'docname):', 'if', 'docname', 'in', 'env.bokeh_plot_files:', 'del', 'env.bokeh_plot_files[docname]']
977,480
devashish-patel/webcam-motion-detector
bokeh_plot.py
PlotScriptParser.parse
parse
Parse ``source``, write results to ``document``.
[ "Parse", "``source``,", "write", "results", "to", "``document``." ]
def parse(self, source, document): source = CODING.sub('', source) env = document.settings.env filename = env.doc2path(env.docname) m = ast.parse(source) docstring = ast.get_docstring(m) if docstring is not None: lines = source.split('\n') lineno = m.body[0].lineno source...
['def', 'parse(self,', 'source,', 'document):', 'source', '=', "CODING.sub('',", 'source)', 'env', '=', 'document.settings.env', 'filename', '=', 'env.doc2path(env.docname)', 'm', '=', 'ast.parse(source)', 'docstring', '=', 'ast.get_docstring(m)', 'if', 'docstring', 'is', 'not', 'None:', 'lines', '=', "source.split('\\...
977,482
devashish-patel/webcam-motion-detector
bokeh_sitemap.py
html_page_context
html_page_context
Collect page names for the sitemap as HTML pages are built.
[ "Collect", "page", "names", "for", "the", "sitemap", "as", "HTML", "pages", "are", "built." ]
def html_page_context(app, pagename, templatename, context, doctree): site = context['SITEMAP_BASE_URL'] version = context['version'] app.sitemap_links.add(site + version + '/' + pagename + '.html')
['def', 'html_page_context(app,', 'pagename,', 'templatename,', 'context,', 'doctree):', 'site', '=', "context['SITEMAP_BASE_URL']", 'version', '=', "context['version']", 'app.sitemap_links.add(site', '+', 'version', '+', "'/'", '+', 'pagename', '+', "'.html')"]
977,483
devashish-patel/webcam-motion-detector
test_resources.py
test_external_js_and_css_resource_embedding
test_external_js_and_css_resource_embedding
This test method has to be at the end of the test modules because subclassing a Model causes the CustomModel to be added as a MetaModel and messes up the Resources state for the other tests.
[ "This", "test", "method", "has", "to", "be", "at", "the", "end", "of", "the", "test", "modules", "because", "subclassing", "a", "Model", "causes", "the", "CustomModel", "to", "be", "added", "as", "a", "MetaModel", "and", "messes", "up", "the", "Resources",...
def test_external_js_and_css_resource_embedding(): class CustomModel1(Model): __javascript__ = 'external_js_1' __css__ = 'external_css_1' class CustomModel2(Model): __javascript__ = ['external_js_2', 'external_js_3'] __css__ = ['external_css_2', 'external_css_3'] class Cus...
['def', 'test_external_js_and_css_resource_embedding():', 'class', 'CustomModel1(Model):', '__javascript__', '=', "'external_js_1'", '__css__', '=', "'external_css_1'", 'class', 'CustomModel2(Model):', '__javascript__', '=', "['external_js_2',", "'external_js_3']", '__css__', '=', "['external_css_2',", "'external_css_3...
977,485
devashish-patel/webcam-motion-detector
browser.py
get_browser_controller
get_browser_controller
Return a browser controller.
[ "Return", "a", "browser", "controller." ]
def get_browser_controller(browser=None): browser = settings.browser(browser) if browser is not None: if browser == 'none': controller = DummyWebBrowser() else: controller = webbrowser.get(browser) else: controller = webbrowser return controller
['def', 'get_browser_controller(browser=None):', 'browser', '=', 'settings.browser(browser)', 'if', 'browser', 'is', 'not', 'None:', 'if', 'browser', '==', "'none':", 'controller', '=', 'DummyWebBrowser()', 'else:', 'controller', '=', 'webbrowser.get(browser)', 'else:', 'controller', '=', 'webbrowser', 'return', 'contr...
977,489
devashish-patel/webcam-motion-detector
callback_manager.py
PropertyCallbackManager.trigger
trigger
Trigger callbacks for ``attr`` on this object.
[ "Trigger", "callbacks", "for", "``attr``", "on", "this", "object." ]
def trigger(self, attr, old, new, hint=None, setter=None): def invoke(): callbacks = self._callbacks.get(attr) if callbacks: for callback in callbacks: callback(attr, old, new) if hasattr(self, '_document') and self._document is not None: self._document._noti...
['def', 'trigger(self,', 'attr,', 'old,', 'new,', 'hint=None,', 'setter=None):', 'def', 'invoke():', 'callbacks', '=', 'self._callbacks.get(attr)', 'if', 'callbacks:', 'for', 'callback', 'in', 'callbacks:', 'callback(attr,', 'old,', 'new)', 'if', 'hasattr(self,', "'_document')", 'and', 'self._document', 'is', 'not', 'N...
977,494
devashish-patel/webcam-motion-detector
compiler.py
bundle_models
bundle_models
Create a bundle of `models`.
[ "Create", "a", "bundle", "of", "`models`." ]
def bundle_models(models): custom_models = {} for cls in models: impl = getattr(cls, '__implementation__', None) if impl is not None: model = CustomModel(cls) custom_models[model.full_name] = model if not custom_models: return None ordered_models = sorted(...
['def', 'bundle_models(models):', 'custom_models', '=', '{}', 'for', 'cls', 'in', 'models:', 'impl', '=', 'getattr(cls,', "'__implementation__',", 'None)', 'if', 'impl', 'is', 'not', 'None:', 'model', '=', 'CustomModel(cls)', 'custom_models[model.full_name]', '=', 'model', 'if', 'not', 'custom_models:', 'return', 'None...
977,495
devashish-patel/webcam-motion-detector
dependencies.py
detect_phantomjs
detect_phantomjs
Detect if PhantomJS is avaiable in PATH, at a minimum version.
[ "Detect", "if", "PhantomJS", "is", "avaiable", "in", "PATH,", "at", "a", "minimum", "version." ]
def detect_phantomjs(version='2.1'): if settings.phantomjs_path() is not None: phantomjs_path = settings.phantomjs_path() else: try: phantomjs_path = shutil.which('phantomjs') except AttributeError: phantomjs_path = 'phantomjs' try: proc = Popen([phant...
['def', "detect_phantomjs(version='2.1'):", 'if', 'settings.phantomjs_path()', 'is', 'not', 'None:', 'phantomjs_path', '=', 'settings.phantomjs_path()', 'else:', 'try:', 'phantomjs_path', '=', "shutil.which('phantomjs')", 'except', 'AttributeError:', 'phantomjs_path', '=', "'phantomjs'", 'try:', 'proc', '=', 'Popen([ph...
977,499
devashish-patel/webcam-motion-detector
sampledata.py
download
download
Download larger data sets for various Bokeh examples.
[ "Download", "larger", "data", "sets", "for", "various", "Bokeh", "examples." ]
def download(progress=True): data_dir = external_data_dir(create=True) print('Using data directory: %s' % data_dir) s3 = 'https://s3.amazonaws.com/bokeh_data/' files = [(s3, 'CGM.csv'), (s3, 'US_Counties.zip'), (s3, 'us_cities.json'), (s3, 'unemployment09.csv'), (s3, 'AAPL.csv'), (s3, 'FB.csv'), (s3, 'G...
['def', 'download(progress=True):', 'data_dir', '=', 'external_data_dir(create=True)', "print('Using", 'data', 'directory:', "%s'", '%', 'data_dir)', 's3', '=', "'https://s3.amazonaws.com/bokeh_data/'", 'files', '=', '[(s3,', "'CGM.csv'),", '(s3,', "'US_Counties.zip'),", '(s3,', "'us_cities.json'),", '(s3,', "'unemploy...
977,506
devashish-patel/webcam-motion-detector
serialization.py
serialize_array
serialize_array
Transforms a NumPy array into serialized form.
[ "Transforms", "a", "NumPy", "array", "into", "serialized", "form." ]
def serialize_array(array, force_list=False, buffers=None): if isinstance(array, np.ma.MaskedArray): array = array.filled(np.nan) if array_encoding_disabled(array) or force_list: return transform_array_to_list(array) if not array.flags['C_CONTIGUOUS']: array = np.ascontiguousarray(ar...
['def', 'serialize_array(array,', 'force_list=False,', 'buffers=None):', 'if', 'isinstance(array,', 'np.ma.MaskedArray):', 'array', '=', 'array.filled(np.nan)', 'if', 'array_encoding_disabled(array)', 'or', 'force_list:', 'return', 'transform_array_to_list(array)', 'if', 'not', "array.flags['C_CONTIGUOUS']:", 'array', ...
977,515
devashish-patel/webcam-motion-detector
string.py
encode_utf8
encode_utf8
Encode a UTF-8 string to a sequence of bytes.
[ "Encode", "a", "UTF-8", "string", "to", "a", "sequence", "of", "bytes." ]
def encode_utf8(u): import sys if sys.version_info[0] == 2: u = u.encode('utf-8') return u
['def', 'encode_utf8(u):', 'import', 'sys', 'if', 'sys.version_info[0]', '==', '2:', 'u', '=', "u.encode('utf-8')", 'return', 'u']
977,524
devashish-patel/webcam-motion-detector
string.py
indent
indent
Indent all the lines in a given block of text by a specified ammount.
[ "Indent", "all", "the", "lines", "in", "a", "given", "block", "of", "text", "by", "a", "specified", "ammount." ]
def indent(text, n=2, ch=' '): padding = ch * n return '\n'.join([padding + line for line in text.split('\n')])
['def', 'indent(text,', 'n=2,', "ch='", "'):", 'padding', '=', 'ch', '*', 'n', 'return', "'\\n'.join([padding", '+', 'line', 'for', 'line', 'in', "text.split('\\n')])"]
977,526
devashish-patel/webcam-motion-detector
string.py
nice_join
nice_join
Join together sequences of strings into English-friendly phrases using the conjunction ``or`` when appropriate.
[ "Join", "together", "sequences", "of", "strings", "into", "English-friendly", "phrases", "using", "the", "conjunction", "``or``", "when", "appropriate." ]
def nice_join(seq, sep=', '): seq = [str(x) for x in seq] if len(seq) <= 1: return sep.join(seq) else: return '%s or %s' % (sep.join(seq[:-1]), seq[-1])
['def', 'nice_join(seq,', "sep=',", "'):", 'seq', '=', '[str(x)', 'for', 'x', 'in', 'seq]', 'if', 'len(seq)', '<=', '1:', 'return', 'sep.join(seq)', 'else:', 'return', "'%s", 'or', "%s'", '%', '(sep.join(seq[:-1]),', 'seq[-1])']
977,527
devashish-patel/webcam-motion-detector
tornado.py
_CallbackGroup.remove_all_callbacks
remove_all_callbacks
Removes all registered callbacks.
[ "Removes", "all", "registered", "callbacks." ]
def remove_all_callbacks(self): for cb in list(self._next_tick_callbacks.keys()): self.remove_next_tick_callback(cb) for cb in list(self._timeout_callbacks.keys()): self.remove_timeout_callback(cb) for cb in list(self._periodic_callbacks.keys()): self.remove_periodic_callback(cb)
['def', 'remove_all_callbacks(self):', 'for', 'cb', 'in', 'list(self._next_tick_callbacks.keys()):', 'self.remove_next_tick_callback(cb)', 'for', 'cb', 'in', 'list(self._timeout_callbacks.keys()):', 'self.remove_timeout_callback(cb)', 'for', 'cb', 'in', 'list(self._periodic_callbacks.keys()):', 'self.remove_periodic_ca...
977,532
devashish-patel/webcam-motion-detector
tornado.py
_CallbackGroup.remove_next_tick_callback
remove_next_tick_callback
Removes a callback added with add_next_tick_callback.
[ "Removes", "a", "callback", "added", "with", "add_next_tick_callback." ]
def remove_next_tick_callback(self, callback): self._remove(callback, self._next_tick_callbacks)
['def', 'remove_next_tick_callback(self,', 'callback):', 'self._remove(callback,', 'self._next_tick_callbacks)']
977,534
devashish-patel/webcam-motion-detector
tornado.py
_CallbackGroup.remove_timeout_callback
remove_timeout_callback
Removes a callback added with add_timeout_callback, before it runs.
[ "Removes", "a", "callback", "added", "with", "add_timeout_callback,", "before", "it", "runs." ]
def remove_timeout_callback(self, callback): self._remove(callback, self._timeout_callbacks)
['def', 'remove_timeout_callback(self,', 'callback):', 'self._remove(callback,', 'self._timeout_callbacks)']
977,536
devashish-patel/webcam-motion-detector
tornado.py
_CallbackGroup.add_periodic_callback
add_periodic_callback
Adds a callback to be run every period_milliseconds until it is removed.
[ "Adds", "a", "callback", "to", "be", "run", "every", "period_milliseconds", "until", "it", "is", "removed." ]
def add_periodic_callback(self, callback, period_milliseconds, cleanup=None): if callback in self._periodic_callbacks: raise ValueError('Callback added as a periodic callback twice') cb = _AsyncPeriodic(callback, period_milliseconds, io_loop=self._loop) def remover(): cb.stop() self...
['def', 'add_periodic_callback(self,', 'callback,', 'period_milliseconds,', 'cleanup=None):', 'if', 'callback', 'in', 'self._periodic_callbacks:', 'raise', "ValueError('Callback", 'added', 'as', 'a', 'periodic', 'callback', "twice')", 'cb', '=', '_AsyncPeriodic(callback,', 'period_milliseconds,', 'io_loop=self._loop)',...
977,537
devashish-patel/webcam-motion-detector
tornado.py
_CallbackGroup.remove_periodic_callback
remove_periodic_callback
Removes a callback added with add_periodic_callback.
[ "Removes", "a", "callback", "added", "with", "add_periodic_callback." ]
def remove_periodic_callback(self, callback): self._remove(callback, self._periodic_callbacks)
['def', 'remove_periodic_callback(self,', 'callback):', 'self._remove(callback,', 'self._periodic_callbacks)']
977,538
devashish-patel/webcam-motion-detector
__init__.py
unique
unique
Class decorator that ensures only unique members exist in an enumeration.
[ "Class", "decorator", "that", "ensures", "only", "unique", "members", "exist", "in", "an", "enumeration." ]
def unique(enumeration): duplicates = [] for (name, member) in enumeration.__members__.items(): if name != member.name: duplicates.append((name, member.name)) if duplicates: duplicate_names = ', '.join(['%s -> %s' % (alias, name) for (alias, name) in duplicates]) raise Va...
['def', 'unique(enumeration):', 'duplicates', '=', '[]', 'for', '(name,', 'member)', 'in', 'enumeration.__members__.items():', 'if', 'name', '!=', 'member.name:', 'duplicates.append((name,', 'member.name))', 'if', 'duplicates:', 'duplicate_names', '=', "',", "'.join(['%s", '->', "%s'", '%', '(alias,', 'name)', 'for', '...
977,706
devashish-patel/webcam-motion-detector
completer.py
IPCompleter.all_completions
all_completions
Wrapper around the complete method for the benefit of emacs.
[ "Wrapper", "around", "the", "complete", "method", "for", "the", "benefit", "of", "emacs." ]
def all_completions(self, text): return self.complete(text)[1]
['def', 'all_completions(self,', 'text):', 'return', 'self.complete(text)[1]']
978,536
devashish-patel/webcam-motion-detector
magics.py
TerminalMagics.autoindent
autoindent
Toggle autoindent on/off (if available).
[ "Toggle", "autoindent", "on/off", "(if", "available)." ]
def autoindent(self, parameter_s=''): self.shell.set_autoindent() print('Automatic indentation is:', ['OFF', 'ON'][self.shell.autoindent])
['def', 'autoindent(self,', "parameter_s=''):", 'self.shell.set_autoindent()', "print('Automatic", 'indentation', "is:',", "['OFF',", "'ON'][self.shell.autoindent])"]
979,284
devashish-patel/webcam-motion-detector
warn.py
info
info
Deprecated Equivalent to warn(msg,level=1).
[ "Deprecated", "Equivalent", "to", "warn(msg,level=1)." ]
def info(msg): warn(msg, level=1)
['def', 'info(msg):', 'warn(msg,', 'level=1)']
979,480
devashish-patel/webcam-motion-detector
util.py
mergetree
mergetree
Recursively merge a directory tree using mergecopy().
[ "Recursively", "merge", "a", "directory", "tree", "using", "mergecopy()." ]
def mergetree(src, dst, condition=None, copyfn=mergecopy, srcbase=None): src = fsencoding(src) dst = fsencoding(dst) if srcbase is None: srcbase = src names = map(fsencoding, os.listdir(src)) try: os.makedirs(dst) except OSError: pass errors = [] for name in names...
['def', 'mergetree(src,', 'dst,', 'condition=None,', 'copyfn=mergecopy,', 'srcbase=None):', 'src', '=', 'fsencoding(src)', 'dst', '=', 'fsencoding(dst)', 'if', 'srcbase', 'is', 'None:', 'srcbase', '=', 'src', 'names', '=', 'map(fsencoding,', 'os.listdir(src))', 'try:', 'os.makedirs(dst)', 'except', 'OSError:', 'pass', ...
980,160
devashish-patel/webcam-motion-detector
util.py
sdk_normalize
sdk_normalize
Normalize a path to strip out the SDK portion, normally so that it can be decided whether it is in a system path or not.
[ "Normalize", "a", "path", "to", "strip", "out", "the", "SDK", "portion,", "normally", "so", "that", "it", "can", "be", "decided", "whether", "it", "is", "in", "a", "system", "path", "or", "not." ]
def sdk_normalize(filename): if filename.startswith('/Developer/SDKs/'): pathcomp = filename.split('/') del pathcomp[1:4] filename = '/'.join(pathcomp) return filename
['def', 'sdk_normalize(filename):', 'if', "filename.startswith('/Developer/SDKs/'):", 'pathcomp', '=', "filename.split('/')", 'del', 'pathcomp[1:4]', 'filename', '=', "'/'.join(pathcomp)", 'return', 'filename']
980,161
devashish-patel/webcam-motion-detector
test_nbconvertapp.py
TestNbConvertApp.test_markdown_display_priority
test_markdown_display_priority
Check to see if markdown conversion embedds PNGs, even if an (unsupported) PDF is present.
[ "Check", "to", "see", "if", "markdown", "conversion", "embedds", "PNGs,", "even", "if", "an", "(unsupported)", "PDF", "is", "present." ]
def test_markdown_display_priority(self): with self.create_temp_cwd(['markdown_display_priority.ipynb']): self.nbconvert('--log-level 0 --to markdown "markdown_display_priority.ipynb"') assert os.path.isfile('markdown_display_priority.md') with io.open('markdown_display_priority.md') as f: ...
['def', 'test_markdown_display_priority(self):', 'with', "self.create_temp_cwd(['markdown_display_priority.ipynb']):", "self.nbconvert('--log-level", '0', '--to', 'markdown', '"markdown_display_priority.ipynb"\')', 'assert', "os.path.isfile('markdown_display_priority.md')", 'with', "io.open('markdown_display_priority.m...
980,402
devashish-patel/webcam-motion-detector
basic.py
load_auto_suggestion_bindings
load_auto_suggestion_bindings
Key bindings for accepting auto suggestion text.
[ "Key", "bindings", "for", "accepting", "auto", "suggestion", "text." ]
def load_auto_suggestion_bindings(): registry = Registry() handle = registry.add_binding suggestion_available = Condition(lambda cli: cli.current_buffer.suggestion is not None and cli.current_buffer.document.is_cursor_at_the_end) @handle(Keys.ControlF, filter=suggestion_available) @handle(Keys.Cont...
['def', 'load_auto_suggestion_bindings():', 'registry', '=', 'Registry()', 'handle', '=', 'registry.add_binding', 'suggestion_available', '=', 'Condition(lambda', 'cli:', 'cli.current_buffer.suggestion', 'is', 'not', 'None', 'and', 'cli.current_buffer.document.is_cursor_at_the_end)', '@handle(Keys.ControlF,', 'filter=s...
983,915
devashish-patel/webcam-motion-detector
prompt.py
DefaultPrompt.from_message
from_message
Create a default prompt with a static message text.
[ "Create", "a", "default", "prompt", "with", "a", "static", "message", "text." ]
def from_message(cls, message='> '): assert isinstance(message, text_type) def get_message_tokens(cli): return [(Token.Prompt, message)] return cls(get_message_tokens)
['def', 'from_message(cls,', "message='>", "'):", 'assert', 'isinstance(message,', 'text_type)', 'def', 'get_message_tokens(cli):', 'return', '[(Token.Prompt,', 'message)]', 'return', 'cls(get_message_tokens)']
984,035
devashish-patel/webcam-motion-detector
compat.py
setenv
setenv
Accepts unicode string and set it as environment variable 'name' containing value 'value'.
[ "Accepts", "unicode", "string", "and", "set", "it", "as", "environment", "variable", "'name'", "containing", "value", "'value'." ]
def setenv(name, value): os.environ[name] = value
['def', 'setenv(name,', 'value):', 'os.environ[name]', '=', 'value']
984,193
devashish-patel/webcam-motion-detector
compat.py
expand_path
expand_path
Replace initial tilde '~' in path with user's home directory and also expand environment variables (${VARNAME} - Unix, %VARNAME% - Windows).
[ "Replace", "initial", "tilde", "'~'", "in", "path", "with", "user's", "home", "directory", "and", "also", "expand", "environment", "variables", "(${VARNAME}", "-", "Unix,", "%VARNAME%", "-", "Windows)." ]
def expand_path(path): return os.path.expandvars(os.path.expanduser(path))
['def', 'expand_path(path):', 'return', 'os.path.expandvars(os.path.expanduser(path))']
984,199
devashish-patel/webcam-motion-detector
readers.py
CTOCReader.get
get
Return the table of contents entry (tuple) at index NDX.
[ "Return", "the", "table", "of", "contents", "entry", "(tuple)", "at", "index", "NDX." ]
def get(self, ndx): return self.data[ndx]
['def', 'get(self,', 'ndx):', 'return', 'self.data[ndx]']
984,206
devashish-patel/webcam-motion-detector
readers.py
CArchiveReader.loadtoc
loadtoc
Load the table of contents into memory.
[ "Load", "the", "table", "of", "contents", "into", "memory." ]
def loadtoc(self): self.toc = CTOCReader() self.lib.seek(self.pkg_start + self.tocpos) tocstr = self.lib.read(self.toclen) self.toc.frombinary(tocstr)
['def', 'loadtoc(self):', 'self.toc', '=', 'CTOCReader()', 'self.lib.seek(self.pkg_start', '+', 'self.tocpos)', 'tocstr', '=', 'self.lib.read(self.toclen)', 'self.toc.frombinary(tocstr)']
984,209
devashish-patel/webcam-motion-detector
writers.py
CTOC.tobinary
tobinary
Return self as a binary string.
[ "Return", "self", "as", "a", "binary", "string." ]
def tobinary(self): rslt = [] for (dpos, dlen, ulen, flag, typcd, nm) in self.data: if is_py2 and isinstance(nm, str): nm = nm.decode(sys.getfilesystemencoding()) nm = nm.encode('utf-8') nmlen = len(nm) + 1 toclen = nmlen + self.ENTRYLEN if toclen % 16 == 0: ...
['def', 'tobinary(self):', 'rslt', '=', '[]', 'for', '(dpos,', 'dlen,', 'ulen,', 'flag,', 'typcd,', 'nm)', 'in', 'self.data:', 'if', 'is_py2', 'and', 'isinstance(nm,', 'str):', 'nm', '=', 'nm.decode(sys.getfilesystemencoding())', 'nm', '=', "nm.encode('utf-8')", 'nmlen', '=', 'len(nm)', '+', '1', 'toclen', '=', 'nmlen'...
984,216