repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.unblockall
def unblockall(self): ''' Remove all blocks from the queue and all sub-queues ''' for q in self.queues.values(): q.unblockall() self.blockEvents.clear()
python
def unblockall(self): ''' Remove all blocks from the queue and all sub-queues ''' for q in self.queues.values(): q.unblockall() self.blockEvents.clear()
[ "def", "unblockall", "(", "self", ")", ":", "for", "q", "in", "self", ".", "queues", ".", "values", "(", ")", ":", "q", ".", "unblockall", "(", ")", "self", ".", "blockEvents", ".", "clear", "(", ")" ]
Remove all blocks from the queue and all sub-queues
[ "Remove", "all", "blocks", "from", "the", "queue", "and", "all", "sub", "-", "queues" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L881-L887
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.notifyAppend
def notifyAppend(self, queue, force): ''' Internal notify for sub-queues :returns: If the append is blocked by parent, an EventMatcher is returned, None else. ''' if not force and not self.canAppend(): self.isWaited = True return self._matcher ...
python
def notifyAppend(self, queue, force): ''' Internal notify for sub-queues :returns: If the append is blocked by parent, an EventMatcher is returned, None else. ''' if not force and not self.canAppend(): self.isWaited = True return self._matcher ...
[ "def", "notifyAppend", "(", "self", ",", "queue", ",", "force", ")", ":", "if", "not", "force", "and", "not", "self", ".", "canAppend", "(", ")", ":", "self", ".", "isWaited", "=", "True", "return", "self", ".", "_matcher", "if", "self", ".", "parent...
Internal notify for sub-queues :returns: If the append is blocked by parent, an EventMatcher is returned, None else.
[ "Internal", "notify", "for", "sub", "-", "queues", ":", "returns", ":", "If", "the", "append", "is", "blocked", "by", "parent", "an", "EventMatcher", "is", "returned", "None", "else", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L888-L902
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.notifyBlock
def notifyBlock(self, queue, blocked): ''' Internal notify for sub-queues been blocked ''' if blocked: if self.prioritySet[-1] == queue.priority: self.prioritySet.pop() else: pindex = bisect_left(self.prioritySet, queue.priority) ...
python
def notifyBlock(self, queue, blocked): ''' Internal notify for sub-queues been blocked ''' if blocked: if self.prioritySet[-1] == queue.priority: self.prioritySet.pop() else: pindex = bisect_left(self.prioritySet, queue.priority) ...
[ "def", "notifyBlock", "(", "self", ",", "queue", ",", "blocked", ")", ":", "if", "blocked", ":", "if", "self", ".", "prioritySet", "[", "-", "1", "]", "==", "queue", ".", "priority", ":", "self", ".", "prioritySet", ".", "pop", "(", ")", "else", ":...
Internal notify for sub-queues been blocked
[ "Internal", "notify", "for", "sub", "-", "queues", "been", "blocked" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L903-L923
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.notifyPop
def notifyPop(self, queue, length = 1): ''' Internal notify for sub-queues been poped :returns: List of any events generated by this pop ''' self.totalSize = self.totalSize - length ret1 = [] ret2 = [] if self.isWaited and self.canAppend(): ...
python
def notifyPop(self, queue, length = 1): ''' Internal notify for sub-queues been poped :returns: List of any events generated by this pop ''' self.totalSize = self.totalSize - length ret1 = [] ret2 = [] if self.isWaited and self.canAppend(): ...
[ "def", "notifyPop", "(", "self", ",", "queue", ",", "length", "=", "1", ")", ":", "self", ".", "totalSize", "=", "self", ".", "totalSize", "-", "length", "ret1", "=", "[", "]", "ret2", "=", "[", "]", "if", "self", ".", "isWaited", "and", "self", ...
Internal notify for sub-queues been poped :returns: List of any events generated by this pop
[ "Internal", "notify", "for", "sub", "-", "queues", "been", "poped", ":", "returns", ":", "List", "of", "any", "events", "generated", "by", "this", "pop" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L924-L948
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.pop
def pop(self): ''' Pop an event from the queue. The event in the queue with higher priority is popped before ones in lower priority. If there are multiple queues with the same priority, events are taken in turn from each queue. May return some queueEvents indicating that some of the queu...
python
def pop(self): ''' Pop an event from the queue. The event in the queue with higher priority is popped before ones in lower priority. If there are multiple queues with the same priority, events are taken in turn from each queue. May return some queueEvents indicating that some of the queu...
[ "def", "pop", "(", "self", ")", ":", "ret", "=", "self", ".", "_pop", "(", ")", "if", "self", ".", "parent", "is", "not", "None", ":", "pr", "=", "self", ".", "parent", ".", "notifyPop", "(", "self", ")", "ret", "[", "1", "]", ".", "extend", ...
Pop an event from the queue. The event in the queue with higher priority is popped before ones in lower priority. If there are multiple queues with the same priority, events are taken in turn from each queue. May return some queueEvents indicating that some of the queues can be written into. ...
[ "Pop", "an", "event", "from", "the", "queue", ".", "The", "event", "in", "the", "queue", "with", "higher", "priority", "is", "popped", "before", "ones", "in", "lower", "priority", ".", "If", "there", "are", "multiple", "queues", "with", "the", "same", "p...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L956-L970
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue._pop
def _pop(self): ''' Actual pop ''' if not self.canPop(): raise IndexError('pop from an empty or blocked queue') priority = self.prioritySet[-1] ret = self.queues[priority]._pop() self.outputStat = self.outputStat + 1 self.totalSize = self.total...
python
def _pop(self): ''' Actual pop ''' if not self.canPop(): raise IndexError('pop from an empty or blocked queue') priority = self.prioritySet[-1] ret = self.queues[priority]._pop() self.outputStat = self.outputStat + 1 self.totalSize = self.total...
[ "def", "_pop", "(", "self", ")", ":", "if", "not", "self", ".", "canPop", "(", ")", ":", "raise", "IndexError", "(", "'pop from an empty or blocked queue'", ")", "priority", "=", "self", ".", "prioritySet", "[", "-", "1", "]", "ret", "=", "self", ".", ...
Actual pop
[ "Actual", "pop" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L971-L987
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.clear
def clear(self): ''' Clear all the events in this queue, including any sub-queues. :returns: ((queueEvents,...), (queueEmptyEvents,...)) where queueEvents are QueueCanWriteEvents generated by clearing. ''' l = len(self) ret = self._clear() if self.parent ...
python
def clear(self): ''' Clear all the events in this queue, including any sub-queues. :returns: ((queueEvents,...), (queueEmptyEvents,...)) where queueEvents are QueueCanWriteEvents generated by clearing. ''' l = len(self) ret = self._clear() if self.parent ...
[ "def", "clear", "(", "self", ")", ":", "l", "=", "len", "(", "self", ")", "ret", "=", "self", ".", "_clear", "(", ")", "if", "self", ".", "parent", "is", "not", "None", ":", "pr", "=", "self", ".", "parent", ".", "notifyPop", "(", "self", ",", ...
Clear all the events in this queue, including any sub-queues. :returns: ((queueEvents,...), (queueEmptyEvents,...)) where queueEvents are QueueCanWriteEvents generated by clearing.
[ "Clear", "all", "the", "events", "in", "this", "queue", "including", "any", "sub", "-", "queues", ".", ":", "returns", ":", "((", "queueEvents", "...", ")", "(", "queueEmptyEvents", "...", "))", "where", "queueEvents", "are", "QueueCanWriteEvents", "generated"...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L988-L1000
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue._clear
def _clear(self): ''' Actual clear ''' ret = ([],[]) for q in self.queues.values(): pr = q._clear() ret[0].extend(pr[0]) ret[1].extend(pr[1]) self.totalSize = 0 del self.prioritySet[:] if self.isWaited and self.canAppend...
python
def _clear(self): ''' Actual clear ''' ret = ([],[]) for q in self.queues.values(): pr = q._clear() ret[0].extend(pr[0]) ret[1].extend(pr[1]) self.totalSize = 0 del self.prioritySet[:] if self.isWaited and self.canAppend...
[ "def", "_clear", "(", "self", ")", ":", "ret", "=", "(", "[", "]", ",", "[", "]", ")", "for", "q", "in", "self", ".", "queues", ".", "values", "(", ")", ":", "pr", "=", "q", ".", "_clear", "(", ")", "ret", "[", "0", "]", ".", "extend", "(...
Actual clear
[ "Actual", "clear" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L1001-L1019
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.setPriority
def setPriority(self, queue, priority): ''' Set priority of a sub-queue ''' q = self.queueindex[queue] self.queues[q[0]].removeSubQueue(q[1]) newPriority = self.queues.setdefault(priority, CBQueue.MultiQueue(self, priority)) q[0] = priority newPriority.add...
python
def setPriority(self, queue, priority): ''' Set priority of a sub-queue ''' q = self.queueindex[queue] self.queues[q[0]].removeSubQueue(q[1]) newPriority = self.queues.setdefault(priority, CBQueue.MultiQueue(self, priority)) q[0] = priority newPriority.add...
[ "def", "setPriority", "(", "self", ",", "queue", ",", "priority", ")", ":", "q", "=", "self", ".", "queueindex", "[", "queue", "]", "self", ".", "queues", "[", "q", "[", "0", "]", "]", ".", "removeSubQueue", "(", "q", "[", "1", "]", ")", "newPrio...
Set priority of a sub-queue
[ "Set", "priority", "of", "a", "sub", "-", "queue" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L1032-L1040
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.addSubQueue
def addSubQueue(self, priority, matcher, name = None, maxdefault = None, maxtotal = None, defaultQueueClass = FifoQueue): ''' add a sub queue to current queue, with a priority and a matcher :param priority: priority of this queue. Larger is higher, 0 is lowest. :param m...
python
def addSubQueue(self, priority, matcher, name = None, maxdefault = None, maxtotal = None, defaultQueueClass = FifoQueue): ''' add a sub queue to current queue, with a priority and a matcher :param priority: priority of this queue. Larger is higher, 0 is lowest. :param m...
[ "def", "addSubQueue", "(", "self", ",", "priority", ",", "matcher", ",", "name", "=", "None", ",", "maxdefault", "=", "None", ",", "maxtotal", "=", "None", ",", "defaultQueueClass", "=", "FifoQueue", ")", ":", "if", "name", "is", "not", "None", "and", ...
add a sub queue to current queue, with a priority and a matcher :param priority: priority of this queue. Larger is higher, 0 is lowest. :param matcher: an event matcher to catch events. Every event match the criteria will be stored in this queue. :param name: a unique ...
[ "add", "a", "sub", "queue", "to", "current", "queue", "with", "a", "priority", "and", "a", "matcher", ":", "param", "priority", ":", "priority", "of", "this", "queue", ".", "Larger", "is", "higher", "0", "is", "lowest", ".", ":", "param", "matcher", ":...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L1042-L1066
train
hubo1016/vlcp
vlcp/event/pqueue.py
CBQueue.removeSubQueue
def removeSubQueue(self, queue): ''' remove a sub queue from current queue. This unblock the sub-queue, retrieve all events from the queue and put them back to the parent. Call clear on the sub-queue first if the events are not needed any more. :param q...
python
def removeSubQueue(self, queue): ''' remove a sub queue from current queue. This unblock the sub-queue, retrieve all events from the queue and put them back to the parent. Call clear on the sub-queue first if the events are not needed any more. :param q...
[ "def", "removeSubQueue", "(", "self", ",", "queue", ")", ":", "q", "=", "self", ".", "queueindex", "[", "queue", "]", "q", "[", "1", "]", ".", "unblockall", "(", ")", "q", "[", "1", "]", ".", "_removeFromTree", "(", ")", "ret", "=", "(", "[", "...
remove a sub queue from current queue. This unblock the sub-queue, retrieve all events from the queue and put them back to the parent. Call clear on the sub-queue first if the events are not needed any more. :param queue: the name or queue object to remove ...
[ "remove", "a", "sub", "queue", "from", "current", "queue", ".", "This", "unblock", "the", "sub", "-", "queue", "retrieve", "all", "events", "from", "the", "queue", "and", "put", "them", "back", "to", "the", "parent", ".", "Call", "clear", "on", "the", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/pqueue.py#L1067-L1098
train
hubo1016/vlcp
vlcp/utils/walkerlib.py
ensure_keys
def ensure_keys(walk, *keys): """ Use walk to try to retrieve all keys """ all_retrieved = True for k in keys: try: walk(k) except WalkKeyNotRetrieved: all_retrieved = False return all_retrieved
python
def ensure_keys(walk, *keys): """ Use walk to try to retrieve all keys """ all_retrieved = True for k in keys: try: walk(k) except WalkKeyNotRetrieved: all_retrieved = False return all_retrieved
[ "def", "ensure_keys", "(", "walk", ",", "*", "keys", ")", ":", "all_retrieved", "=", "True", "for", "k", "in", "keys", ":", "try", ":", "walk", "(", "k", ")", "except", "WalkKeyNotRetrieved", ":", "all_retrieved", "=", "False", "return", "all_retrieved" ]
Use walk to try to retrieve all keys
[ "Use", "walk", "to", "try", "to", "retrieve", "all", "keys" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/walkerlib.py#L9-L19
train
hubo1016/vlcp
doc/source/ext/configlist.py
list_config
def list_config(root_package = 'vlcp'): ''' Walk through all the sub modules, find subclasses of vlcp.config.Configurable, list their available configurations through _default_ prefix ''' pkg = __import__(root_package, fromlist=['_']) return_dict = OrderedDict() for imp, module, _ in walk_pa...
python
def list_config(root_package = 'vlcp'): ''' Walk through all the sub modules, find subclasses of vlcp.config.Configurable, list their available configurations through _default_ prefix ''' pkg = __import__(root_package, fromlist=['_']) return_dict = OrderedDict() for imp, module, _ in walk_pa...
[ "def", "list_config", "(", "root_package", "=", "'vlcp'", ")", ":", "pkg", "=", "__import__", "(", "root_package", ",", "fromlist", "=", "[", "'_'", "]", ")", "return_dict", "=", "OrderedDict", "(", ")", "for", "imp", ",", "module", ",", "_", "in", "wa...
Walk through all the sub modules, find subclasses of vlcp.config.Configurable, list their available configurations through _default_ prefix
[ "Walk", "through", "all", "the", "sub", "modules", "find", "subclasses", "of", "vlcp", ".", "config", ".", "Configurable", "list", "their", "available", "configurations", "through", "_default_", "prefix" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/doc/source/ext/configlist.py#L22-L89
train
hubo1016/vlcp
vlcp/utils/http.py
http
def http(container = None): "wrap a WSGI-style class method to a HTTPRequest event handler" def decorator(func): @functools.wraps(func) def handler(self, event): return _handler(self if container is None else container, event, lambda env: func(self, env)) return handler r...
python
def http(container = None): "wrap a WSGI-style class method to a HTTPRequest event handler" def decorator(func): @functools.wraps(func) def handler(self, event): return _handler(self if container is None else container, event, lambda env: func(self, env)) return handler r...
[ "def", "http", "(", "container", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "handler", "(", "self", ",", "event", ")", ":", "return", "_handler", "(", "self", "if", "co...
wrap a WSGI-style class method to a HTTPRequest event handler
[ "wrap", "a", "WSGI", "-", "style", "class", "method", "to", "a", "HTTPRequest", "event", "handler" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L607-L614
train
hubo1016/vlcp
vlcp/utils/http.py
statichttp
def statichttp(container = None): "wrap a WSGI-style function to a HTTPRequest event handler" def decorator(func): @functools.wraps(func) def handler(event): return _handler(container, event, func) if hasattr(func, '__self__'): handler.__self__ = func.__self__ ...
python
def statichttp(container = None): "wrap a WSGI-style function to a HTTPRequest event handler" def decorator(func): @functools.wraps(func) def handler(event): return _handler(container, event, func) if hasattr(func, '__self__'): handler.__self__ = func.__self__ ...
[ "def", "statichttp", "(", "container", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "handler", "(", "event", ")", ":", "return", "_handler", "(", "container", ",", "event", ...
wrap a WSGI-style function to a HTTPRequest event handler
[ "wrap", "a", "WSGI", "-", "style", "function", "to", "a", "HTTPRequest", "event", "handler" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L616-L625
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.start_response
def start_response(self, status = 200, headers = [], clearheaders = True, disabletransferencoding = False): "Start to send response" if self._sendHeaders: raise HttpProtocolException('Cannot modify response, headers already sent') self.status = status self.disabledeflate = di...
python
def start_response(self, status = 200, headers = [], clearheaders = True, disabletransferencoding = False): "Start to send response" if self._sendHeaders: raise HttpProtocolException('Cannot modify response, headers already sent') self.status = status self.disabledeflate = di...
[ "def", "start_response", "(", "self", ",", "status", "=", "200", ",", "headers", "=", "[", "]", ",", "clearheaders", "=", "True", ",", "disabletransferencoding", "=", "False", ")", ":", "if", "self", ".", "_sendHeaders", ":", "raise", "HttpProtocolException"...
Start to send response
[ "Start", "to", "send", "response" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L145-L154
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.header
def header(self, key, value, replace = True): "Send a new header" if hasattr(key, 'encode'): key = key.encode('ascii') if hasattr(value, 'encode'): value = value.encode(self.encoding) if replace: self.sent_headers = [(k,v) for k,v in self.sent_headers ...
python
def header(self, key, value, replace = True): "Send a new header" if hasattr(key, 'encode'): key = key.encode('ascii') if hasattr(value, 'encode'): value = value.encode(self.encoding) if replace: self.sent_headers = [(k,v) for k,v in self.sent_headers ...
[ "def", "header", "(", "self", ",", "key", ",", "value", ",", "replace", "=", "True", ")", ":", "if", "hasattr", "(", "key", ",", "'encode'", ")", ":", "key", "=", "key", ".", "encode", "(", "'ascii'", ")", "if", "hasattr", "(", "value", ",", "'en...
Send a new header
[ "Send", "a", "new", "header" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L158-L166
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.rawheader
def rawheader(self, kv, replace = True): """ Add a header with "<Header>: Value" string """ if hasattr(kv, 'encode'): kv = kv.encode(self.encoding) k,v = kv.split(b':', 1) self.header(k, v.strip(), replace)
python
def rawheader(self, kv, replace = True): """ Add a header with "<Header>: Value" string """ if hasattr(kv, 'encode'): kv = kv.encode(self.encoding) k,v = kv.split(b':', 1) self.header(k, v.strip(), replace)
[ "def", "rawheader", "(", "self", ",", "kv", ",", "replace", "=", "True", ")", ":", "if", "hasattr", "(", "kv", ",", "'encode'", ")", ":", "kv", "=", "kv", ".", "encode", "(", "self", ".", "encoding", ")", "k", ",", "v", "=", "kv", ".", "split",...
Add a header with "<Header>: Value" string
[ "Add", "a", "header", "with", "<Header", ">", ":", "Value", "string" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L167-L174
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.setcookie
def setcookie(self, key, value, max_age=None, expires=None, path='/', domain=None, secure=None, httponly=False): """ Add a new cookie """ newcookie = Morsel() newcookie.key = key newcookie.value = value newcookie.coded_value = value if max_age is not None:...
python
def setcookie(self, key, value, max_age=None, expires=None, path='/', domain=None, secure=None, httponly=False): """ Add a new cookie """ newcookie = Morsel() newcookie.key = key newcookie.value = value newcookie.coded_value = value if max_age is not None:...
[ "def", "setcookie", "(", "self", ",", "key", ",", "value", ",", "max_age", "=", "None", ",", "expires", "=", "None", ",", "path", "=", "'/'", ",", "domain", "=", "None", ",", "secure", "=", "None", ",", "httponly", "=", "False", ")", ":", "newcooki...
Add a new cookie
[ "Add", "a", "new", "cookie" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L175-L196
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.bufferoutput
def bufferoutput(self): """ Buffer the whole output until write EOF or flushed. """ new_stream = Stream(writebufferlimit=None) if self._sendHeaders: # An extra copy self.container.subroutine(new_stream.copy_to(self.outputstream, self.container, buffering=F...
python
def bufferoutput(self): """ Buffer the whole output until write EOF or flushed. """ new_stream = Stream(writebufferlimit=None) if self._sendHeaders: # An extra copy self.container.subroutine(new_stream.copy_to(self.outputstream, self.container, buffering=F...
[ "def", "bufferoutput", "(", "self", ")", ":", "new_stream", "=", "Stream", "(", "writebufferlimit", "=", "None", ")", "if", "self", ".", "_sendHeaders", ":", "# An extra copy", "self", ".", "container", ".", "subroutine", "(", "new_stream", ".", "copy_to", "...
Buffer the whole output until write EOF or flushed.
[ "Buffer", "the", "whole", "output", "until", "write", "EOF", "or", "flushed", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L197-L205
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.rewrite
async def rewrite(self, path, method = None, keepresponse = True): "Rewrite this request to another processor. Must be called before header sent" if self._sendHeaders: raise HttpProtocolException('Cannot modify response, headers already sent') if getattr(self.event, 'rewritedepth', 0...
python
async def rewrite(self, path, method = None, keepresponse = True): "Rewrite this request to another processor. Must be called before header sent" if self._sendHeaders: raise HttpProtocolException('Cannot modify response, headers already sent') if getattr(self.event, 'rewritedepth', 0...
[ "async", "def", "rewrite", "(", "self", ",", "path", ",", "method", "=", "None", ",", "keepresponse", "=", "True", ")", ":", "if", "self", ".", "_sendHeaders", ":", "raise", "HttpProtocolException", "(", "'Cannot modify response, headers already sent'", ")", "if...
Rewrite this request to another processor. Must be called before header sent
[ "Rewrite", "this", "request", "to", "another", "processor", ".", "Must", "be", "called", "before", "header", "sent" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L216-L249
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.redirect
async def redirect(self, path, status = 302): """ Redirect this request with 3xx status """ location = urljoin(urlunsplit((b'https' if self.https else b'http', self.host, ...
python
async def redirect(self, path, status = 302): """ Redirect this request with 3xx status """ location = urljoin(urlunsplit((b'https' if self.https else b'http', self.host, ...
[ "async", "def", "redirect", "(", "self", ",", "path", ",", "status", "=", "302", ")", ":", "location", "=", "urljoin", "(", "urlunsplit", "(", "(", "b'https'", "if", "self", ".", "https", "else", "b'http'", ",", "self", ".", "host", ",", "quote_from_by...
Redirect this request with 3xx status
[ "Redirect", "this", "request", "with", "3xx", "status" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L250-L262
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.nl2br
def nl2br(self, text): """ Replace \'\n\' with \'<br/>\\n\' """ if isinstance(text, bytes): return text.replace(b'\n', b'<br/>\n') else: return text.replace('\n', '<br/>\n')
python
def nl2br(self, text): """ Replace \'\n\' with \'<br/>\\n\' """ if isinstance(text, bytes): return text.replace(b'\n', b'<br/>\n') else: return text.replace('\n', '<br/>\n')
[ "def", "nl2br", "(", "self", ",", "text", ")", ":", "if", "isinstance", "(", "text", ",", "bytes", ")", ":", "return", "text", ".", "replace", "(", "b'\\n'", ",", "b'<br/>\\n'", ")", "else", ":", "return", "text", ".", "replace", "(", "'\\n'", ",", ...
Replace \'\n\' with \'<br/>\\n\'
[ "Replace", "\\", "\\", "n", "\\", "with", "\\", "<br", "/", ">", "\\\\", "n", "\\" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L263-L270
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.escape
def escape(self, text, quote = True): """ Escape special characters in HTML """ if isinstance(text, bytes): return escape_b(text, quote) else: return escape(text, quote)
python
def escape(self, text, quote = True): """ Escape special characters in HTML """ if isinstance(text, bytes): return escape_b(text, quote) else: return escape(text, quote)
[ "def", "escape", "(", "self", ",", "text", ",", "quote", "=", "True", ")", ":", "if", "isinstance", "(", "text", ",", "bytes", ")", ":", "return", "escape_b", "(", "text", ",", "quote", ")", "else", ":", "return", "escape", "(", "text", ",", "quote...
Escape special characters in HTML
[ "Escape", "special", "characters", "in", "HTML" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L271-L278
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.error
async def error(self, status=500, allowredirect = True, close = True, showerror = None, headers = []): """ Show default error response """ if showerror is None: showerror = self.showerrorinfo if self._sendHeaders: if showerror: typ, exc, tb...
python
async def error(self, status=500, allowredirect = True, close = True, showerror = None, headers = []): """ Show default error response """ if showerror is None: showerror = self.showerrorinfo if self._sendHeaders: if showerror: typ, exc, tb...
[ "async", "def", "error", "(", "self", ",", "status", "=", "500", ",", "allowredirect", "=", "True", ",", "close", "=", "True", ",", "showerror", "=", "None", ",", "headers", "=", "[", "]", ")", ":", "if", "showerror", "is", "None", ":", "showerror", ...
Show default error response
[ "Show", "default", "error", "response" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L279-L304
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.write
async def write(self, data, eof = False, buffering = True): """ Write output to current output stream """ if not self.outputstream: self.outputstream = Stream() self._startResponse() elif (not buffering or eof) and not self._sendHeaders: self._...
python
async def write(self, data, eof = False, buffering = True): """ Write output to current output stream """ if not self.outputstream: self.outputstream = Stream() self._startResponse() elif (not buffering or eof) and not self._sendHeaders: self._...
[ "async", "def", "write", "(", "self", ",", "data", ",", "eof", "=", "False", ",", "buffering", "=", "True", ")", ":", "if", "not", "self", ".", "outputstream", ":", "self", ".", "outputstream", "=", "Stream", "(", ")", "self", ".", "_startResponse", ...
Write output to current output stream
[ "Write", "output", "to", "current", "output", "stream" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L305-L316
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.writelines
async def writelines(self, lines, eof = False, buffering = True): """ Write lines to current output stream """ for l in lines: await self.write(l, False, buffering) if eof: await self.write(b'', eof, buffering)
python
async def writelines(self, lines, eof = False, buffering = True): """ Write lines to current output stream """ for l in lines: await self.write(l, False, buffering) if eof: await self.write(b'', eof, buffering)
[ "async", "def", "writelines", "(", "self", ",", "lines", ",", "eof", "=", "False", ",", "buffering", "=", "True", ")", ":", "for", "l", "in", "lines", ":", "await", "self", ".", "write", "(", "l", ",", "False", ",", "buffering", ")", "if", "eof", ...
Write lines to current output stream
[ "Write", "lines", "to", "current", "output", "stream" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L317-L324
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.output
def output(self, stream, disabletransferencoding = None): """ Set output stream and send response immediately """ if self._sendHeaders: raise HttpProtocolException('Cannot modify response, headers already sent') self.outputstream = stream try: cont...
python
def output(self, stream, disabletransferencoding = None): """ Set output stream and send response immediately """ if self._sendHeaders: raise HttpProtocolException('Cannot modify response, headers already sent') self.outputstream = stream try: cont...
[ "def", "output", "(", "self", ",", "stream", ",", "disabletransferencoding", "=", "None", ")", ":", "if", "self", ".", "_sendHeaders", ":", "raise", "HttpProtocolException", "(", "'Cannot modify response, headers already sent'", ")", "self", ".", "outputstream", "="...
Set output stream and send response immediately
[ "Set", "output", "stream", "and", "send", "response", "immediately" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L330-L345
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.outputdata
def outputdata(self, data): """ Send output with fixed length data """ if not isinstance(data, bytes): data = str(data).encode(self.encoding) self.output(MemoryStream(data))
python
def outputdata(self, data): """ Send output with fixed length data """ if not isinstance(data, bytes): data = str(data).encode(self.encoding) self.output(MemoryStream(data))
[ "def", "outputdata", "(", "self", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "bytes", ")", ":", "data", "=", "str", "(", "data", ")", ".", "encode", "(", "self", ".", "encoding", ")", "self", ".", "output", "(", "MemoryStre...
Send output with fixed length data
[ "Send", "output", "with", "fixed", "length", "data" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L346-L352
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.close
async def close(self): """ Close this request, send all data. You can still run other operations in the handler. """ if not self._sendHeaders: self._startResponse() if self.inputstream is not None: self.inputstream.close(self.connection.scheduler) ...
python
async def close(self): """ Close this request, send all data. You can still run other operations in the handler. """ if not self._sendHeaders: self._startResponse() if self.inputstream is not None: self.inputstream.close(self.connection.scheduler) ...
[ "async", "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "_sendHeaders", ":", "self", ".", "_startResponse", "(", ")", "if", "self", ".", "inputstream", "is", "not", "None", ":", "self", ".", "inputstream", ".", "close", "(", "self", ...
Close this request, send all data. You can still run other operations in the handler.
[ "Close", "this", "request", "send", "all", "data", ".", "You", "can", "still", "run", "other", "operations", "in", "the", "handler", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L353-L364
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.parseform
async def parseform(self, limit = 67108864, tostr = True, safename = True): ''' Parse form-data with multipart/form-data or application/x-www-form-urlencoded In Python3, the keys of form and files are unicode, but values are bytes If the key ends with '[]', it is considered to be a list:...
python
async def parseform(self, limit = 67108864, tostr = True, safename = True): ''' Parse form-data with multipart/form-data or application/x-www-form-urlencoded In Python3, the keys of form and files are unicode, but values are bytes If the key ends with '[]', it is considered to be a list:...
[ "async", "def", "parseform", "(", "self", ",", "limit", "=", "67108864", ",", "tostr", "=", "True", ",", "safename", "=", "True", ")", ":", "if", "tostr", ":", "def", "_str", "(", "s", ")", ":", "try", ":", "if", "not", "isinstance", "(", "s", ",...
Parse form-data with multipart/form-data or application/x-www-form-urlencoded In Python3, the keys of form and files are unicode, but values are bytes If the key ends with '[]', it is considered to be a list: a=1&b=2&b=3 => {'a':1,'b':3} a[]=1&b[]=2&b[]=3 => {'a':[1],'b...
[ "Parse", "form", "-", "data", "with", "multipart", "/", "form", "-", "data", "or", "application", "/", "x", "-", "www", "-", "form", "-", "urlencoded", "In", "Python3", "the", "keys", "of", "form", "and", "files", "are", "unicode", "but", "values", "ar...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L368-L473
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.sessionstart
async def sessionstart(self): "Start session. Must start service.utils.session.Session to use this method" if not hasattr(self, 'session') or not self.session: self.session, setcookies = await call_api(self.container, 'session', 'start', {'cookies':self.rawcookie}) for nc in setc...
python
async def sessionstart(self): "Start session. Must start service.utils.session.Session to use this method" if not hasattr(self, 'session') or not self.session: self.session, setcookies = await call_api(self.container, 'session', 'start', {'cookies':self.rawcookie}) for nc in setc...
[ "async", "def", "sessionstart", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'session'", ")", "or", "not", "self", ".", "session", ":", "self", ".", "session", ",", "setcookies", "=", "await", "call_api", "(", "self", ".", "contain...
Start session. Must start service.utils.session.Session to use this method
[ "Start", "session", ".", "Must", "start", "service", ".", "utils", ".", "session", ".", "Session", "to", "use", "this", "method" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L474-L480
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.sessiondestroy
async def sessiondestroy(self): """ Destroy current session. The session object is discarded and can no longer be used in other requests. """ if hasattr(self, 'session') and self.session: setcookies = await call_api(self.container, 'session', 'destroy', {'sessionid':self.sess...
python
async def sessiondestroy(self): """ Destroy current session. The session object is discarded and can no longer be used in other requests. """ if hasattr(self, 'session') and self.session: setcookies = await call_api(self.container, 'session', 'destroy', {'sessionid':self.sess...
[ "async", "def", "sessiondestroy", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'session'", ")", "and", "self", ".", "session", ":", "setcookies", "=", "await", "call_api", "(", "self", ".", "container", ",", "'session'", ",", "'destroy'", "...
Destroy current session. The session object is discarded and can no longer be used in other requests.
[ "Destroy", "current", "session", ".", "The", "session", "object", "is", "discarded", "and", "can", "no", "longer", "be", "used", "in", "other", "requests", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L481-L491
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.basicauth
def basicauth(self, realm = b'all', nofail = False): "Try to get the basic authorize info, return (username, password) if succeeded, return 401 otherwise" if b'authorization' in self.headerdict: auth = self.headerdict[b'authorization'] auth_pair = auth.split(b' ', 1) ...
python
def basicauth(self, realm = b'all', nofail = False): "Try to get the basic authorize info, return (username, password) if succeeded, return 401 otherwise" if b'authorization' in self.headerdict: auth = self.headerdict[b'authorization'] auth_pair = auth.split(b' ', 1) ...
[ "def", "basicauth", "(", "self", ",", "realm", "=", "b'all'", ",", "nofail", "=", "False", ")", ":", "if", "b'authorization'", "in", "self", ".", "headerdict", ":", "auth", "=", "self", ".", "headerdict", "[", "b'authorization'", "]", "auth_pair", "=", "...
Try to get the basic authorize info, return (username, password) if succeeded, return 401 otherwise
[ "Try", "to", "get", "the", "basic", "authorize", "info", "return", "(", "username", "password", ")", "if", "succeeded", "return", "401", "otherwise" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L492-L511
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.basicauthfail
def basicauthfail(self, realm = b'all'): """ Return 401 for authentication failure. This will end the handler. """ if not isinstance(realm, bytes): realm = realm.encode('ascii') self.start_response(401, [(b'WWW-Authenticate', b'Basic realm="' + realm + b'"')]) ...
python
def basicauthfail(self, realm = b'all'): """ Return 401 for authentication failure. This will end the handler. """ if not isinstance(realm, bytes): realm = realm.encode('ascii') self.start_response(401, [(b'WWW-Authenticate', b'Basic realm="' + realm + b'"')]) ...
[ "def", "basicauthfail", "(", "self", ",", "realm", "=", "b'all'", ")", ":", "if", "not", "isinstance", "(", "realm", ",", "bytes", ")", ":", "realm", "=", "realm", ".", "encode", "(", "'ascii'", ")", "self", ".", "start_response", "(", "401", ",", "[...
Return 401 for authentication failure. This will end the handler.
[ "Return", "401", "for", "authentication", "failure", ".", "This", "will", "end", "the", "handler", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L512-L519
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.getrealpath
def getrealpath(self, root, path): ''' Return the real path on disk from the query path, from a root path. The input path from URL might be absolute '/abc', or point to parent '../test', or even with UNC or drive '\\test\abc', 'c:\test.abc', which creates security issues when acc...
python
def getrealpath(self, root, path): ''' Return the real path on disk from the query path, from a root path. The input path from URL might be absolute '/abc', or point to parent '../test', or even with UNC or drive '\\test\abc', 'c:\test.abc', which creates security issues when acc...
[ "def", "getrealpath", "(", "self", ",", "root", ",", "path", ")", ":", "if", "not", "isinstance", "(", "path", ",", "str", ")", ":", "path", "=", "path", ".", "decode", "(", "self", ".", "encoding", ")", "# In windows, if the path starts with multiple / or \...
Return the real path on disk from the query path, from a root path. The input path from URL might be absolute '/abc', or point to parent '../test', or even with UNC or drive '\\test\abc', 'c:\test.abc', which creates security issues when accessing file contents with the path. With getrea...
[ "Return", "the", "real", "path", "on", "disk", "from", "the", "query", "path", "from", "a", "root", "path", ".", "The", "input", "path", "from", "URL", "might", "be", "absolute", "/", "abc", "or", "point", "to", "parent", "..", "/", "test", "or", "ev...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L520-L544
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.argstostr
def argstostr(self): "Query string arguments are bytes in Python3. This function Convert bytes to string with env.encoding(default to utf-8)." self.args = dict((k, self._tostr(v)) for k,v in self.args.items()) return self.args
python
def argstostr(self): "Query string arguments are bytes in Python3. This function Convert bytes to string with env.encoding(default to utf-8)." self.args = dict((k, self._tostr(v)) for k,v in self.args.items()) return self.args
[ "def", "argstostr", "(", "self", ")", ":", "self", ".", "args", "=", "dict", "(", "(", "k", ",", "self", ".", "_tostr", "(", "v", ")", ")", "for", "k", ",", "v", "in", "self", ".", "args", ".", "items", "(", ")", ")", "return", "self", ".", ...
Query string arguments are bytes in Python3. This function Convert bytes to string with env.encoding(default to utf-8).
[ "Query", "string", "arguments", "are", "bytes", "in", "Python3", ".", "This", "function", "Convert", "bytes", "to", "string", "with", "env", ".", "encoding", "(", "default", "to", "utf", "-", "8", ")", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L552-L555
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.cookietostr
def cookietostr(self): "Cookie values are bytes in Python3. This function Convert bytes to string with env.encoding(default to utf-8)." self.cookies = dict((k, (v.decode(self.encoding) if not isinstance(v, str) else v)) for k,v in self.cookies.items()) return self.cookies
python
def cookietostr(self): "Cookie values are bytes in Python3. This function Convert bytes to string with env.encoding(default to utf-8)." self.cookies = dict((k, (v.decode(self.encoding) if not isinstance(v, str) else v)) for k,v in self.cookies.items()) return self.cookies
[ "def", "cookietostr", "(", "self", ")", ":", "self", ".", "cookies", "=", "dict", "(", "(", "k", ",", "(", "v", ".", "decode", "(", "self", ".", "encoding", ")", "if", "not", "isinstance", "(", "v", ",", "str", ")", "else", "v", ")", ")", "for"...
Cookie values are bytes in Python3. This function Convert bytes to string with env.encoding(default to utf-8).
[ "Cookie", "values", "are", "bytes", "in", "Python3", ".", "This", "function", "Convert", "bytes", "to", "string", "with", "env", ".", "encoding", "(", "default", "to", "utf", "-", "8", ")", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L556-L559
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.createcsrf
async def createcsrf(self, csrfarg = '_csrf'): """ Create a anti-CSRF token in the session """ await self.sessionstart() if not csrfarg in self.session.vars: self.session.vars[csrfarg] = uuid.uuid4().hex
python
async def createcsrf(self, csrfarg = '_csrf'): """ Create a anti-CSRF token in the session """ await self.sessionstart() if not csrfarg in self.session.vars: self.session.vars[csrfarg] = uuid.uuid4().hex
[ "async", "def", "createcsrf", "(", "self", ",", "csrfarg", "=", "'_csrf'", ")", ":", "await", "self", ".", "sessionstart", "(", ")", "if", "not", "csrfarg", "in", "self", ".", "session", ".", "vars", ":", "self", ".", "session", ".", "vars", "[", "cs...
Create a anti-CSRF token in the session
[ "Create", "a", "anti", "-", "CSRF", "token", "in", "the", "session" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L560-L566
train
hubo1016/vlcp
vlcp/utils/http.py
Environment.outputjson
def outputjson(self, obj): """ Serialize `obj` with JSON and output to the client """ self.header('Content-Type', 'application/json') self.outputdata(json.dumps(obj).encode('ascii'))
python
def outputjson(self, obj): """ Serialize `obj` with JSON and output to the client """ self.header('Content-Type', 'application/json') self.outputdata(json.dumps(obj).encode('ascii'))
[ "def", "outputjson", "(", "self", ",", "obj", ")", ":", "self", ".", "header", "(", "'Content-Type'", ",", "'application/json'", ")", "self", ".", "outputdata", "(", "json", ".", "dumps", "(", "obj", ")", ".", "encode", "(", "'ascii'", ")", ")" ]
Serialize `obj` with JSON and output to the client
[ "Serialize", "obj", "with", "JSON", "and", "output", "to", "the", "client" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L567-L572
train
hubo1016/vlcp
vlcp/utils/http.py
Dispatcher.routeevent
def routeevent(self, path, routinemethod, container = None, host = None, vhost = None, method = [b'GET', b'HEAD']): ''' Route specified path to a routine factory :param path: path to match, can be a regular expression :param routinemethod: factory function routinemetho...
python
def routeevent(self, path, routinemethod, container = None, host = None, vhost = None, method = [b'GET', b'HEAD']): ''' Route specified path to a routine factory :param path: path to match, can be a regular expression :param routinemethod: factory function routinemetho...
[ "def", "routeevent", "(", "self", ",", "path", ",", "routinemethod", ",", "container", "=", "None", ",", "host", "=", "None", ",", "vhost", "=", "None", ",", "method", "=", "[", "b'GET'", ",", "b'HEAD'", "]", ")", ":", "regm", "=", "re", ".", "comp...
Route specified path to a routine factory :param path: path to match, can be a regular expression :param routinemethod: factory function routinemethod(event), event is the HttpRequestEvent :param container: routine container. If None, default to self for bound method,...
[ "Route", "specified", "path", "to", "a", "routine", "factory", ":", "param", "path", ":", "path", "to", "match", "can", "be", "a", "regular", "expression", ":", "param", "routinemethod", ":", "factory", "function", "routinemethod", "(", "event", ")", "event"...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L632-L689
train
hubo1016/vlcp
vlcp/utils/http.py
Dispatcher.route
def route(self, path, routinemethod, container = None, host = None, vhost = None, method = [b'GET', b'HEAD']): ''' Route specified path to a WSGI-styled routine factory :param path: path to match, can be a regular expression :param routinemethod: factory function routi...
python
def route(self, path, routinemethod, container = None, host = None, vhost = None, method = [b'GET', b'HEAD']): ''' Route specified path to a WSGI-styled routine factory :param path: path to match, can be a regular expression :param routinemethod: factory function routi...
[ "def", "route", "(", "self", ",", "path", ",", "routinemethod", ",", "container", "=", "None", ",", "host", "=", "None", ",", "vhost", "=", "None", ",", "method", "=", "[", "b'GET'", ",", "b'HEAD'", "]", ")", ":", "self", ".", "routeevent", "(", "p...
Route specified path to a WSGI-styled routine factory :param path: path to match, can be a regular expression :param routinemethod: factory function routinemethod(env), env is an Environment object see also utils.http.Environment :param container: rout...
[ "Route", "specified", "path", "to", "a", "WSGI", "-", "styled", "routine", "factory", ":", "param", "path", ":", "path", "to", "match", "can", "be", "a", "regular", "expression", ":", "param", "routinemethod", ":", "factory", "function", "routinemethod", "("...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L690-L708
train
hubo1016/vlcp
vlcp/utils/http.py
Dispatcher.routeargs
def routeargs(self, path, routinemethod, container = None, host = None, vhost = None, method = [b'POST'], tostr = True, matchargs = (), fileargs=(), queryargs=(), cookieargs=(), sessionargs=(), csrfcheck = False, csrfarg = '_csrf', formlimit = 67108864): ''' Convenien...
python
def routeargs(self, path, routinemethod, container = None, host = None, vhost = None, method = [b'POST'], tostr = True, matchargs = (), fileargs=(), queryargs=(), cookieargs=(), sessionargs=(), csrfcheck = False, csrfarg = '_csrf', formlimit = 67108864): ''' Convenien...
[ "def", "routeargs", "(", "self", ",", "path", ",", "routinemethod", ",", "container", "=", "None", ",", "host", "=", "None", ",", "vhost", "=", "None", ",", "method", "=", "[", "b'POST'", "]", ",", "tostr", "=", "True", ",", "matchargs", "=", "(", ...
Convenient way to route a processor with arguments. Automatically parse arguments and pass them to the corresponding handler arguments. If required arguments are missing, HttpInputException is thrown which creates a 400 Bad Request response. If optional arguments are missing, they are replaced with defa...
[ "Convenient", "way", "to", "route", "a", "processor", "with", "arguments", ".", "Automatically", "parse", "arguments", "and", "pass", "them", "to", "the", "corresponding", "handler", "arguments", ".", "If", "required", "arguments", "are", "missing", "HttpInputExce...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L709-L877
train
hubo1016/vlcp
vlcp/utils/http.py
Dispatcher.expand
def expand(cls, match, expand): """ If use expand directly, the url-decoded context will be decoded again, which create a security issue. Hack expand to quote the text before expanding """ return re._expand(match.re, cls._EncodedMatch(match), expand)
python
def expand(cls, match, expand): """ If use expand directly, the url-decoded context will be decoded again, which create a security issue. Hack expand to quote the text before expanding """ return re._expand(match.re, cls._EncodedMatch(match), expand)
[ "def", "expand", "(", "cls", ",", "match", ",", "expand", ")", ":", "return", "re", ".", "_expand", "(", "match", ".", "re", ",", "cls", ".", "_EncodedMatch", "(", "match", ")", ",", "expand", ")" ]
If use expand directly, the url-decoded context will be decoded again, which create a security issue. Hack expand to quote the text before expanding
[ "If", "use", "expand", "directly", "the", "url", "-", "decoded", "context", "will", "be", "decoded", "again", "which", "create", "a", "security", "issue", ".", "Hack", "expand", "to", "quote", "the", "text", "before", "expanding" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L887-L892
train
hubo1016/vlcp
vlcp/utils/http.py
Dispatcher.rewrite
def rewrite(self, path, expand, newmethod = None, host = None, vhost = None, method = [b'GET', b'HEAD'], keepquery = True): "Automatically rewrite a request to another location" async def func(env): newpath = self.expand(env.path_match, expand) if keepquery and getattr(env, 'quer...
python
def rewrite(self, path, expand, newmethod = None, host = None, vhost = None, method = [b'GET', b'HEAD'], keepquery = True): "Automatically rewrite a request to another location" async def func(env): newpath = self.expand(env.path_match, expand) if keepquery and getattr(env, 'quer...
[ "def", "rewrite", "(", "self", ",", "path", ",", "expand", ",", "newmethod", "=", "None", ",", "host", "=", "None", ",", "vhost", "=", "None", ",", "method", "=", "[", "b'GET'", ",", "b'HEAD'", "]", ",", "keepquery", "=", "True", ")", ":", "async",...
Automatically rewrite a request to another location
[ "Automatically", "rewrite", "a", "request", "to", "another", "location" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L893-L903
train
hubo1016/vlcp
vlcp/utils/http.py
HttpHandler.routeargs
def routeargs(path, host = None, vhost = None, method = [b'POST'], **kwargs): "For extra arguments, see Dispatcher.routeargs. They must be specified by keyword arguments" def decorator(func): func.routemode = 'routeargs' func.route_path = path func.route_host = host ...
python
def routeargs(path, host = None, vhost = None, method = [b'POST'], **kwargs): "For extra arguments, see Dispatcher.routeargs. They must be specified by keyword arguments" def decorator(func): func.routemode = 'routeargs' func.route_path = path func.route_host = host ...
[ "def", "routeargs", "(", "path", ",", "host", "=", "None", ",", "vhost", "=", "None", ",", "method", "=", "[", "b'POST'", "]", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "func", ")", ":", "func", ".", "routemode", "=", "'routeargs'...
For extra arguments, see Dispatcher.routeargs. They must be specified by keyword arguments
[ "For", "extra", "arguments", "see", "Dispatcher", ".", "routeargs", ".", "They", "must", "be", "specified", "by", "keyword", "arguments" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L944-L954
train
hubo1016/vlcp
vlcp/event/runnable.py
_close_generator
def _close_generator(g): """ PyPy 3 generator has a bug that calling `close` caused memory leak. Before it is fixed, use `throw` instead """ if isinstance(g, generatorwrapper): g.close() elif _get_frame(g) is not None: try: g.throw(GeneratorExit_) except (Stop...
python
def _close_generator(g): """ PyPy 3 generator has a bug that calling `close` caused memory leak. Before it is fixed, use `throw` instead """ if isinstance(g, generatorwrapper): g.close() elif _get_frame(g) is not None: try: g.throw(GeneratorExit_) except (Stop...
[ "def", "_close_generator", "(", "g", ")", ":", "if", "isinstance", "(", "g", ",", "generatorwrapper", ")", ":", "g", ".", "close", "(", ")", "elif", "_get_frame", "(", "g", ")", "is", "not", "None", ":", "try", ":", "g", ".", "throw", "(", "Generat...
PyPy 3 generator has a bug that calling `close` caused memory leak. Before it is fixed, use `throw` instead
[ "PyPy", "3", "generator", "has", "a", "bug", "that", "calling", "close", "caused", "memory", "leak", ".", "Before", "it", "is", "fixed", "use", "throw", "instead" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L102-L115
train
hubo1016/vlcp
vlcp/event/runnable.py
Routine
def Routine(coroutine, scheduler, asyncStart = True, container = None, manualStart = False, daemon = False): """ This wraps a normal coroutine to become a VLCP routine. Usually you do not need to call this yourself; `container.start` and `container.subroutine` calls this automatically. """ def run()...
python
def Routine(coroutine, scheduler, asyncStart = True, container = None, manualStart = False, daemon = False): """ This wraps a normal coroutine to become a VLCP routine. Usually you do not need to call this yourself; `container.start` and `container.subroutine` calls this automatically. """ def run()...
[ "def", "Routine", "(", "coroutine", ",", "scheduler", ",", "asyncStart", "=", "True", ",", "container", "=", "None", ",", "manualStart", "=", "False", ",", "daemon", "=", "False", ")", ":", "def", "run", "(", ")", ":", "iterator", "=", "_await", "(", ...
This wraps a normal coroutine to become a VLCP routine. Usually you do not need to call this yourself; `container.start` and `container.subroutine` calls this automatically.
[ "This", "wraps", "a", "normal", "coroutine", "to", "become", "a", "VLCP", "routine", ".", "Usually", "you", "do", "not", "need", "to", "call", "this", "yourself", ";", "container", ".", "start", "and", "container", ".", "subroutine", "calls", "this", "auto...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L194-L290
train
hubo1016/vlcp
vlcp/event/runnable.py
EventHandler.registerHandler
def registerHandler(self, matcher, handler): ''' Register self to scheduler ''' self.handlers[matcher] = handler self.scheduler.register((matcher,), self) self._setDaemon()
python
def registerHandler(self, matcher, handler): ''' Register self to scheduler ''' self.handlers[matcher] = handler self.scheduler.register((matcher,), self) self._setDaemon()
[ "def", "registerHandler", "(", "self", ",", "matcher", ",", "handler", ")", ":", "self", ".", "handlers", "[", "matcher", "]", "=", "handler", "self", ".", "scheduler", ".", "register", "(", "(", "matcher", ",", ")", ",", "self", ")", "self", ".", "_...
Register self to scheduler
[ "Register", "self", "to", "scheduler" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L48-L54
train
hubo1016/vlcp
vlcp/event/runnable.py
EventHandler.registerAllHandlers
def registerAllHandlers(self, handlerDict): ''' Register self to scheduler ''' self.handlers.update(handlerDict) if hasattr(handlerDict, 'keys'): self.scheduler.register(handlerDict.keys(), self) else: self.scheduler.register(tuple(h[0] for h in ha...
python
def registerAllHandlers(self, handlerDict): ''' Register self to scheduler ''' self.handlers.update(handlerDict) if hasattr(handlerDict, 'keys'): self.scheduler.register(handlerDict.keys(), self) else: self.scheduler.register(tuple(h[0] for h in ha...
[ "def", "registerAllHandlers", "(", "self", ",", "handlerDict", ")", ":", "self", ".", "handlers", ".", "update", "(", "handlerDict", ")", "if", "hasattr", "(", "handlerDict", ",", "'keys'", ")", ":", "self", ".", "scheduler", ".", "register", "(", "handler...
Register self to scheduler
[ "Register", "self", "to", "scheduler" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L61-L70
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.start
def start(self, asyncStart = False): """ Start `container.main` as the main routine. :param asyncStart: if True, start the routine in background. By default, the routine starts in foreground, which means it is executed to the first `...
python
def start(self, asyncStart = False): """ Start `container.main` as the main routine. :param asyncStart: if True, start the routine in background. By default, the routine starts in foreground, which means it is executed to the first `...
[ "def", "start", "(", "self", ",", "asyncStart", "=", "False", ")", ":", "r", "=", "Routine", "(", "self", ".", "main", "(", ")", ",", "self", ".", "scheduler", ",", "asyncStart", ",", "self", ",", "True", ",", "self", ".", "daemon", ")", "self", ...
Start `container.main` as the main routine. :param asyncStart: if True, start the routine in background. By default, the routine starts in foreground, which means it is executed to the first `yield` statement before returning. If the started routine...
[ "Start", "container", ".", "main", "as", "the", "main", "routine", ".", ":", "param", "asyncStart", ":", "if", "True", "start", "the", "routine", "in", "background", ".", "By", "default", "the", "routine", "starts", "in", "foreground", "which", "means", "i...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L351-L366
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.subroutine
def subroutine(self, iterator, asyncStart = True, name = None, daemon = False): """ Start extra routines in this container. :param iterator: A coroutine object i.e the return value of an async method `my_routine()` :param asyncStart: if False, start the routine in foreg...
python
def subroutine(self, iterator, asyncStart = True, name = None, daemon = False): """ Start extra routines in this container. :param iterator: A coroutine object i.e the return value of an async method `my_routine()` :param asyncStart: if False, start the routine in foreg...
[ "def", "subroutine", "(", "self", ",", "iterator", ",", "asyncStart", "=", "True", ",", "name", "=", "None", ",", "daemon", "=", "False", ")", ":", "r", "=", "Routine", "(", "iterator", ",", "self", ".", "scheduler", ",", "asyncStart", ",", "self", "...
Start extra routines in this container. :param iterator: A coroutine object i.e the return value of an async method `my_routine()` :param asyncStart: if False, start the routine in foreground. By default, the routine starts in background, which means it is no...
[ "Start", "extra", "routines", "in", "this", "container", ".", ":", "param", "iterator", ":", "A", "coroutine", "object", "i", ".", "e", "the", "return", "value", "of", "an", "async", "method", "my_routine", "()", ":", "param", "asyncStart", ":", "if", "F...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L367-L394
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.wait_for_send
async def wait_for_send(self, event, *, until=None): ''' Send an event to the main event queue. Can call without delegate. :param until: if the callback returns True, stop sending and return :return: the last True value the callback returns, or None ''' ...
python
async def wait_for_send(self, event, *, until=None): ''' Send an event to the main event queue. Can call without delegate. :param until: if the callback returns True, stop sending and return :return: the last True value the callback returns, or None ''' ...
[ "async", "def", "wait_for_send", "(", "self", ",", "event", ",", "*", ",", "until", "=", "None", ")", ":", "while", "True", ":", "if", "until", ":", "r", "=", "until", "(", ")", "if", "r", ":", "return", "r", "waiter", "=", "self", ".", "schedule...
Send an event to the main event queue. Can call without delegate. :param until: if the callback returns True, stop sending and return :return: the last True value the callback returns, or None
[ "Send", "an", "event", "to", "the", "main", "event", "queue", ".", "Can", "call", "without", "delegate", ".", ":", "param", "until", ":", "if", "the", "callback", "returns", "True", "stop", "sending", "and", "return", ":", "return", ":", "the", "last", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L411-L427
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.wait_with_timeout
async def wait_with_timeout(self, timeout, *matchers): """ Wait for multiple event matchers, or until timeout. :param timeout: a timeout value :param \*matchers: event matchers :return: (is_timeout, event, matcher). When is_timeout = True, event = match...
python
async def wait_with_timeout(self, timeout, *matchers): """ Wait for multiple event matchers, or until timeout. :param timeout: a timeout value :param \*matchers: event matchers :return: (is_timeout, event, matcher). When is_timeout = True, event = match...
[ "async", "def", "wait_with_timeout", "(", "self", ",", "timeout", ",", "*", "matchers", ")", ":", "if", "timeout", "is", "None", ":", "ev", ",", "m", "=", "await", "M_", "(", "*", "matchers", ")", "return", "False", ",", "ev", ",", "m", "else", ":"...
Wait for multiple event matchers, or until timeout. :param timeout: a timeout value :param \*matchers: event matchers :return: (is_timeout, event, matcher). When is_timeout = True, event = matcher = None.
[ "Wait", "for", "multiple", "event", "matchers", "or", "until", "timeout", ".", ":", "param", "timeout", ":", "a", "timeout", "value", ":", "param", "\\", "*", "matchers", ":", "event", "matchers", ":", "return", ":", "(", "is_timeout", "event", "matcher", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L430-L453
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.execute_with_timeout
async def execute_with_timeout(self, timeout, subprocess): """ Execute a subprocess with timeout. If time limit exceeds, the subprocess is terminated, and `is_timeout` is set to True; otherwise the `is_timeout` is set to False. You can uses `execute_with_timeout` with other help...
python
async def execute_with_timeout(self, timeout, subprocess): """ Execute a subprocess with timeout. If time limit exceeds, the subprocess is terminated, and `is_timeout` is set to True; otherwise the `is_timeout` is set to False. You can uses `execute_with_timeout` with other help...
[ "async", "def", "execute_with_timeout", "(", "self", ",", "timeout", ",", "subprocess", ")", ":", "if", "timeout", "is", "None", ":", "return", "(", "False", ",", "await", "subprocess", ")", "else", ":", "th", "=", "self", ".", "scheduler", ".", "setTime...
Execute a subprocess with timeout. If time limit exceeds, the subprocess is terminated, and `is_timeout` is set to True; otherwise the `is_timeout` is set to False. You can uses `execute_with_timeout` with other help functions to create time limit for them:: timeout, result...
[ "Execute", "a", "subprocess", "with", "timeout", ".", "If", "time", "limit", "exceeds", "the", "subprocess", "is", "terminated", "and", "is_timeout", "is", "set", "to", "True", ";", "otherwise", "the", "is_timeout", "is", "set", "to", "False", ".", "You", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L457-L484
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.with_exception
async def with_exception(self, subprocess, *matchers): """ Monitoring event matchers while executing a subprocess. If events are matched before the subprocess ends, the subprocess is terminated and a RoutineException is raised. """ def _callback(event, matcher): raise...
python
async def with_exception(self, subprocess, *matchers): """ Monitoring event matchers while executing a subprocess. If events are matched before the subprocess ends, the subprocess is terminated and a RoutineException is raised. """ def _callback(event, matcher): raise...
[ "async", "def", "with_exception", "(", "self", ",", "subprocess", ",", "*", "matchers", ")", ":", "def", "_callback", "(", "event", ",", "matcher", ")", ":", "raise", "RoutineException", "(", "matcher", ",", "event", ")", "return", "await", "self", ".", ...
Monitoring event matchers while executing a subprocess. If events are matched before the subprocess ends, the subprocess is terminated and a RoutineException is raised.
[ "Monitoring", "event", "matchers", "while", "executing", "a", "subprocess", ".", "If", "events", "are", "matched", "before", "the", "subprocess", "ends", "the", "subprocess", "is", "terminated", "and", "a", "RoutineException", "is", "raised", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L498-L505
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.with_callback
def with_callback(self, subprocess, callback, *matchers, intercept_callback = None): """ Monitoring event matchers while executing a subprocess. `callback(event, matcher)` is called each time an event is matched by any event matchers. If the callback raises an exception, the subprocess is termin...
python
def with_callback(self, subprocess, callback, *matchers, intercept_callback = None): """ Monitoring event matchers while executing a subprocess. `callback(event, matcher)` is called each time an event is matched by any event matchers. If the callback raises an exception, the subprocess is termin...
[ "def", "with_callback", "(", "self", ",", "subprocess", ",", "callback", ",", "*", "matchers", ",", "intercept_callback", "=", "None", ")", ":", "it_", "=", "_await", "(", "subprocess", ")", "if", "not", "matchers", "and", "not", "intercept_callback", ":", ...
Monitoring event matchers while executing a subprocess. `callback(event, matcher)` is called each time an event is matched by any event matchers. If the callback raises an exception, the subprocess is terminated. :param intercept_callback: a callback called before a event is delegated to the in...
[ "Monitoring", "event", "matchers", "while", "executing", "a", "subprocess", ".", "callback", "(", "event", "matcher", ")", "is", "called", "each", "time", "an", "event", "is", "matched", "by", "any", "event", "matchers", ".", "If", "the", "callback", "raises...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L510-L568
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.wait_for_all
async def wait_for_all(self, *matchers, eventlist = None, eventdict = None, callback = None): """ Wait until each matcher matches an event. When this coroutine method returns, `eventlist` is set to the list of events in the arriving order (may not be the same as the matchers); `eventdict...
python
async def wait_for_all(self, *matchers, eventlist = None, eventdict = None, callback = None): """ Wait until each matcher matches an event. When this coroutine method returns, `eventlist` is set to the list of events in the arriving order (may not be the same as the matchers); `eventdict...
[ "async", "def", "wait_for_all", "(", "self", ",", "*", "matchers", ",", "eventlist", "=", "None", ",", "eventdict", "=", "None", ",", "callback", "=", "None", ")", ":", "if", "eventdict", "is", "None", ":", "eventdict", "=", "{", "}", "if", "eventlist"...
Wait until each matcher matches an event. When this coroutine method returns, `eventlist` is set to the list of events in the arriving order (may not be the same as the matchers); `eventdict` is set to a dictionary `{matcher1: event1, matcher2: event2, ...}` :param eventlist: us...
[ "Wait", "until", "each", "matcher", "matches", "an", "event", ".", "When", "this", "coroutine", "method", "returns", "eventlist", "is", "set", "to", "the", "list", "of", "events", "in", "the", "arriving", "order", "(", "may", "not", "be", "the", "same", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L585-L617
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.wait_for_all_to_process
async def wait_for_all_to_process(self, *matchers, eventlist = None, eventdict = None, callback = None): """ Similar to `waitForAll`, but set `canignore=True` for these events. This ensures blocking events are processed correctly. """ d...
python
async def wait_for_all_to_process(self, *matchers, eventlist = None, eventdict = None, callback = None): """ Similar to `waitForAll`, but set `canignore=True` for these events. This ensures blocking events are processed correctly. """ d...
[ "async", "def", "wait_for_all_to_process", "(", "self", ",", "*", "matchers", ",", "eventlist", "=", "None", ",", "eventdict", "=", "None", ",", "callback", "=", "None", ")", ":", "def", "_callback", "(", "event", ",", "matcher", ")", ":", "event", ".", ...
Similar to `waitForAll`, but set `canignore=True` for these events. This ensures blocking events are processed correctly.
[ "Similar", "to", "waitForAll", "but", "set", "canignore", "=", "True", "for", "these", "events", ".", "This", "ensures", "blocking", "events", "are", "processed", "correctly", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L621-L632
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.wait_for_all_empty
async def wait_for_all_empty(self, *queues): """ Wait for multiple queues to be empty at the same time. Require delegate when calling from coroutines running in other containers """ matchers = [m for m in (q.waitForEmpty() for q in queues) if m is not None] while matcher...
python
async def wait_for_all_empty(self, *queues): """ Wait for multiple queues to be empty at the same time. Require delegate when calling from coroutines running in other containers """ matchers = [m for m in (q.waitForEmpty() for q in queues) if m is not None] while matcher...
[ "async", "def", "wait_for_all_empty", "(", "self", ",", "*", "queues", ")", ":", "matchers", "=", "[", "m", "for", "m", "in", "(", "q", ".", "waitForEmpty", "(", ")", "for", "q", "in", "queues", ")", "if", "m", "is", "not", "None", "]", "while", ...
Wait for multiple queues to be empty at the same time. Require delegate when calling from coroutines running in other containers
[ "Wait", "for", "multiple", "queues", "to", "be", "empty", "at", "the", "same", "time", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L636-L645
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.syscall_noreturn
def syscall_noreturn(self, func): ''' Call a syscall method. A syscall method is executed outside of any routines, directly in the scheduler loop, which gives it chances to directly operate the event loop. See :py:method::`vlcp.event.core.Scheduler.syscall`. ''' matcher =...
python
def syscall_noreturn(self, func): ''' Call a syscall method. A syscall method is executed outside of any routines, directly in the scheduler loop, which gives it chances to directly operate the event loop. See :py:method::`vlcp.event.core.Scheduler.syscall`. ''' matcher =...
[ "def", "syscall_noreturn", "(", "self", ",", "func", ")", ":", "matcher", "=", "self", ".", "scheduler", ".", "syscall", "(", "func", ")", "while", "not", "matcher", ":", "yield", "matcher", "=", "self", ".", "scheduler", ".", "syscall", "(", "func", "...
Call a syscall method. A syscall method is executed outside of any routines, directly in the scheduler loop, which gives it chances to directly operate the event loop. See :py:method::`vlcp.event.core.Scheduler.syscall`.
[ "Call", "a", "syscall", "method", ".", "A", "syscall", "method", "is", "executed", "outside", "of", "any", "routines", "directly", "in", "the", "scheduler", "loop", "which", "gives", "it", "chances", "to", "directly", "operate", "the", "event", "loop", ".", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L650-L661
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.syscall
async def syscall(self, func, ignoreException = False): """ Call a syscall method and retrieve its return value """ ev = await self.syscall_noreturn(func) if hasattr(ev, 'exception'): if ignoreException: return else: raise e...
python
async def syscall(self, func, ignoreException = False): """ Call a syscall method and retrieve its return value """ ev = await self.syscall_noreturn(func) if hasattr(ev, 'exception'): if ignoreException: return else: raise e...
[ "async", "def", "syscall", "(", "self", ",", "func", ",", "ignoreException", "=", "False", ")", ":", "ev", "=", "await", "self", ".", "syscall_noreturn", "(", "func", ")", "if", "hasattr", "(", "ev", ",", "'exception'", ")", ":", "if", "ignoreException",...
Call a syscall method and retrieve its return value
[ "Call", "a", "syscall", "method", "and", "retrieve", "its", "return", "value" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L663-L674
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.delegate
async def delegate(self, subprocess, forceclose = False): ''' Run a subprocess without container support Many subprocess assume itself running in a specified container, it uses container reference like self.events. Calling the subprocess in other containers will fail. ...
python
async def delegate(self, subprocess, forceclose = False): ''' Run a subprocess without container support Many subprocess assume itself running in a specified container, it uses container reference like self.events. Calling the subprocess in other containers will fail. ...
[ "async", "def", "delegate", "(", "self", ",", "subprocess", ",", "forceclose", "=", "False", ")", ":", "finish", ",", "r", "=", "self", ".", "begin_delegate", "(", "subprocess", ")", "return", "await", "self", ".", "end_delegate", "(", "finish", ",", "r"...
Run a subprocess without container support Many subprocess assume itself running in a specified container, it uses container reference like self.events. Calling the subprocess in other containers will fail. With delegate, you can call a subprocess in any container (or without a...
[ "Run", "a", "subprocess", "without", "container", "support", "Many", "subprocess", "assume", "itself", "running", "in", "a", "specified", "container", "it", "uses", "container", "reference", "like", "self", ".", "events", ".", "Calling", "the", "subprocess", "in...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L676-L690
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.end_delegate
async def end_delegate(self, delegate_matcher, routine = None, forceclose = False): """ Retrieve a begin_delegate result. Must be called immediately after begin_delegate before any other `await`, or the result might be lost. Do not use this method without thinking. Always use `R...
python
async def end_delegate(self, delegate_matcher, routine = None, forceclose = False): """ Retrieve a begin_delegate result. Must be called immediately after begin_delegate before any other `await`, or the result might be lost. Do not use this method without thinking. Always use `R...
[ "async", "def", "end_delegate", "(", "self", ",", "delegate_matcher", ",", "routine", "=", "None", ",", "forceclose", "=", "False", ")", ":", "try", ":", "ev", "=", "await", "delegate_matcher", "if", "hasattr", "(", "ev", ",", "'exception'", ")", ":", "r...
Retrieve a begin_delegate result. Must be called immediately after begin_delegate before any other `await`, or the result might be lost. Do not use this method without thinking. Always use `RoutineFuture` when possible.
[ "Retrieve", "a", "begin_delegate", "result", ".", "Must", "be", "called", "immediately", "after", "begin_delegate", "before", "any", "other", "await", "or", "the", "result", "might", "be", "lost", ".", "Do", "not", "use", "this", "method", "without", "thinking...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L692-L707
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.begin_delegate
def begin_delegate(self, subprocess): ''' Start the delegate routine, but do not wait for result, instead returns a (matcher, routine) tuple. Useful for advanced delegates (e.g. delegate multiple subprocesses in the same time). This is NOT a coroutine method. WARNING: th...
python
def begin_delegate(self, subprocess): ''' Start the delegate routine, but do not wait for result, instead returns a (matcher, routine) tuple. Useful for advanced delegates (e.g. delegate multiple subprocesses in the same time). This is NOT a coroutine method. WARNING: th...
[ "def", "begin_delegate", "(", "self", ",", "subprocess", ")", ":", "async", "def", "delegateroutine", "(", ")", ":", "try", ":", "r", "=", "await", "subprocess", "except", ":", "_", ",", "val", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "e", ...
Start the delegate routine, but do not wait for result, instead returns a (matcher, routine) tuple. Useful for advanced delegates (e.g. delegate multiple subprocesses in the same time). This is NOT a coroutine method. WARNING: this is not a safe way for asynchronous executing and get th...
[ "Start", "the", "delegate", "routine", "but", "do", "not", "wait", "for", "result", "instead", "returns", "a", "(", "matcher", "routine", ")", "tuple", ".", "Useful", "for", "advanced", "delegates", "(", "e", ".", "g", ".", "delegate", "multiple", "subproc...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L709-L736
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.begin_delegate_other
def begin_delegate_other(self, subprocess, container, retnames = ('',)): ''' DEPRECATED Start the delegate routine, but do not wait for result, instead returns a (matcher routine) tuple. Useful for advanced delegates (e.g. delegate multiple subprocesses in the same time). This is NOT a c...
python
def begin_delegate_other(self, subprocess, container, retnames = ('',)): ''' DEPRECATED Start the delegate routine, but do not wait for result, instead returns a (matcher routine) tuple. Useful for advanced delegates (e.g. delegate multiple subprocesses in the same time). This is NOT a c...
[ "def", "begin_delegate_other", "(", "self", ",", "subprocess", ",", "container", ",", "retnames", "=", "(", "''", ",", ")", ")", ":", "async", "def", "delegateroutine", "(", ")", ":", "try", ":", "r", "=", "await", "subprocess", "except", ":", "_", ","...
DEPRECATED Start the delegate routine, but do not wait for result, instead returns a (matcher routine) tuple. Useful for advanced delegates (e.g. delegate multiple subprocesses in the same time). This is NOT a coroutine method. :param subprocess: a coroutine :param cont...
[ "DEPRECATED", "Start", "the", "delegate", "routine", "but", "do", "not", "wait", "for", "result", "instead", "returns", "a", "(", "matcher", "routine", ")", "tuple", ".", "Useful", "for", "advanced", "delegates", "(", "e", ".", "g", ".", "delegate", "multi...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L738-L766
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.delegate_other
async def delegate_other(self, subprocess, container, retnames = ('',), forceclose = False): ''' DEPRECATED Another format of delegate allows delegate a subprocess in another container, and get some returning values the subprocess is actually running in 'container'. :: ret =...
python
async def delegate_other(self, subprocess, container, retnames = ('',), forceclose = False): ''' DEPRECATED Another format of delegate allows delegate a subprocess in another container, and get some returning values the subprocess is actually running in 'container'. :: ret =...
[ "async", "def", "delegate_other", "(", "self", ",", "subprocess", ",", "container", ",", "retnames", "=", "(", "''", ",", ")", ",", "forceclose", "=", "False", ")", ":", "finish", ",", "r", "=", "self", ".", "beginDelegateOther", "(", "subprocess", ",", ...
DEPRECATED Another format of delegate allows delegate a subprocess in another container, and get some returning values the subprocess is actually running in 'container'. :: ret = await self.delegate_other(c.method(), c) :return: a tuple for retnames values
[ "DEPRECATED", "Another", "format", "of", "delegate", "allows", "delegate", "a", "subprocess", "in", "another", "container", "and", "get", "some", "returning", "values", "the", "subprocess", "is", "actually", "running", "in", "container", ".", "::", "ret", "=", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L770-L781
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.execute_all_with_names
async def execute_all_with_names(self, subprocesses, container = None, retnames = ('',), forceclose = True): ''' DEPRECATED Execute all subprocesses and get the return values. :param subprocesses: sequence of subroutines (coroutines) :param container: if specified, run ...
python
async def execute_all_with_names(self, subprocesses, container = None, retnames = ('',), forceclose = True): ''' DEPRECATED Execute all subprocesses and get the return values. :param subprocesses: sequence of subroutines (coroutines) :param container: if specified, run ...
[ "async", "def", "execute_all_with_names", "(", "self", ",", "subprocesses", ",", "container", "=", "None", ",", "retnames", "=", "(", "''", ",", ")", ",", "forceclose", "=", "True", ")", ":", "if", "not", "subprocesses", ":", "return", "[", "]", "subproc...
DEPRECATED Execute all subprocesses and get the return values. :param subprocesses: sequence of subroutines (coroutines) :param container: if specified, run subprocesses in another container. :param retnames: DEPRECATED get return value from container.(name) for each n...
[ "DEPRECATED", "Execute", "all", "subprocesses", "and", "get", "the", "return", "values", ".", ":", "param", "subprocesses", ":", "sequence", "of", "subroutines", "(", "coroutines", ")", ":", "param", "container", ":", "if", "specified", "run", "subprocesses", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L785-L828
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.execute_all
async def execute_all(self, subprocesses, forceclose=True): ''' Execute all subprocesses and get the return values. :param subprocesses: sequence of subroutines (coroutines) :param forceclose: force close the routines on exit, so all the subprocesses are terminated ...
python
async def execute_all(self, subprocesses, forceclose=True): ''' Execute all subprocesses and get the return values. :param subprocesses: sequence of subroutines (coroutines) :param forceclose: force close the routines on exit, so all the subprocesses are terminated ...
[ "async", "def", "execute_all", "(", "self", ",", "subprocesses", ",", "forceclose", "=", "True", ")", ":", "if", "not", "subprocesses", ":", "return", "[", "]", "subprocesses", "=", "list", "(", "subprocesses", ")", "if", "len", "(", "subprocesses", ")", ...
Execute all subprocesses and get the return values. :param subprocesses: sequence of subroutines (coroutines) :param forceclose: force close the routines on exit, so all the subprocesses are terminated on timeout if used with executeWithTimeout ...
[ "Execute", "all", "subprocesses", "and", "get", "the", "return", "values", ".", ":", "param", "subprocesses", ":", "sequence", "of", "subroutines", "(", "coroutines", ")", ":", "param", "forceclose", ":", "force", "close", "the", "routines", "on", "exit", "s...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L832-L866
train
hubo1016/vlcp
vlcp/event/runnable.py
RoutineContainer.get_container
def get_container(cls, scheduler): """ Create temporary instance for helper functions """ if scheduler in cls._container_cache: return cls._container_cache[scheduler] else: c = cls(scheduler) cls._container_cache[scheduler] = c retu...
python
def get_container(cls, scheduler): """ Create temporary instance for helper functions """ if scheduler in cls._container_cache: return cls._container_cache[scheduler] else: c = cls(scheduler) cls._container_cache[scheduler] = c retu...
[ "def", "get_container", "(", "cls", ",", "scheduler", ")", ":", "if", "scheduler", "in", "cls", ".", "_container_cache", ":", "return", "cls", ".", "_container_cache", "[", "scheduler", "]", "else", ":", "c", "=", "cls", "(", "scheduler", ")", "cls", "."...
Create temporary instance for helper functions
[ "Create", "temporary", "instance", "for", "helper", "functions" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/runnable.py#L869-L878
train
hubo1016/vlcp
vlcp/server/module.py
depend
def depend(*args): """ Decorator to declare dependencies to other modules. Recommended usage is:: import other_module @depend(other_module.ModuleClass) class MyModule(Module): ... :param \*args: depended module classes. """ def decfunc(cls): ...
python
def depend(*args): """ Decorator to declare dependencies to other modules. Recommended usage is:: import other_module @depend(other_module.ModuleClass) class MyModule(Module): ... :param \*args: depended module classes. """ def decfunc(cls): ...
[ "def", "depend", "(", "*", "args", ")", ":", "def", "decfunc", "(", "cls", ")", ":", "if", "not", "'depends'", "in", "cls", ".", "__dict__", ":", "cls", ".", "depends", "=", "[", "]", "cls", ".", "depends", ".", "extend", "(", "list", "(", "args"...
Decorator to declare dependencies to other modules. Recommended usage is:: import other_module @depend(other_module.ModuleClass) class MyModule(Module): ... :param \*args: depended module classes.
[ "Decorator", "to", "declare", "dependencies", "to", "other", "modules", ".", "Recommended", "usage", "is", "::", "import", "other_module" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L23-L44
train
hubo1016/vlcp
vlcp/server/module.py
api
def api(func, container = None, criteria = None): ''' Return an API def for a generic function :param func: a function or bounded method :param container: if None, this is used as a synchronous method, the return value of the method is used for the return value. If not No...
python
def api(func, container = None, criteria = None): ''' Return an API def for a generic function :param func: a function or bounded method :param container: if None, this is used as a synchronous method, the return value of the method is used for the return value. If not No...
[ "def", "api", "(", "func", ",", "container", "=", "None", ",", "criteria", "=", "None", ")", ":", "return", "(", "func", ".", "__name__", ".", "lower", "(", ")", ",", "functools", ".", "update_wrapper", "(", "lambda", "n", ",", "p", ":", "func", "(...
Return an API def for a generic function :param func: a function or bounded method :param container: if None, this is used as a synchronous method, the return value of the method is used for the return value. If not None, this is used as an asynchronous method, ...
[ "Return", "an", "API", "def", "for", "a", "generic", "function", ":", "param", "func", ":", "a", "function", "or", "bounded", "method", ":", "param", "container", ":", "if", "None", "this", "is", "used", "as", "a", "synchronous", "method", "the", "return...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L112-L127
train
hubo1016/vlcp
vlcp/server/module.py
proxy
def proxy(name, default = None): """ Create a proxy module. A proxy module has a default implementation, but can be redirected to other implementations with configurations. Other modules can depend on proxy modules. """ proxymodule = _ProxyMetaClass(name, (_ProxyModule,), {'_default': default}) ...
python
def proxy(name, default = None): """ Create a proxy module. A proxy module has a default implementation, but can be redirected to other implementations with configurations. Other modules can depend on proxy modules. """ proxymodule = _ProxyMetaClass(name, (_ProxyModule,), {'_default': default}) ...
[ "def", "proxy", "(", "name", ",", "default", "=", "None", ")", ":", "proxymodule", "=", "_ProxyMetaClass", "(", "name", ",", "(", "_ProxyModule", ",", ")", ",", "{", "'_default'", ":", "default", "}", ")", "proxymodule", ".", "__module__", "=", "sys", ...
Create a proxy module. A proxy module has a default implementation, but can be redirected to other implementations with configurations. Other modules can depend on proxy modules.
[ "Create", "a", "proxy", "module", ".", "A", "proxy", "module", "has", "a", "default", "implementation", "but", "can", "be", "redirected", "to", "other", "implementations", "with", "configurations", ".", "Other", "modules", "can", "depend", "on", "proxy", "modu...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L462-L469
train
hubo1016/vlcp
vlcp/server/module.py
send_api
async def send_api(container, targetname, name, params = {}): """ Send API and discard the result """ handle = object() apiEvent = ModuleAPICall(handle, targetname, name, params = params) await container.wait_for_send(apiEvent)
python
async def send_api(container, targetname, name, params = {}): """ Send API and discard the result """ handle = object() apiEvent = ModuleAPICall(handle, targetname, name, params = params) await container.wait_for_send(apiEvent)
[ "async", "def", "send_api", "(", "container", ",", "targetname", ",", "name", ",", "params", "=", "{", "}", ")", ":", "handle", "=", "object", "(", ")", "apiEvent", "=", "ModuleAPICall", "(", "handle", ",", "targetname", ",", "name", ",", "params", "="...
Send API and discard the result
[ "Send", "API", "and", "discard", "the", "result" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L742-L748
train
hubo1016/vlcp
vlcp/server/module.py
call_api
async def call_api(container, targetname, name, params = {}, timeout = 120.0): """ Call module API `targetname/name` with parameters. :param targetname: module targetname. Usually the lower-cased name of the module class, or 'public' for public APIs. :param name: method ...
python
async def call_api(container, targetname, name, params = {}, timeout = 120.0): """ Call module API `targetname/name` with parameters. :param targetname: module targetname. Usually the lower-cased name of the module class, or 'public' for public APIs. :param name: method ...
[ "async", "def", "call_api", "(", "container", ",", "targetname", ",", "name", ",", "params", "=", "{", "}", ",", "timeout", "=", "120.0", ")", ":", "handle", "=", "object", "(", ")", "apiEvent", "=", "ModuleAPICall", "(", "handle", ",", "targetname", "...
Call module API `targetname/name` with parameters. :param targetname: module targetname. Usually the lower-cased name of the module class, or 'public' for public APIs. :param name: method name :param params: module API parameters, should be a dictionary of `{parameter: ...
[ "Call", "module", "API", "targetname", "/", "name", "with", "parameters", ".", ":", "param", "targetname", ":", "module", "targetname", ".", "Usually", "the", "lower", "-", "cased", "name", "of", "the", "module", "class", "or", "public", "for", "public", "...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L751-L777
train
hubo1016/vlcp
vlcp/server/module.py
batch_call_api
async def batch_call_api(container, apis, timeout = 120.0): """ DEPRECATED - use execute_all instead """ apiHandles = [(object(), api) for api in apis] apiEvents = [ModuleAPICall(handle, targetname, name, params = params) for handle, (targetname, name, params) in apiHandles] api...
python
async def batch_call_api(container, apis, timeout = 120.0): """ DEPRECATED - use execute_all instead """ apiHandles = [(object(), api) for api in apis] apiEvents = [ModuleAPICall(handle, targetname, name, params = params) for handle, (targetname, name, params) in apiHandles] api...
[ "async", "def", "batch_call_api", "(", "container", ",", "apis", ",", "timeout", "=", "120.0", ")", ":", "apiHandles", "=", "[", "(", "object", "(", ")", ",", "api", ")", "for", "api", "in", "apis", "]", "apiEvents", "=", "[", "ModuleAPICall", "(", "...
DEPRECATED - use execute_all instead
[ "DEPRECATED", "-", "use", "execute_all", "instead" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L781-L806
train
hubo1016/vlcp
vlcp/server/module.py
ModuleAPIHandler.registerAPIs
def registerAPIs(self, apidefs): ''' API definition is in format: `(name, handler, container, discoverinfo)` if the handler is a generator, container should be specified handler should accept two arguments:: def handler(name, params): ... ...
python
def registerAPIs(self, apidefs): ''' API definition is in format: `(name, handler, container, discoverinfo)` if the handler is a generator, container should be specified handler should accept two arguments:: def handler(name, params): ... ...
[ "def", "registerAPIs", "(", "self", ",", "apidefs", ")", ":", "handlers", "=", "[", "self", ".", "_createHandler", "(", "*", "apidef", ")", "for", "apidef", "in", "apidefs", "]", "self", ".", "handler", ".", "registerAllHandlers", "(", "handlers", ")", "...
API definition is in format: `(name, handler, container, discoverinfo)` if the handler is a generator, container should be specified handler should accept two arguments:: def handler(name, params): ... `name` is the method name, `params` is ...
[ "API", "definition", "is", "in", "format", ":", "(", "name", "handler", "container", "discoverinfo", ")", "if", "the", "handler", "is", "a", "generator", "container", "should", "be", "specified", "handler", "should", "accept", "two", "arguments", "::", "def", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L196-L219
train
hubo1016/vlcp
vlcp/server/module.py
ModuleAPIHandler.registerAPI
def registerAPI(self, name, handler, container = None, discoverinfo = None, criteria = None): """ Append new API to this handler """ self.handler.registerHandler(*self._createHandler(name, handler, container, criteria)) if discoverinfo is None: self.discoverinfo[name]...
python
def registerAPI(self, name, handler, container = None, discoverinfo = None, criteria = None): """ Append new API to this handler """ self.handler.registerHandler(*self._createHandler(name, handler, container, criteria)) if discoverinfo is None: self.discoverinfo[name]...
[ "def", "registerAPI", "(", "self", ",", "name", ",", "handler", ",", "container", "=", "None", ",", "discoverinfo", "=", "None", ",", "criteria", "=", "None", ")", ":", "self", ".", "handler", ".", "registerHandler", "(", "*", "self", ".", "_createHandle...
Append new API to this handler
[ "Append", "new", "API", "to", "this", "handler" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L220-L228
train
hubo1016/vlcp
vlcp/server/module.py
ModuleAPIHandler.unregisterAPI
def unregisterAPI(self, name): """ Remove an API from this handler """ if name.startswith('public/'): target = 'public' name = name[len('public/'):] else: target = self.servicename name = name removes = [m for m in self.hand...
python
def unregisterAPI(self, name): """ Remove an API from this handler """ if name.startswith('public/'): target = 'public' name = name[len('public/'):] else: target = self.servicename name = name removes = [m for m in self.hand...
[ "def", "unregisterAPI", "(", "self", ",", "name", ")", ":", "if", "name", ".", "startswith", "(", "'public/'", ")", ":", "target", "=", "'public'", "name", "=", "name", "[", "len", "(", "'public/'", ")", ":", "]", "else", ":", "target", "=", "self", ...
Remove an API from this handler
[ "Remove", "an", "API", "from", "this", "handler" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L229-L241
train
hubo1016/vlcp
vlcp/server/module.py
ModuleAPIHandler.discover
def discover(self, details = False): 'Discover API definitions. Set details=true to show details' if details and not (isinstance(details, str) and details.lower() == 'false'): return copy.deepcopy(self.discoverinfo) else: return dict((k,v.get('description', '')) for k,v i...
python
def discover(self, details = False): 'Discover API definitions. Set details=true to show details' if details and not (isinstance(details, str) and details.lower() == 'false'): return copy.deepcopy(self.discoverinfo) else: return dict((k,v.get('description', '')) for k,v i...
[ "def", "discover", "(", "self", ",", "details", "=", "False", ")", ":", "if", "details", "and", "not", "(", "isinstance", "(", "details", ",", "str", ")", "and", "details", ".", "lower", "(", ")", "==", "'false'", ")", ":", "return", "copy", ".", "...
Discover API definitions. Set details=true to show details
[ "Discover", "API", "definitions", ".", "Set", "details", "=", "true", "to", "show", "details" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L242-L247
train
hubo1016/vlcp
vlcp/server/module.py
ModuleLoader.loadmodule
async def loadmodule(self, module): ''' Load a module class ''' self._logger.debug('Try to load module %r', module) if hasattr(module, '_instance'): self._logger.debug('Module is already initialized, module state is: %r', module._instance.state) if module....
python
async def loadmodule(self, module): ''' Load a module class ''' self._logger.debug('Try to load module %r', module) if hasattr(module, '_instance'): self._logger.debug('Module is already initialized, module state is: %r', module._instance.state) if module....
[ "async", "def", "loadmodule", "(", "self", ",", "module", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'Try to load module %r'", ",", "module", ")", "if", "hasattr", "(", "module", ",", "'_instance'", ")", ":", "self", ".", "_logger", ".", "debu...
Load a module class
[ "Load", "a", "module", "class" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L502-L577
train
hubo1016/vlcp
vlcp/server/module.py
ModuleLoader.unloadmodule
async def unloadmodule(self, module, ignoreDependencies = False): ''' Unload a module class ''' self._logger.debug('Try to unload module %r', module) if hasattr(module, '_instance'): self._logger.debug('Module %r is loaded, module state is %r', module, module._instanc...
python
async def unloadmodule(self, module, ignoreDependencies = False): ''' Unload a module class ''' self._logger.debug('Try to unload module %r', module) if hasattr(module, '_instance'): self._logger.debug('Module %r is loaded, module state is %r', module, module._instanc...
[ "async", "def", "unloadmodule", "(", "self", ",", "module", ",", "ignoreDependencies", "=", "False", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'Try to unload module %r'", ",", "module", ")", "if", "hasattr", "(", "module", ",", "'_instance'", ")"...
Unload a module class
[ "Unload", "a", "module", "class" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L578-L613
train
hubo1016/vlcp
vlcp/server/module.py
ModuleLoader.load_by_path
async def load_by_path(self, path): """ Load a module by full path. If there are dependencies, they are also loaded. """ try: p, module = findModule(path, True) except KeyError as exc: raise ModuleLoadException('Cannot load module ' + repr(path) + ': ' + s...
python
async def load_by_path(self, path): """ Load a module by full path. If there are dependencies, they are also loaded. """ try: p, module = findModule(path, True) except KeyError as exc: raise ModuleLoadException('Cannot load module ' + repr(path) + ': ' + s...
[ "async", "def", "load_by_path", "(", "self", ",", "path", ")", ":", "try", ":", "p", ",", "module", "=", "findModule", "(", "path", ",", "True", ")", "except", "KeyError", "as", "exc", ":", "raise", "ModuleLoadException", "(", "'Cannot load module '", "+",...
Load a module by full path. If there are dependencies, they are also loaded.
[ "Load", "a", "module", "by", "full", "path", ".", "If", "there", "are", "dependencies", "they", "are", "also", "loaded", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L614-L626
train
hubo1016/vlcp
vlcp/server/module.py
ModuleLoader.unload_by_path
async def unload_by_path(self, path): """ Unload a module by full path. Dependencies are automatically unloaded if they are marked to be services. """ p, module = findModule(path, False) if module is None: raise ModuleLoadException('Cannot find module: ' + rep...
python
async def unload_by_path(self, path): """ Unload a module by full path. Dependencies are automatically unloaded if they are marked to be services. """ p, module = findModule(path, False) if module is None: raise ModuleLoadException('Cannot find module: ' + rep...
[ "async", "def", "unload_by_path", "(", "self", ",", "path", ")", ":", "p", ",", "module", "=", "findModule", "(", "path", ",", "False", ")", "if", "module", "is", "None", ":", "raise", "ModuleLoadException", "(", "'Cannot find module: '", "+", "repr", "(",...
Unload a module by full path. Dependencies are automatically unloaded if they are marked to be services.
[ "Unload", "a", "module", "by", "full", "path", ".", "Dependencies", "are", "automatically", "unloaded", "if", "they", "are", "marked", "to", "be", "services", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L630-L638
train
hubo1016/vlcp
vlcp/server/module.py
ModuleLoader.reload_modules
async def reload_modules(self, pathlist): """ Reload modules with a full path in the pathlist """ loadedModules = [] failures = [] for path in pathlist: p, module = findModule(path, False) if module is not None and hasattr(module, '_instance') and ...
python
async def reload_modules(self, pathlist): """ Reload modules with a full path in the pathlist """ loadedModules = [] failures = [] for path in pathlist: p, module = findModule(path, False) if module is not None and hasattr(module, '_instance') and ...
[ "async", "def", "reload_modules", "(", "self", ",", "pathlist", ")", ":", "loadedModules", "=", "[", "]", "failures", "=", "[", "]", "for", "path", "in", "pathlist", ":", "p", ",", "module", "=", "findModule", "(", "path", ",", "False", ")", "if", "m...
Reload modules with a full path in the pathlist
[ "Reload", "modules", "with", "a", "full", "path", "in", "the", "pathlist" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L642-L723
train
hubo1016/vlcp
vlcp/server/module.py
ModuleLoader.get_module_by_name
def get_module_by_name(self, targetname): """ Return the module instance for a target name. """ if targetname == 'public': target = None elif not targetname not in self.activeModules: raise KeyError('Module %r not exists or is not loaded' % (targetname,)) ...
python
def get_module_by_name(self, targetname): """ Return the module instance for a target name. """ if targetname == 'public': target = None elif not targetname not in self.activeModules: raise KeyError('Module %r not exists or is not loaded' % (targetname,)) ...
[ "def", "get_module_by_name", "(", "self", ",", "targetname", ")", ":", "if", "targetname", "==", "'public'", ":", "target", "=", "None", "elif", "not", "targetname", "not", "in", "self", ".", "activeModules", ":", "raise", "KeyError", "(", "'Module %r not exis...
Return the module instance for a target name.
[ "Return", "the", "module", "instance", "for", "a", "target", "name", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/server/module.py#L727-L737
train
hubo1016/vlcp
vlcp/config/config.py
configbase
def configbase(key): """ Decorator to set this class to configuration base class. A configuration base class uses `<parentbase>.key.` for its configuration base, and uses `<parentbase>.key.default` for configuration mapping. """ def decorator(cls): parent = cls.getConfigurableParent() ...
python
def configbase(key): """ Decorator to set this class to configuration base class. A configuration base class uses `<parentbase>.key.` for its configuration base, and uses `<parentbase>.key.default` for configuration mapping. """ def decorator(cls): parent = cls.getConfigurableParent() ...
[ "def", "configbase", "(", "key", ")", ":", "def", "decorator", "(", "cls", ")", ":", "parent", "=", "cls", ".", "getConfigurableParent", "(", ")", "if", "parent", "is", "None", ":", "parentbase", "=", "None", "else", ":", "parentbase", "=", "getattr", ...
Decorator to set this class to configuration base class. A configuration base class uses `<parentbase>.key.` for its configuration base, and uses `<parentbase>.key.default` for configuration mapping.
[ "Decorator", "to", "set", "this", "class", "to", "configuration", "base", "class", ".", "A", "configuration", "base", "class", "uses", "<parentbase", ">", ".", "key", ".", "for", "its", "configuration", "base", "and", "uses", "<parentbase", ">", ".", "key", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L391-L409
train
hubo1016/vlcp
vlcp/config/config.py
config
def config(key): """ Decorator to map this class directly to a configuration node. It uses `<parentbase>.key` for configuration base and configuration mapping. """ def decorator(cls): parent = cls.getConfigurableParent() if parent is None: parentbase = None else: ...
python
def config(key): """ Decorator to map this class directly to a configuration node. It uses `<parentbase>.key` for configuration base and configuration mapping. """ def decorator(cls): parent = cls.getConfigurableParent() if parent is None: parentbase = None else: ...
[ "def", "config", "(", "key", ")", ":", "def", "decorator", "(", "cls", ")", ":", "parent", "=", "cls", ".", "getConfigurableParent", "(", ")", "if", "parent", "is", "None", ":", "parentbase", "=", "None", "else", ":", "parentbase", "=", "getattr", "(",...
Decorator to map this class directly to a configuration node. It uses `<parentbase>.key` for configuration base and configuration mapping.
[ "Decorator", "to", "map", "this", "class", "directly", "to", "a", "configuration", "node", ".", "It", "uses", "<parentbase", ">", ".", "key", "for", "configuration", "base", "and", "configuration", "mapping", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L411-L427
train
hubo1016/vlcp
vlcp/config/config.py
defaultconfig
def defaultconfig(cls): """ Generate a default configuration mapping bases on the class name. If this class does not have a parent with `configbase` defined, it is set to a configuration base with `configbase=<lowercase-name>` and `configkey=<lowercase-name>.default`; otherwise it inherits `configba...
python
def defaultconfig(cls): """ Generate a default configuration mapping bases on the class name. If this class does not have a parent with `configbase` defined, it is set to a configuration base with `configbase=<lowercase-name>` and `configkey=<lowercase-name>.default`; otherwise it inherits `configba...
[ "def", "defaultconfig", "(", "cls", ")", ":", "parentbase", "=", "None", "for", "p", "in", "cls", ".", "__bases__", ":", "if", "issubclass", "(", "p", ",", "Configurable", ")", ":", "parentbase", "=", "getattr", "(", "p", ",", "'configbase'", ",", "Non...
Generate a default configuration mapping bases on the class name. If this class does not have a parent with `configbase` defined, it is set to a configuration base with `configbase=<lowercase-name>` and `configkey=<lowercase-name>.default`; otherwise it inherits `configbase` of its parent and set `configkey...
[ "Generate", "a", "default", "configuration", "mapping", "bases", "on", "the", "class", "name", ".", "If", "this", "class", "does", "not", "have", "a", "parent", "with", "configbase", "defined", "it", "is", "set", "to", "a", "configuration", "base", "with", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L429-L458
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.config_keys
def config_keys(self, sortkey = False): """ Return all configuration keys in this node, including configurations on children nodes. """ if sortkey: items = sorted(self.items()) else: items = self.items() for k,v in items: if isinstance(...
python
def config_keys(self, sortkey = False): """ Return all configuration keys in this node, including configurations on children nodes. """ if sortkey: items = sorted(self.items()) else: items = self.items() for k,v in items: if isinstance(...
[ "def", "config_keys", "(", "self", ",", "sortkey", "=", "False", ")", ":", "if", "sortkey", ":", "items", "=", "sorted", "(", "self", ".", "items", "(", ")", ")", "else", ":", "items", "=", "self", ".", "items", "(", ")", "for", "k", ",", "v", ...
Return all configuration keys in this node, including configurations on children nodes.
[ "Return", "all", "configuration", "keys", "in", "this", "node", "including", "configurations", "on", "children", "nodes", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L36-L49
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.config_items
def config_items(self, sortkey = False): """ Return all `(key, value)` tuples for configurations in this node, including configurations on children nodes. """ if sortkey: items = sorted(self.items()) else: items = self.items() for k,v in items: ...
python
def config_items(self, sortkey = False): """ Return all `(key, value)` tuples for configurations in this node, including configurations on children nodes. """ if sortkey: items = sorted(self.items()) else: items = self.items() for k,v in items: ...
[ "def", "config_items", "(", "self", ",", "sortkey", "=", "False", ")", ":", "if", "sortkey", ":", "items", "=", "sorted", "(", "self", ".", "items", "(", ")", ")", "else", ":", "items", "=", "self", ".", "items", "(", ")", "for", "k", ",", "v", ...
Return all `(key, value)` tuples for configurations in this node, including configurations on children nodes.
[ "Return", "all", "(", "key", "value", ")", "tuples", "for", "configurations", "in", "this", "node", "including", "configurations", "on", "children", "nodes", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L50-L63
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.config_value_keys
def config_value_keys(self, sortkey = False): """ Return configuration keys directly stored in this node. Configurations in child nodes are not included. """ if sortkey: items = sorted(self.items()) else: items = self.items() return (k for k,v in i...
python
def config_value_keys(self, sortkey = False): """ Return configuration keys directly stored in this node. Configurations in child nodes are not included. """ if sortkey: items = sorted(self.items()) else: items = self.items() return (k for k,v in i...
[ "def", "config_value_keys", "(", "self", ",", "sortkey", "=", "False", ")", ":", "if", "sortkey", ":", "items", "=", "sorted", "(", "self", ".", "items", "(", ")", ")", "else", ":", "items", "=", "self", ".", "items", "(", ")", "return", "(", "k", ...
Return configuration keys directly stored in this node. Configurations in child nodes are not included.
[ "Return", "configuration", "keys", "directly", "stored", "in", "this", "node", ".", "Configurations", "in", "child", "nodes", "are", "not", "included", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L64-L72
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.loadconfig
def loadconfig(self, keysuffix, obj): """ Copy all configurations from this node into obj """ subtree = self.get(keysuffix) if subtree is not None and isinstance(subtree, ConfigTree): for k,v in subtree.items(): if isinstance(v, ConfigTree): ...
python
def loadconfig(self, keysuffix, obj): """ Copy all configurations from this node into obj """ subtree = self.get(keysuffix) if subtree is not None and isinstance(subtree, ConfigTree): for k,v in subtree.items(): if isinstance(v, ConfigTree): ...
[ "def", "loadconfig", "(", "self", ",", "keysuffix", ",", "obj", ")", ":", "subtree", "=", "self", ".", "get", "(", "keysuffix", ")", "if", "subtree", "is", "not", "None", "and", "isinstance", "(", "subtree", ",", "ConfigTree", ")", ":", "for", "k", "...
Copy all configurations from this node into obj
[ "Copy", "all", "configurations", "from", "this", "node", "into", "obj" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L82-L95
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.withconfig
def withconfig(self, keysuffix): """ Load configurations with this decorator """ def decorator(cls): return self.loadconfig(keysuffix, cls) return decorator
python
def withconfig(self, keysuffix): """ Load configurations with this decorator """ def decorator(cls): return self.loadconfig(keysuffix, cls) return decorator
[ "def", "withconfig", "(", "self", ",", "keysuffix", ")", ":", "def", "decorator", "(", "cls", ")", ":", "return", "self", ".", "loadconfig", "(", "keysuffix", ",", "cls", ")", "return", "decorator" ]
Load configurations with this decorator
[ "Load", "configurations", "with", "this", "decorator" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L96-L102
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.gettree
def gettree(self, key, create = False): """ Get a subtree node from the key (path relative to this node) """ tree, _ = self._getsubitem(key + '.tmp', create) return tree
python
def gettree(self, key, create = False): """ Get a subtree node from the key (path relative to this node) """ tree, _ = self._getsubitem(key + '.tmp', create) return tree
[ "def", "gettree", "(", "self", ",", "key", ",", "create", "=", "False", ")", ":", "tree", ",", "_", "=", "self", ".", "_getsubitem", "(", "key", "+", "'.tmp'", ",", "create", ")", "return", "tree" ]
Get a subtree node from the key (path relative to this node)
[ "Get", "a", "subtree", "node", "from", "the", "key", "(", "path", "relative", "to", "this", "node", ")" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L108-L113
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.get
def get(self, key, defaultvalue = None): """ Support dict-like get (return a default value if not found) """ (t, k) = self._getsubitem(key, False) if t is None: return defaultvalue else: return t.__dict__.get(k, defaultvalue)
python
def get(self, key, defaultvalue = None): """ Support dict-like get (return a default value if not found) """ (t, k) = self._getsubitem(key, False) if t is None: return defaultvalue else: return t.__dict__.get(k, defaultvalue)
[ "def", "get", "(", "self", ",", "key", ",", "defaultvalue", "=", "None", ")", ":", "(", "t", ",", "k", ")", "=", "self", ".", "_getsubitem", "(", "key", ",", "False", ")", "if", "t", "is", "None", ":", "return", "defaultvalue", "else", ":", "retu...
Support dict-like get (return a default value if not found)
[ "Support", "dict", "-", "like", "get", "(", "return", "a", "default", "value", "if", "not", "found", ")" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L163-L171
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.setdefault
def setdefault(self, key, defaultvalue = None): """ Support dict-like setdefault (create if not existed) """ (t, k) = self._getsubitem(key, True) return t.__dict__.setdefault(k, defaultvalue)
python
def setdefault(self, key, defaultvalue = None): """ Support dict-like setdefault (create if not existed) """ (t, k) = self._getsubitem(key, True) return t.__dict__.setdefault(k, defaultvalue)
[ "def", "setdefault", "(", "self", ",", "key", ",", "defaultvalue", "=", "None", ")", ":", "(", "t", ",", "k", ")", "=", "self", ".", "_getsubitem", "(", "key", ",", "True", ")", "return", "t", ".", "__dict__", ".", "setdefault", "(", "k", ",", "d...
Support dict-like setdefault (create if not existed)
[ "Support", "dict", "-", "like", "setdefault", "(", "create", "if", "not", "existed", ")" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L172-L177
train
hubo1016/vlcp
vlcp/config/config.py
ConfigTree.todict
def todict(self): """ Convert this node to a dictionary tree. """ dict_entry = [] for k,v in self.items(): if isinstance(v, ConfigTree): dict_entry.append((k, v.todict())) else: dict_entry.append((k, v)) return dict(...
python
def todict(self): """ Convert this node to a dictionary tree. """ dict_entry = [] for k,v in self.items(): if isinstance(v, ConfigTree): dict_entry.append((k, v.todict())) else: dict_entry.append((k, v)) return dict(...
[ "def", "todict", "(", "self", ")", ":", "dict_entry", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "ConfigTree", ")", ":", "dict_entry", ".", "append", "(", "(", "k", ",", "v...
Convert this node to a dictionary tree.
[ "Convert", "this", "node", "to", "a", "dictionary", "tree", "." ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L192-L202
train
hubo1016/vlcp
vlcp/config/config.py
Manager.loadfromfile
def loadfromfile(self, filelike): """ Read configurations from a file-like object, or a sequence of strings. Old values are not cleared, if you want to reload the configurations completely, you should call `clear()` before using `load*` methods. """ line_format = re.compi...
python
def loadfromfile(self, filelike): """ Read configurations from a file-like object, or a sequence of strings. Old values are not cleared, if you want to reload the configurations completely, you should call `clear()` before using `load*` methods. """ line_format = re.compi...
[ "def", "loadfromfile", "(", "self", ",", "filelike", ")", ":", "line_format", "=", "re", ".", "compile", "(", "r'((?:[a-zA-Z][a-zA-Z0-9_]*\\.)*[a-zA-Z][a-zA-Z0-9_]*)\\s*=\\s*'", ")", "space", "=", "re", ".", "compile", "(", "r'\\s'", ")", "line_no", "=", "0", "#...
Read configurations from a file-like object, or a sequence of strings. Old values are not cleared, if you want to reload the configurations completely, you should call `clear()` before using `load*` methods.
[ "Read", "configurations", "from", "a", "file", "-", "like", "object", "or", "a", "sequence", "of", "strings", ".", "Old", "values", "are", "not", "cleared", "if", "you", "want", "to", "reload", "the", "configurations", "completely", "you", "should", "call", ...
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L210-L259
train
hubo1016/vlcp
vlcp/config/config.py
Manager.save
def save(self, sortkey = True): """ Save configurations to a list of strings """ return [k + '=' + repr(v) for k,v in self.config_items(sortkey)]
python
def save(self, sortkey = True): """ Save configurations to a list of strings """ return [k + '=' + repr(v) for k,v in self.config_items(sortkey)]
[ "def", "save", "(", "self", ",", "sortkey", "=", "True", ")", ":", "return", "[", "k", "+", "'='", "+", "repr", "(", "v", ")", "for", "k", ",", "v", "in", "self", ".", "config_items", "(", "sortkey", ")", "]" ]
Save configurations to a list of strings
[ "Save", "configurations", "to", "a", "list", "of", "strings" ]
239055229ec93a99cc7e15208075724ccf543bd1
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L271-L275
train