repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
bmuller/kademlia
kademlia/node.py
NodeHeap.push
def push(self, nodes): """ Push nodes onto heap. @param nodes: This can be a single item or a C{list}. """ if not isinstance(nodes, list): nodes = [nodes] for node in nodes: if node not in self: distance = self.node.distance_to(no...
python
def push(self, nodes): """ Push nodes onto heap. @param nodes: This can be a single item or a C{list}. """ if not isinstance(nodes, list): nodes = [nodes] for node in nodes: if node not in self: distance = self.node.distance_to(no...
[ "def", "push", "(", "self", ",", "nodes", ")", ":", "if", "not", "isinstance", "(", "nodes", ",", "list", ")", ":", "nodes", "=", "[", "nodes", "]", "for", "node", "in", "nodes", ":", "if", "node", "not", "in", "self", ":", "distance", "=", "self...
Push nodes onto heap. @param nodes: This can be a single item or a C{list}.
[ "Push", "nodes", "onto", "heap", "." ]
4a8d445c9ee8f3ca10f56107e4445daed4933c8a
https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/node.py#L85-L97
train
bmuller/kademlia
kademlia/utils.py
shared_prefix
def shared_prefix(args): """ Find the shared prefix between the strings. For instance: sharedPrefix(['blahblah', 'blahwhat']) returns 'blah'. """ i = 0 while i < min(map(len, args)): if len(set(map(operator.itemgetter(i), args))) != 1: break i += 1 ...
python
def shared_prefix(args): """ Find the shared prefix between the strings. For instance: sharedPrefix(['blahblah', 'blahwhat']) returns 'blah'. """ i = 0 while i < min(map(len, args)): if len(set(map(operator.itemgetter(i), args))) != 1: break i += 1 ...
[ "def", "shared_prefix", "(", "args", ")", ":", "i", "=", "0", "while", "i", "<", "min", "(", "map", "(", "len", ",", "args", ")", ")", ":", "if", "len", "(", "set", "(", "map", "(", "operator", ".", "itemgetter", "(", "i", ")", ",", "args", "...
Find the shared prefix between the strings. For instance: sharedPrefix(['blahblah', 'blahwhat']) returns 'blah'.
[ "Find", "the", "shared", "prefix", "between", "the", "strings", "." ]
4a8d445c9ee8f3ca10f56107e4445daed4933c8a
https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/utils.py#L21-L36
train
bmuller/kademlia
kademlia/protocol.py
KademliaProtocol.get_refresh_ids
def get_refresh_ids(self): """ Get ids to search for to keep old buckets up to date. """ ids = [] for bucket in self.router.lonely_buckets(): rid = random.randint(*bucket.range).to_bytes(20, byteorder='big') ids.append(rid) return ids
python
def get_refresh_ids(self): """ Get ids to search for to keep old buckets up to date. """ ids = [] for bucket in self.router.lonely_buckets(): rid = random.randint(*bucket.range).to_bytes(20, byteorder='big') ids.append(rid) return ids
[ "def", "get_refresh_ids", "(", "self", ")", ":", "ids", "=", "[", "]", "for", "bucket", "in", "self", ".", "router", ".", "lonely_buckets", "(", ")", ":", "rid", "=", "random", ".", "randint", "(", "*", "bucket", ".", "range", ")", ".", "to_bytes", ...
Get ids to search for to keep old buckets up to date.
[ "Get", "ids", "to", "search", "for", "to", "keep", "old", "buckets", "up", "to", "date", "." ]
4a8d445c9ee8f3ca10f56107e4445daed4933c8a
https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/protocol.py#L21-L29
train
bmuller/kademlia
kademlia/protocol.py
KademliaProtocol.handle_call_response
def handle_call_response(self, result, node): """ If we get a response, add the node to the routing table. If we get no response, make sure it's removed from the routing table. """ if not result[0]: log.warning("no response from %s, removing from router", node) ...
python
def handle_call_response(self, result, node): """ If we get a response, add the node to the routing table. If we get no response, make sure it's removed from the routing table. """ if not result[0]: log.warning("no response from %s, removing from router", node) ...
[ "def", "handle_call_response", "(", "self", ",", "result", ",", "node", ")", ":", "if", "not", "result", "[", "0", "]", ":", "log", ".", "warning", "(", "\"no response from %s, removing from router\"", ",", "node", ")", "self", ".", "router", ".", "remove_co...
If we get a response, add the node to the routing table. If we get no response, make sure it's removed from the routing table.
[ "If", "we", "get", "a", "response", "add", "the", "node", "to", "the", "routing", "table", ".", "If", "we", "get", "no", "response", "make", "sure", "it", "s", "removed", "from", "the", "routing", "table", "." ]
4a8d445c9ee8f3ca10f56107e4445daed4933c8a
https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/protocol.py#L116-L128
train
adafruit/Adafruit_CircuitPython_NeoPixel
neopixel.py
NeoPixel.deinit
def deinit(self): """Blank out the NeoPixels and release the pin.""" for i in range(len(self.buf)): self.buf[i] = 0 neopixel_write(self.pin, self.buf) self.pin.deinit()
python
def deinit(self): """Blank out the NeoPixels and release the pin.""" for i in range(len(self.buf)): self.buf[i] = 0 neopixel_write(self.pin, self.buf) self.pin.deinit()
[ "def", "deinit", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "buf", ")", ")", ":", "self", ".", "buf", "[", "i", "]", "=", "0", "neopixel_write", "(", "self", ".", "pin", ",", "self", ".", "buf", ")", "self...
Blank out the NeoPixels and release the pin.
[ "Blank", "out", "the", "NeoPixels", "and", "release", "the", "pin", "." ]
c0ed34813a608b64ed044826553918ddbad12f0c
https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/blob/c0ed34813a608b64ed044826553918ddbad12f0c/neopixel.py#L107-L112
train
adafruit/Adafruit_CircuitPython_NeoPixel
neopixel.py
NeoPixel.show
def show(self): """Shows the new colors on the pixels themselves if they haven't already been autowritten. The colors may or may not be showing after this function returns because it may be done asynchronously.""" if self.brightness > 0.99: neopixel_write(self.pin, s...
python
def show(self): """Shows the new colors on the pixels themselves if they haven't already been autowritten. The colors may or may not be showing after this function returns because it may be done asynchronously.""" if self.brightness > 0.99: neopixel_write(self.pin, s...
[ "def", "show", "(", "self", ")", ":", "if", "self", ".", "brightness", ">", "0.99", ":", "neopixel_write", "(", "self", ".", "pin", ",", "self", ".", "buf", ")", "else", ":", "neopixel_write", "(", "self", ".", "pin", ",", "bytearray", "(", "[", "i...
Shows the new colors on the pixels themselves if they haven't already been autowritten. The colors may or may not be showing after this function returns because it may be done asynchronously.
[ "Shows", "the", "new", "colors", "on", "the", "pixels", "themselves", "if", "they", "haven", "t", "already", "been", "autowritten", "." ]
c0ed34813a608b64ed044826553918ddbad12f0c
https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/blob/c0ed34813a608b64ed044826553918ddbad12f0c/neopixel.py#L223-L232
train
dask/dask-kubernetes
dask_kubernetes/objects.py
_set_k8s_attribute
def _set_k8s_attribute(obj, attribute, value): """ Set a specific value on a kubernetes object's attribute obj an object from Kubernetes Python API client attribute Should be a Kubernetes API style attribute (with camelCase) value Can be anything (string, list, dict, k8s obj...
python
def _set_k8s_attribute(obj, attribute, value): """ Set a specific value on a kubernetes object's attribute obj an object from Kubernetes Python API client attribute Should be a Kubernetes API style attribute (with camelCase) value Can be anything (string, list, dict, k8s obj...
[ "def", "_set_k8s_attribute", "(", "obj", ",", "attribute", ",", "value", ")", ":", "current_value", "=", "None", "attribute_name", "=", "None", "for", "python_attribute", ",", "json_attribute", "in", "obj", ".", "attribute_map", ".", "items", "(", ")", ":", ...
Set a specific value on a kubernetes object's attribute obj an object from Kubernetes Python API client attribute Should be a Kubernetes API style attribute (with camelCase) value Can be anything (string, list, dict, k8s objects) that can be accepted by the k8s python client
[ "Set", "a", "specific", "value", "on", "a", "kubernetes", "object", "s", "attribute" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/objects.py#L20-L64
train
dask/dask-kubernetes
dask_kubernetes/objects.py
merge_dictionaries
def merge_dictionaries(a, b, path=None, update=True): """ Merge two dictionaries recursively. From https://stackoverflow.com/a/25270947 """ if path is None: path = [] for key in b: if key in a: if isinstance(a[key], dict) and isinstance(b[key], dict): ...
python
def merge_dictionaries(a, b, path=None, update=True): """ Merge two dictionaries recursively. From https://stackoverflow.com/a/25270947 """ if path is None: path = [] for key in b: if key in a: if isinstance(a[key], dict) and isinstance(b[key], dict): ...
[ "def", "merge_dictionaries", "(", "a", ",", "b", ",", "path", "=", "None", ",", "update", "=", "True", ")", ":", "if", "path", "is", "None", ":", "path", "=", "[", "]", "for", "key", "in", "b", ":", "if", "key", "in", "a", ":", "if", "isinstanc...
Merge two dictionaries recursively. From https://stackoverflow.com/a/25270947
[ "Merge", "two", "dictionaries", "recursively", "." ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/objects.py#L67-L93
train
dask/dask-kubernetes
dask_kubernetes/objects.py
make_pod_spec
def make_pod_spec( image, labels={}, threads_per_worker=1, env={}, extra_container_config={}, extra_pod_config={}, memory_limit=None, memory_request=None, cpu_limit=None, cpu_request=None, ): """ Create generic pod template from inp...
python
def make_pod_spec( image, labels={}, threads_per_worker=1, env={}, extra_container_config={}, extra_pod_config={}, memory_limit=None, memory_request=None, cpu_limit=None, cpu_request=None, ): """ Create generic pod template from inp...
[ "def", "make_pod_spec", "(", "image", ",", "labels", "=", "{", "}", ",", "threads_per_worker", "=", "1", ",", "env", "=", "{", "}", ",", "extra_container_config", "=", "{", "}", ",", "extra_pod_config", "=", "{", "}", ",", "memory_limit", "=", "None", ...
Create generic pod template from input parameters Examples -------- >>> make_pod_spec(image='daskdev/dask:latest', memory_limit='4G', memory_request='4G')
[ "Create", "generic", "pod", "template", "from", "input", "parameters" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/objects.py#L96-L184
train
dask/dask-kubernetes
dask_kubernetes/objects.py
clean_pod_template
def clean_pod_template(pod_template): """ Normalize pod template and check for type errors """ if isinstance(pod_template, str): msg = ('Expected a kubernetes.client.V1Pod object, got %s' 'If trying to pass a yaml filename then use ' 'KubeCluster.from_yaml') raise T...
python
def clean_pod_template(pod_template): """ Normalize pod template and check for type errors """ if isinstance(pod_template, str): msg = ('Expected a kubernetes.client.V1Pod object, got %s' 'If trying to pass a yaml filename then use ' 'KubeCluster.from_yaml') raise T...
[ "def", "clean_pod_template", "(", "pod_template", ")", ":", "if", "isinstance", "(", "pod_template", ",", "str", ")", ":", "msg", "=", "(", "'Expected a kubernetes.client.V1Pod object, got %s'", "'If trying to pass a yaml filename then use '", "'KubeCluster.from_yaml'", ")", ...
Normalize pod template and check for type errors
[ "Normalize", "pod", "template", "and", "check", "for", "type", "errors" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/objects.py#L199-L225
train
dask/dask-kubernetes
dask_kubernetes/core.py
_cleanup_pods
def _cleanup_pods(namespace, labels): """ Remove all pods with these labels in this namespace """ api = kubernetes.client.CoreV1Api() pods = api.list_namespaced_pod(namespace, label_selector=format_labels(labels)) for pod in pods.items: try: api.delete_namespaced_pod(pod.metadata.nam...
python
def _cleanup_pods(namespace, labels): """ Remove all pods with these labels in this namespace """ api = kubernetes.client.CoreV1Api() pods = api.list_namespaced_pod(namespace, label_selector=format_labels(labels)) for pod in pods.items: try: api.delete_namespaced_pod(pod.metadata.nam...
[ "def", "_cleanup_pods", "(", "namespace", ",", "labels", ")", ":", "api", "=", "kubernetes", ".", "client", ".", "CoreV1Api", "(", ")", "pods", "=", "api", ".", "list_namespaced_pod", "(", "namespace", ",", "label_selector", "=", "format_labels", "(", "label...
Remove all pods with these labels in this namespace
[ "Remove", "all", "pods", "with", "these", "labels", "in", "this", "namespace" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L500-L511
train
dask/dask-kubernetes
dask_kubernetes/core.py
format_labels
def format_labels(labels): """ Convert a dictionary of labels into a comma separated string """ if labels: return ','.join(['{}={}'.format(k, v) for k, v in labels.items()]) else: return ''
python
def format_labels(labels): """ Convert a dictionary of labels into a comma separated string """ if labels: return ','.join(['{}={}'.format(k, v) for k, v in labels.items()]) else: return ''
[ "def", "format_labels", "(", "labels", ")", ":", "if", "labels", ":", "return", "','", ".", "join", "(", "[", "'{}={}'", ".", "format", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "labels", ".", "items", "(", ")", "]", ")", "else", ":"...
Convert a dictionary of labels into a comma separated string
[ "Convert", "a", "dictionary", "of", "labels", "into", "a", "comma", "separated", "string" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L514-L519
train
dask/dask-kubernetes
dask_kubernetes/core.py
_namespace_default
def _namespace_default(): """ Get current namespace if running in a k8s cluster If not in a k8s cluster with service accounts enabled, default to 'default' Taken from https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L125 """ ns_path = '/var/run/secrets/kubernete...
python
def _namespace_default(): """ Get current namespace if running in a k8s cluster If not in a k8s cluster with service accounts enabled, default to 'default' Taken from https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L125 """ ns_path = '/var/run/secrets/kubernete...
[ "def", "_namespace_default", "(", ")", ":", "ns_path", "=", "'/var/run/secrets/kubernetes.io/serviceaccount/namespace'", "if", "os", ".", "path", ".", "exists", "(", "ns_path", ")", ":", "with", "open", "(", "ns_path", ")", "as", "f", ":", "return", "f", ".", ...
Get current namespace if running in a k8s cluster If not in a k8s cluster with service accounts enabled, default to 'default' Taken from https://github.com/jupyterhub/kubespawner/blob/master/kubespawner/spawner.py#L125
[ "Get", "current", "namespace", "if", "running", "in", "a", "k8s", "cluster" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L522-L535
train
dask/dask-kubernetes
dask_kubernetes/core.py
select_workers_to_close
def select_workers_to_close(scheduler, n_to_close): """ Select n workers to close from scheduler """ workers = list(scheduler.workers.values()) assert n_to_close <= len(workers) key = lambda ws: ws.metrics['memory'] to_close = set(sorted(scheduler.idle, key=key)[:n_to_close]) if len(to_close) <...
python
def select_workers_to_close(scheduler, n_to_close): """ Select n workers to close from scheduler """ workers = list(scheduler.workers.values()) assert n_to_close <= len(workers) key = lambda ws: ws.metrics['memory'] to_close = set(sorted(scheduler.idle, key=key)[:n_to_close]) if len(to_close) <...
[ "def", "select_workers_to_close", "(", "scheduler", ",", "n_to_close", ")", ":", "workers", "=", "list", "(", "scheduler", ".", "workers", ".", "values", "(", ")", ")", "assert", "n_to_close", "<=", "len", "(", "workers", ")", "key", "=", "lambda", "ws", ...
Select n workers to close from scheduler
[ "Select", "n", "workers", "to", "close", "from", "scheduler" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L538-L550
train
dask/dask-kubernetes
dask_kubernetes/core.py
KubeCluster.from_yaml
def from_yaml(cls, yaml_path, **kwargs): """ Create cluster with worker pod spec defined by a YAML file We can start a cluster with pods defined in an accompanying YAML file like the following: .. code-block:: yaml kind: Pod metadata: labels: ...
python
def from_yaml(cls, yaml_path, **kwargs): """ Create cluster with worker pod spec defined by a YAML file We can start a cluster with pods defined in an accompanying YAML file like the following: .. code-block:: yaml kind: Pod metadata: labels: ...
[ "def", "from_yaml", "(", "cls", ",", "yaml_path", ",", "**", "kwargs", ")", ":", "if", "not", "yaml", ":", "raise", "ImportError", "(", "\"PyYaml is required to use yaml functionality, please install it!\"", ")", "with", "open", "(", "yaml_path", ")", "as", "f", ...
Create cluster with worker pod spec defined by a YAML file We can start a cluster with pods defined in an accompanying YAML file like the following: .. code-block:: yaml kind: Pod metadata: labels: foo: bar baz: quux ...
[ "Create", "cluster", "with", "worker", "pod", "spec", "defined", "by", "a", "YAML", "file" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L251-L284
train
dask/dask-kubernetes
dask_kubernetes/core.py
KubeCluster.pods
def pods(self): """ A list of kubernetes pods corresponding to current workers See Also -------- KubeCluster.logs """ return self.core_api.list_namespaced_pod( self.namespace, label_selector=format_labels(self.pod_template.metadata.labels) ...
python
def pods(self): """ A list of kubernetes pods corresponding to current workers See Also -------- KubeCluster.logs """ return self.core_api.list_namespaced_pod( self.namespace, label_selector=format_labels(self.pod_template.metadata.labels) ...
[ "def", "pods", "(", "self", ")", ":", "return", "self", ".", "core_api", ".", "list_namespaced_pod", "(", "self", ".", "namespace", ",", "label_selector", "=", "format_labels", "(", "self", ".", "pod_template", ".", "metadata", ".", "labels", ")", ")", "."...
A list of kubernetes pods corresponding to current workers See Also -------- KubeCluster.logs
[ "A", "list", "of", "kubernetes", "pods", "corresponding", "to", "current", "workers" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L306-L316
train
dask/dask-kubernetes
dask_kubernetes/core.py
KubeCluster.logs
def logs(self, pod=None): """ Logs from a worker pod You can get this pod object from the ``pods`` method. If no pod is specified all pod logs will be returned. On large clusters this could end up being rather large. Parameters ---------- pod: kubernetes.client...
python
def logs(self, pod=None): """ Logs from a worker pod You can get this pod object from the ``pods`` method. If no pod is specified all pod logs will be returned. On large clusters this could end up being rather large. Parameters ---------- pod: kubernetes.client...
[ "def", "logs", "(", "self", ",", "pod", "=", "None", ")", ":", "if", "pod", "is", "None", ":", "return", "{", "pod", ".", "status", ".", "pod_ip", ":", "self", ".", "logs", "(", "pod", ")", "for", "pod", "in", "self", ".", "pods", "(", ")", "...
Logs from a worker pod You can get this pod object from the ``pods`` method. If no pod is specified all pod logs will be returned. On large clusters this could end up being rather large. Parameters ---------- pod: kubernetes.client.V1Pod The pod from which ...
[ "Logs", "from", "a", "worker", "pod" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L318-L340
train
dask/dask-kubernetes
dask_kubernetes/core.py
KubeCluster.scale
def scale(self, n): """ Scale cluster to n workers Parameters ---------- n: int Target number of workers Example ------- >>> cluster.scale(10) # scale cluster to ten workers See Also -------- KubeCluster.scale_up Kub...
python
def scale(self, n): """ Scale cluster to n workers Parameters ---------- n: int Target number of workers Example ------- >>> cluster.scale(10) # scale cluster to ten workers See Also -------- KubeCluster.scale_up Kub...
[ "def", "scale", "(", "self", ",", "n", ")", ":", "pods", "=", "self", ".", "_cleanup_terminated_pods", "(", "self", ".", "pods", "(", ")", ")", "if", "n", ">=", "len", "(", "pods", ")", ":", "return", "self", ".", "scale_up", "(", "n", ",", "pods...
Scale cluster to n workers Parameters ---------- n: int Target number of workers Example ------- >>> cluster.scale(10) # scale cluster to ten workers See Also -------- KubeCluster.scale_up KubeCluster.scale_down
[ "Scale", "cluster", "to", "n", "workers" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L342-L395
train
dask/dask-kubernetes
dask_kubernetes/core.py
KubeCluster.scale_up
def scale_up(self, n, pods=None, **kwargs): """ Make sure we have n dask-workers available for this cluster Examples -------- >>> cluster.scale_up(20) # ask for twenty workers """ maximum = dask.config.get('kubernetes.count.max') if maximum is not None a...
python
def scale_up(self, n, pods=None, **kwargs): """ Make sure we have n dask-workers available for this cluster Examples -------- >>> cluster.scale_up(20) # ask for twenty workers """ maximum = dask.config.get('kubernetes.count.max') if maximum is not None a...
[ "def", "scale_up", "(", "self", ",", "n", ",", "pods", "=", "None", ",", "**", "kwargs", ")", ":", "maximum", "=", "dask", ".", "config", ".", "get", "(", "'kubernetes.count.max'", ")", "if", "maximum", "is", "not", "None", "and", "maximum", "<", "n"...
Make sure we have n dask-workers available for this cluster Examples -------- >>> cluster.scale_up(20) # ask for twenty workers
[ "Make", "sure", "we", "have", "n", "dask", "-", "workers", "available", "for", "this", "cluster" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L421-L455
train
dask/dask-kubernetes
dask_kubernetes/core.py
KubeCluster.scale_down
def scale_down(self, workers, pods=None): """ Remove the pods for the requested list of workers When scale_down is called by the _adapt async loop, the workers are assumed to have been cleanly closed first and in-memory data has been migrated to the remaining workers. Note that...
python
def scale_down(self, workers, pods=None): """ Remove the pods for the requested list of workers When scale_down is called by the _adapt async loop, the workers are assumed to have been cleanly closed first and in-memory data has been migrated to the remaining workers. Note that...
[ "def", "scale_down", "(", "self", ",", "workers", ",", "pods", "=", "None", ")", ":", "pods", "=", "pods", "or", "self", ".", "_cleanup_terminated_pods", "(", "self", ".", "pods", "(", ")", ")", "ips", "=", "set", "(", "urlparse", "(", "worker", ")",...
Remove the pods for the requested list of workers When scale_down is called by the _adapt async loop, the workers are assumed to have been cleanly closed first and in-memory data has been migrated to the remaining workers. Note that when the worker process exits, Kubernetes leaves the ...
[ "Remove", "the", "pods", "for", "the", "requested", "list", "of", "workers" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L458-L485
train
dask/dask-kubernetes
dask_kubernetes/core.py
KubeCluster.close
def close(self, **kwargs): """ Close this cluster """ self.scale_down(self.cluster.scheduler.workers) return self.cluster.close(**kwargs)
python
def close(self, **kwargs): """ Close this cluster """ self.scale_down(self.cluster.scheduler.workers) return self.cluster.close(**kwargs)
[ "def", "close", "(", "self", ",", "**", "kwargs", ")", ":", "self", ".", "scale_down", "(", "self", ".", "cluster", ".", "scheduler", ".", "workers", ")", "return", "self", ".", "cluster", ".", "close", "(", "**", "kwargs", ")" ]
Close this cluster
[ "Close", "this", "cluster" ]
8a4883ecd902460b446bb1f43ed97efe398a135e
https://github.com/dask/dask-kubernetes/blob/8a4883ecd902460b446bb1f43ed97efe398a135e/dask_kubernetes/core.py#L490-L493
train
viniciuschiele/flask-apscheduler
flask_apscheduler/utils.py
job_to_dict
def job_to_dict(job): """Converts a job to an OrderedDict.""" data = OrderedDict() data['id'] = job.id data['name'] = job.name data['func'] = job.func_ref data['args'] = job.args data['kwargs'] = job.kwargs data.update(trigger_to_dict(job.trigger)) if not job.pending: data...
python
def job_to_dict(job): """Converts a job to an OrderedDict.""" data = OrderedDict() data['id'] = job.id data['name'] = job.name data['func'] = job.func_ref data['args'] = job.args data['kwargs'] = job.kwargs data.update(trigger_to_dict(job.trigger)) if not job.pending: data...
[ "def", "job_to_dict", "(", "job", ")", ":", "data", "=", "OrderedDict", "(", ")", "data", "[", "'id'", "]", "=", "job", ".", "id", "data", "[", "'name'", "]", "=", "job", ".", "name", "data", "[", "'func'", "]", "=", "job", ".", "func_ref", "data...
Converts a job to an OrderedDict.
[ "Converts", "a", "job", "to", "an", "OrderedDict", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/utils.py#L26-L43
train
viniciuschiele/flask-apscheduler
flask_apscheduler/utils.py
pop_trigger
def pop_trigger(data): """Pops trigger and trigger args from a given dict.""" trigger_name = data.pop('trigger') trigger_args = {} if trigger_name == 'date': trigger_arg_names = ('run_date', 'timezone') elif trigger_name == 'interval': trigger_arg_names = ('weeks', 'days', 'hours',...
python
def pop_trigger(data): """Pops trigger and trigger args from a given dict.""" trigger_name = data.pop('trigger') trigger_args = {} if trigger_name == 'date': trigger_arg_names = ('run_date', 'timezone') elif trigger_name == 'interval': trigger_arg_names = ('weeks', 'days', 'hours',...
[ "def", "pop_trigger", "(", "data", ")", ":", "trigger_name", "=", "data", ".", "pop", "(", "'trigger'", ")", "trigger_args", "=", "{", "}", "if", "trigger_name", "==", "'date'", ":", "trigger_arg_names", "=", "(", "'run_date'", ",", "'timezone'", ")", "eli...
Pops trigger and trigger args from a given dict.
[ "Pops", "trigger", "and", "trigger", "args", "from", "a", "given", "dict", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/utils.py#L46-L65
train
viniciuschiele/flask-apscheduler
flask_apscheduler/utils.py
trigger_to_dict
def trigger_to_dict(trigger): """Converts a trigger to an OrderedDict.""" data = OrderedDict() if isinstance(trigger, DateTrigger): data['trigger'] = 'date' data['run_date'] = trigger.run_date elif isinstance(trigger, IntervalTrigger): data['trigger'] = 'interval' data[...
python
def trigger_to_dict(trigger): """Converts a trigger to an OrderedDict.""" data = OrderedDict() if isinstance(trigger, DateTrigger): data['trigger'] = 'date' data['run_date'] = trigger.run_date elif isinstance(trigger, IntervalTrigger): data['trigger'] = 'interval' data[...
[ "def", "trigger_to_dict", "(", "trigger", ")", ":", "data", "=", "OrderedDict", "(", ")", "if", "isinstance", "(", "trigger", ",", "DateTrigger", ")", ":", "data", "[", "'trigger'", "]", "=", "'date'", "data", "[", "'run_date'", "]", "=", "trigger", ".",...
Converts a trigger to an OrderedDict.
[ "Converts", "a", "trigger", "to", "an", "OrderedDict", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/utils.py#L68-L110
train
viniciuschiele/flask-apscheduler
flask_apscheduler/utils.py
fix_job_def
def fix_job_def(job_def): """ Replaces the datetime in string by datetime object. """ if six.PY2 and isinstance(job_def.get('func'), six.text_type): # when a job comes from the endpoint, strings are unicode # because that's how json package deserialize the bytes. # we had a case ...
python
def fix_job_def(job_def): """ Replaces the datetime in string by datetime object. """ if six.PY2 and isinstance(job_def.get('func'), six.text_type): # when a job comes from the endpoint, strings are unicode # because that's how json package deserialize the bytes. # we had a case ...
[ "def", "fix_job_def", "(", "job_def", ")", ":", "if", "six", ".", "PY2", "and", "isinstance", "(", "job_def", ".", "get", "(", "'func'", ")", ",", "six", ".", "text_type", ")", ":", "job_def", "[", "'func'", "]", "=", "str", "(", "job_def", ".", "g...
Replaces the datetime in string by datetime object.
[ "Replaces", "the", "datetime", "in", "string", "by", "datetime", "object", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/utils.py#L113-L142
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler.init_app
def init_app(self, app): """Initialize the APScheduler with a Flask application instance.""" self.app = app self.app.apscheduler = self self._load_config() self._load_jobs() if self.api_enabled: self._load_api()
python
def init_app(self, app): """Initialize the APScheduler with a Flask application instance.""" self.app = app self.app.apscheduler = self self._load_config() self._load_jobs() if self.api_enabled: self._load_api()
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "self", ".", "app", "=", "app", "self", ".", "app", ".", "apscheduler", "=", "self", "self", ".", "_load_config", "(", ")", "self", ".", "_load_jobs", "(", ")", "if", "self", ".", "api_enabled", ...
Initialize the APScheduler with a Flask application instance.
[ "Initialize", "the", "APScheduler", "with", "a", "Flask", "application", "instance", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L75-L85
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler.add_listener
def add_listener(self, callback, mask=EVENT_ALL): """ Add a listener for scheduler events. When a matching event occurs, ``callback`` is executed with the event object as its sole argument. If the ``mask`` parameter is not provided, the callback will receive events of all types...
python
def add_listener(self, callback, mask=EVENT_ALL): """ Add a listener for scheduler events. When a matching event occurs, ``callback`` is executed with the event object as its sole argument. If the ``mask`` parameter is not provided, the callback will receive events of all types...
[ "def", "add_listener", "(", "self", ",", "callback", ",", "mask", "=", "EVENT_ALL", ")", ":", "self", ".", "_scheduler", ".", "add_listener", "(", "callback", ",", "mask", ")" ]
Add a listener for scheduler events. When a matching event occurs, ``callback`` is executed with the event object as its sole argument. If the ``mask`` parameter is not provided, the callback will receive events of all types. For further info: https://apscheduler.readthedocs.io/en/lat...
[ "Add", "a", "listener", "for", "scheduler", "events", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L124-L137
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler.add_job
def add_job(self, id, func, **kwargs): """ Add the given job to the job list and wakes up the scheduler if it's already running. :param str id: explicit identifier for the job (for modifying it later) :param func: callable (or a textual reference to one) to run at the given time ...
python
def add_job(self, id, func, **kwargs): """ Add the given job to the job list and wakes up the scheduler if it's already running. :param str id: explicit identifier for the job (for modifying it later) :param func: callable (or a textual reference to one) to run at the given time ...
[ "def", "add_job", "(", "self", ",", "id", ",", "func", ",", "**", "kwargs", ")", ":", "job_def", "=", "dict", "(", "kwargs", ")", "job_def", "[", "'id'", "]", "=", "id", "job_def", "[", "'func'", "]", "=", "func", "job_def", "[", "'name'", "]", "...
Add the given job to the job list and wakes up the scheduler if it's already running. :param str id: explicit identifier for the job (for modifying it later) :param func: callable (or a textual reference to one) to run at the given time
[ "Add", "the", "given", "job", "to", "the", "job", "list", "and", "wakes", "up", "the", "scheduler", "if", "it", "s", "already", "running", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L145-L160
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler.delete_job
def delete_job(self, id, jobstore=None): """ DEPRECATED, use remove_job instead. Remove a job, preventing it from being run any more. :param str id: the identifier of the job :param str jobstore: alias of the job store that contains the job """ warnings.warn('de...
python
def delete_job(self, id, jobstore=None): """ DEPRECATED, use remove_job instead. Remove a job, preventing it from being run any more. :param str id: the identifier of the job :param str jobstore: alias of the job store that contains the job """ warnings.warn('de...
[ "def", "delete_job", "(", "self", ",", "id", ",", "jobstore", "=", "None", ")", ":", "warnings", ".", "warn", "(", "'delete_job has been deprecated, use remove_job instead.'", ",", "DeprecationWarning", ")", "self", ".", "remove_job", "(", "id", ",", "jobstore", ...
DEPRECATED, use remove_job instead. Remove a job, preventing it from being run any more. :param str id: the identifier of the job :param str jobstore: alias of the job store that contains the job
[ "DEPRECATED", "use", "remove_job", "instead", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L162-L173
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler.modify_job
def modify_job(self, id, jobstore=None, **changes): """ Modify the properties of a single job. Modifications are passed to this method as extra keyword arguments. :param str id: the identifier of the job :param str jobstore: alias of the job store that contains the job """ ...
python
def modify_job(self, id, jobstore=None, **changes): """ Modify the properties of a single job. Modifications are passed to this method as extra keyword arguments. :param str id: the identifier of the job :param str jobstore: alias of the job store that contains the job """ ...
[ "def", "modify_job", "(", "self", ",", "id", ",", "jobstore", "=", "None", ",", "**", "changes", ")", ":", "fix_job_def", "(", "changes", ")", "if", "'trigger'", "in", "changes", ":", "trigger", ",", "trigger_args", "=", "pop_trigger", "(", "changes", ")...
Modify the properties of a single job. Modifications are passed to this method as extra keyword arguments. :param str id: the identifier of the job :param str jobstore: alias of the job store that contains the job
[ "Modify", "the", "properties", "of", "a", "single", "job", ".", "Modifications", "are", "passed", "to", "this", "method", "as", "extra", "keyword", "arguments", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L230-L244
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler._load_config
def _load_config(self): """ Load the configuration from the Flask configuration. """ options = dict() job_stores = self.app.config.get('SCHEDULER_JOBSTORES') if job_stores: options['jobstores'] = job_stores executors = self.app.config.get('SCHEDULER_...
python
def _load_config(self): """ Load the configuration from the Flask configuration. """ options = dict() job_stores = self.app.config.get('SCHEDULER_JOBSTORES') if job_stores: options['jobstores'] = job_stores executors = self.app.config.get('SCHEDULER_...
[ "def", "_load_config", "(", "self", ")", ":", "options", "=", "dict", "(", ")", "job_stores", "=", "self", ".", "app", ".", "config", ".", "get", "(", "'SCHEDULER_JOBSTORES'", ")", "if", "job_stores", ":", "options", "[", "'jobstores'", "]", "=", "job_st...
Load the configuration from the Flask configuration.
[ "Load", "the", "configuration", "from", "the", "Flask", "configuration", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L286-L315
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler._load_jobs
def _load_jobs(self): """ Load the job definitions from the Flask configuration. """ jobs = self.app.config.get('SCHEDULER_JOBS') if not jobs: jobs = self.app.config.get('JOBS') if jobs: for job in jobs: self.add_job(**job)
python
def _load_jobs(self): """ Load the job definitions from the Flask configuration. """ jobs = self.app.config.get('SCHEDULER_JOBS') if not jobs: jobs = self.app.config.get('JOBS') if jobs: for job in jobs: self.add_job(**job)
[ "def", "_load_jobs", "(", "self", ")", ":", "jobs", "=", "self", ".", "app", ".", "config", ".", "get", "(", "'SCHEDULER_JOBS'", ")", "if", "not", "jobs", ":", "jobs", "=", "self", ".", "app", ".", "config", ".", "get", "(", "'JOBS'", ")", "if", ...
Load the job definitions from the Flask configuration.
[ "Load", "the", "job", "definitions", "from", "the", "Flask", "configuration", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L317-L328
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler._load_api
def _load_api(self): """ Add the routes for the scheduler API. """ self._add_url_route('get_scheduler_info', '', api.get_scheduler_info, 'GET') self._add_url_route('add_job', '/jobs', api.add_job, 'POST') self._add_url_route('get_job', '/jobs/<job_id>', api.get_job, 'GET'...
python
def _load_api(self): """ Add the routes for the scheduler API. """ self._add_url_route('get_scheduler_info', '', api.get_scheduler_info, 'GET') self._add_url_route('add_job', '/jobs', api.add_job, 'POST') self._add_url_route('get_job', '/jobs/<job_id>', api.get_job, 'GET'...
[ "def", "_load_api", "(", "self", ")", ":", "self", ".", "_add_url_route", "(", "'get_scheduler_info'", ",", "''", ",", "api", ".", "get_scheduler_info", ",", "'GET'", ")", "self", ".", "_add_url_route", "(", "'add_job'", ",", "'/jobs'", ",", "api", ".", "a...
Add the routes for the scheduler API.
[ "Add", "the", "routes", "for", "the", "scheduler", "API", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L330-L342
train
viniciuschiele/flask-apscheduler
flask_apscheduler/scheduler.py
APScheduler._handle_authentication_error
def _handle_authentication_error(self): """ Return an authentication error. """ response = make_response('Access Denied') response.headers['WWW-Authenticate'] = self.auth.get_authenticate_header() response.status_code = 401 return response
python
def _handle_authentication_error(self): """ Return an authentication error. """ response = make_response('Access Denied') response.headers['WWW-Authenticate'] = self.auth.get_authenticate_header() response.status_code = 401 return response
[ "def", "_handle_authentication_error", "(", "self", ")", ":", "response", "=", "make_response", "(", "'Access Denied'", ")", "response", ".", "headers", "[", "'WWW-Authenticate'", "]", "=", "self", ".", "auth", ".", "get_authenticate_header", "(", ")", "response",...
Return an authentication error.
[ "Return", "an", "authentication", "error", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/scheduler.py#L387-L394
train
viniciuschiele/flask-apscheduler
flask_apscheduler/api.py
get_scheduler_info
def get_scheduler_info(): """Gets the scheduler info.""" scheduler = current_app.apscheduler d = OrderedDict([ ('current_host', scheduler.host_name), ('allowed_hosts', scheduler.allowed_hosts), ('running', scheduler.running) ]) return jsonify(d)
python
def get_scheduler_info(): """Gets the scheduler info.""" scheduler = current_app.apscheduler d = OrderedDict([ ('current_host', scheduler.host_name), ('allowed_hosts', scheduler.allowed_hosts), ('running', scheduler.running) ]) return jsonify(d)
[ "def", "get_scheduler_info", "(", ")", ":", "scheduler", "=", "current_app", ".", "apscheduler", "d", "=", "OrderedDict", "(", "[", "(", "'current_host'", ",", "scheduler", ".", "host_name", ")", ",", "(", "'allowed_hosts'", ",", "scheduler", ".", "allowed_hos...
Gets the scheduler info.
[ "Gets", "the", "scheduler", "info", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/api.py#L21-L32
train
viniciuschiele/flask-apscheduler
flask_apscheduler/api.py
add_job
def add_job(): """Adds a new job.""" data = request.get_json(force=True) try: job = current_app.apscheduler.add_job(**data) return jsonify(job) except ConflictingIdError: return jsonify(dict(error_message='Job %s already exists.' % data.get('id')), status=409) except Except...
python
def add_job(): """Adds a new job.""" data = request.get_json(force=True) try: job = current_app.apscheduler.add_job(**data) return jsonify(job) except ConflictingIdError: return jsonify(dict(error_message='Job %s already exists.' % data.get('id')), status=409) except Except...
[ "def", "add_job", "(", ")", ":", "data", "=", "request", ".", "get_json", "(", "force", "=", "True", ")", "try", ":", "job", "=", "current_app", ".", "apscheduler", ".", "add_job", "(", "**", "data", ")", "return", "jsonify", "(", "job", ")", "except...
Adds a new job.
[ "Adds", "a", "new", "job", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/api.py#L35-L46
train
viniciuschiele/flask-apscheduler
flask_apscheduler/api.py
get_job
def get_job(job_id): """Gets a job.""" job = current_app.apscheduler.get_job(job_id) if not job: return jsonify(dict(error_message='Job %s not found' % job_id), status=404) return jsonify(job)
python
def get_job(job_id): """Gets a job.""" job = current_app.apscheduler.get_job(job_id) if not job: return jsonify(dict(error_message='Job %s not found' % job_id), status=404) return jsonify(job)
[ "def", "get_job", "(", "job_id", ")", ":", "job", "=", "current_app", ".", "apscheduler", ".", "get_job", "(", "job_id", ")", "if", "not", "job", ":", "return", "jsonify", "(", "dict", "(", "error_message", "=", "'Job %s not found'", "%", "job_id", ")", ...
Gets a job.
[ "Gets", "a", "job", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/api.py#L61-L69
train
viniciuschiele/flask-apscheduler
flask_apscheduler/api.py
get_jobs
def get_jobs(): """Gets all scheduled jobs.""" jobs = current_app.apscheduler.get_jobs() job_states = [] for job in jobs: job_states.append(job) return jsonify(job_states)
python
def get_jobs(): """Gets all scheduled jobs.""" jobs = current_app.apscheduler.get_jobs() job_states = [] for job in jobs: job_states.append(job) return jsonify(job_states)
[ "def", "get_jobs", "(", ")", ":", "jobs", "=", "current_app", ".", "apscheduler", ".", "get_jobs", "(", ")", "job_states", "=", "[", "]", "for", "job", "in", "jobs", ":", "job_states", ".", "append", "(", "job", ")", "return", "jsonify", "(", "job_stat...
Gets all scheduled jobs.
[ "Gets", "all", "scheduled", "jobs", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/api.py#L72-L82
train
viniciuschiele/flask-apscheduler
flask_apscheduler/api.py
update_job
def update_job(job_id): """Updates a job.""" data = request.get_json(force=True) try: current_app.apscheduler.modify_job(job_id, **data) job = current_app.apscheduler.get_job(job_id) return jsonify(job) except JobLookupError: return jsonify(dict(error_message='Job %s no...
python
def update_job(job_id): """Updates a job.""" data = request.get_json(force=True) try: current_app.apscheduler.modify_job(job_id, **data) job = current_app.apscheduler.get_job(job_id) return jsonify(job) except JobLookupError: return jsonify(dict(error_message='Job %s no...
[ "def", "update_job", "(", "job_id", ")", ":", "data", "=", "request", ".", "get_json", "(", "force", "=", "True", ")", "try", ":", "current_app", ".", "apscheduler", ".", "modify_job", "(", "job_id", ",", "**", "data", ")", "job", "=", "current_app", "...
Updates a job.
[ "Updates", "a", "job", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/api.py#L85-L97
train
viniciuschiele/flask-apscheduler
flask_apscheduler/api.py
resume_job
def resume_job(job_id): """Resumes a job.""" try: current_app.apscheduler.resume_job(job_id) job = current_app.apscheduler.get_job(job_id) return jsonify(job) except JobLookupError: return jsonify(dict(error_message='Job %s not found' % job_id), status=404) except Except...
python
def resume_job(job_id): """Resumes a job.""" try: current_app.apscheduler.resume_job(job_id) job = current_app.apscheduler.get_job(job_id) return jsonify(job) except JobLookupError: return jsonify(dict(error_message='Job %s not found' % job_id), status=404) except Except...
[ "def", "resume_job", "(", "job_id", ")", ":", "try", ":", "current_app", ".", "apscheduler", ".", "resume_job", "(", "job_id", ")", "job", "=", "current_app", ".", "apscheduler", ".", "get_job", "(", "job_id", ")", "return", "jsonify", "(", "job", ")", "...
Resumes a job.
[ "Resumes", "a", "job", "." ]
cc52c39e1948c4e8de5da0d01db45f1779f61997
https://github.com/viniciuschiele/flask-apscheduler/blob/cc52c39e1948c4e8de5da0d01db45f1779f61997/flask_apscheduler/api.py#L113-L123
train
pgjones/quart
quart/cli.py
QuartGroup.get_command
def get_command(self, ctx: click.Context, name: str) -> click.Command: """Return the relevant command given the context and name. .. warning:: This differs substaintially from Flask in that it allows for the inbuilt commands to be overridden. """ info = ctx.ensu...
python
def get_command(self, ctx: click.Context, name: str) -> click.Command: """Return the relevant command given the context and name. .. warning:: This differs substaintially from Flask in that it allows for the inbuilt commands to be overridden. """ info = ctx.ensu...
[ "def", "get_command", "(", "self", ",", "ctx", ":", "click", ".", "Context", ",", "name", ":", "str", ")", "->", "click", ".", "Command", ":", "info", "=", "ctx", ".", "ensure_object", "(", "ScriptInfo", ")", "command", "=", "None", "try", ":", "comm...
Return the relevant command given the context and name. .. warning:: This differs substaintially from Flask in that it allows for the inbuilt commands to be overridden.
[ "Return", "the", "relevant", "command", "given", "the", "context", "and", "name", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/cli.py#L155-L171
train
pgjones/quart
quart/templating.py
render_template
async def render_template(template_name_or_list: Union[str, List[str]], **context: Any) -> str: """Render the template with the context given. Arguments: template_name_or_list: Template name to render of a list of possible template names. context: The variables to pass to the templa...
python
async def render_template(template_name_or_list: Union[str, List[str]], **context: Any) -> str: """Render the template with the context given. Arguments: template_name_or_list: Template name to render of a list of possible template names. context: The variables to pass to the templa...
[ "async", "def", "render_template", "(", "template_name_or_list", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", ",", "**", "context", ":", "Any", ")", "->", "str", ":", "await", "current_app", ".", "update_template_context", "(", "context", "...
Render the template with the context given. Arguments: template_name_or_list: Template name to render of a list of possible template names. context: The variables to pass to the template.
[ "Render", "the", "template", "with", "the", "context", "given", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/templating.py#L79-L89
train
pgjones/quart
quart/templating.py
render_template_string
async def render_template_string(source: str, **context: Any) -> str: """Render the template source with the context given. Arguments: source: The template source code. context: The variables to pass to the template. """ await current_app.update_template_context(context) template = ...
python
async def render_template_string(source: str, **context: Any) -> str: """Render the template source with the context given. Arguments: source: The template source code. context: The variables to pass to the template. """ await current_app.update_template_context(context) template = ...
[ "async", "def", "render_template_string", "(", "source", ":", "str", ",", "**", "context", ":", "Any", ")", "->", "str", ":", "await", "current_app", ".", "update_template_context", "(", "context", ")", "template", "=", "current_app", ".", "jinja_env", ".", ...
Render the template source with the context given. Arguments: source: The template source code. context: The variables to pass to the template.
[ "Render", "the", "template", "source", "with", "the", "context", "given", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/templating.py#L92-L101
train
pgjones/quart
quart/templating.py
DispatchingJinjaLoader.get_source
def get_source( self, environment: Environment, template: str, ) -> Tuple[str, Optional[str], Callable]: """Returns the template source from the environment. This considers the loaders on the :attr:`app` and blueprints. """ for loader in self._loaders(): try:...
python
def get_source( self, environment: Environment, template: str, ) -> Tuple[str, Optional[str], Callable]: """Returns the template source from the environment. This considers the loaders on the :attr:`app` and blueprints. """ for loader in self._loaders(): try:...
[ "def", "get_source", "(", "self", ",", "environment", ":", "Environment", ",", "template", ":", "str", ",", ")", "->", "Tuple", "[", "str", ",", "Optional", "[", "str", "]", ",", "Callable", "]", ":", "for", "loader", "in", "self", ".", "_loaders", "...
Returns the template source from the environment. This considers the loaders on the :attr:`app` and blueprints.
[ "Returns", "the", "template", "source", "from", "the", "environment", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/templating.py#L43-L55
train
pgjones/quart
quart/templating.py
DispatchingJinjaLoader.list_templates
def list_templates(self) -> List[str]: """Returns a list of all avilable templates in environment. This considers the loaders on the :attr:`app` and blueprints. """ result = set() for loader in self._loaders(): for template in loader.list_templates(): ...
python
def list_templates(self) -> List[str]: """Returns a list of all avilable templates in environment. This considers the loaders on the :attr:`app` and blueprints. """ result = set() for loader in self._loaders(): for template in loader.list_templates(): ...
[ "def", "list_templates", "(", "self", ")", "->", "List", "[", "str", "]", ":", "result", "=", "set", "(", ")", "for", "loader", "in", "self", ".", "_loaders", "(", ")", ":", "for", "template", "in", "loader", ".", "list_templates", "(", ")", ":", "...
Returns a list of all avilable templates in environment. This considers the loaders on the :attr:`app` and blueprints.
[ "Returns", "a", "list", "of", "all", "avilable", "templates", "in", "environment", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/templating.py#L67-L76
train
pgjones/quart
quart/blueprints.py
Blueprint.route
def route( self, path: str, methods: Optional[List[str]]=None, endpoint: Optional[str]=None, defaults: Optional[dict]=None, host: Optional[str]=None, subdomain: Optional[str]=None, *, provide_automatic_options: O...
python
def route( self, path: str, methods: Optional[List[str]]=None, endpoint: Optional[str]=None, defaults: Optional[dict]=None, host: Optional[str]=None, subdomain: Optional[str]=None, *, provide_automatic_options: O...
[ "def", "route", "(", "self", ",", "path", ":", "str", ",", "methods", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", "endpoint", ":", "Optional", "[", "str", "]", "=", "None", ",", "defaults", ":", "Optional", "[", "dict", ...
Add a route to the blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.route`. An example usage, .. code-block:: python blueprint = Blueprint(__name__) @blueprint.route('/') def route(): ....
[ "Add", "a", "route", "to", "the", "blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L53-L83
train
pgjones/quart
quart/blueprints.py
Blueprint.websocket
def websocket( self, path: str, endpoint: Optional[str]=None, defaults: Optional[dict]=None, host: Optional[str]=None, subdomain: Optional[str]=None, *, strict_slashes: bool=True, ) -> Callable: """Add a websocke...
python
def websocket( self, path: str, endpoint: Optional[str]=None, defaults: Optional[dict]=None, host: Optional[str]=None, subdomain: Optional[str]=None, *, strict_slashes: bool=True, ) -> Callable: """Add a websocke...
[ "def", "websocket", "(", "self", ",", "path", ":", "str", ",", "endpoint", ":", "Optional", "[", "str", "]", "=", "None", ",", "defaults", ":", "Optional", "[", "dict", "]", "=", "None", ",", "host", ":", "Optional", "[", "str", "]", "=", "None", ...
Add a websocket to the blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.websocket`. An example usage, .. code-block:: python blueprint = Blueprint(__name__) @blueprint.websocket('/') async def route():...
[ "Add", "a", "websocket", "to", "the", "blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L124-L152
train
pgjones/quart
quart/blueprints.py
Blueprint.add_websocket
def add_websocket( self, path: str, endpoint: Optional[str]=None, view_func: Optional[Callable]=None, defaults: Optional[dict]=None, host: Optional[str]=None, subdomain: Optional[str]=None, *, strict_slashes: boo...
python
def add_websocket( self, path: str, endpoint: Optional[str]=None, view_func: Optional[Callable]=None, defaults: Optional[dict]=None, host: Optional[str]=None, subdomain: Optional[str]=None, *, strict_slashes: boo...
[ "def", "add_websocket", "(", "self", ",", "path", ":", "str", ",", "endpoint", ":", "Optional", "[", "str", "]", "=", "None", ",", "view_func", ":", "Optional", "[", "Callable", "]", "=", "None", ",", "defaults", ":", "Optional", "[", "dict", "]", "=...
Add a websocket rule to the blueprint. This is designed to be used on the blueprint directly, and has the same arguments as :meth:`~quart.Quart.add_websocket`. An example usage, .. code-block:: python def route(): ... blueprint = Blueprint(__na...
[ "Add", "a", "websocket", "rule", "to", "the", "blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L154-L182
train
pgjones/quart
quart/blueprints.py
Blueprint.endpoint
def endpoint(self, endpoint: str) -> Callable: """Add an endpoint to the blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.endpoint`. An example usage, .. code-block:: python blueprint = Blueprint(__name__) ...
python
def endpoint(self, endpoint: str) -> Callable: """Add an endpoint to the blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.endpoint`. An example usage, .. code-block:: python blueprint = Blueprint(__name__) ...
[ "def", "endpoint", "(", "self", ",", "endpoint", ":", "str", ")", "->", "Callable", ":", "def", "decorator", "(", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "register_endpoi...
Add an endpoint to the blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.endpoint`. An example usage, .. code-block:: python blueprint = Blueprint(__name__) @blueprint.endpoint('index') def index(): ...
[ "Add", "an", "endpoint", "to", "the", "blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L184-L200
train
pgjones/quart
quart/blueprints.py
Blueprint.before_request
def before_request(self, func: Callable) -> Callable: """Add a before request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_request`. It applies only to requests that are routed to an endpoint in this blue...
python
def before_request(self, func: Callable) -> Callable: """Add a before request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_request`. It applies only to requests that are routed to an endpoint in this blue...
[ "def", "before_request", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "before_request", "(", "func", ",", "self", ".", "name", ")", ")", "retur...
Add a before request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_request`. It applies only to requests that are routed to an endpoint in this blueprint. An example usage, .. code-block:: python ...
[ "Add", "a", "before", "request", "function", "to", "the", "Blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L307-L322
train
pgjones/quart
quart/blueprints.py
Blueprint.before_websocket
def before_websocket(self, func: Callable) -> Callable: """Add a before request websocket to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_websocket`. It applies only to requests that are routed to an endpoint in this...
python
def before_websocket(self, func: Callable) -> Callable: """Add a before request websocket to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_websocket`. It applies only to requests that are routed to an endpoint in this...
[ "def", "before_websocket", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "before_websocket", "(", "func", ",", "self", ".", "name", ")", ")", "r...
Add a before request websocket to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_websocket`. It applies only to requests that are routed to an endpoint in this blueprint. An example usage, .. code-block:: python ...
[ "Add", "a", "before", "request", "websocket", "to", "the", "Blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L324-L340
train
pgjones/quart
quart/blueprints.py
Blueprint.before_app_request
def before_app_request(self, func: Callable) -> Callable: """Add a before request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_request`. It applies to all requests to the app this blueprint is registered on. An...
python
def before_app_request(self, func: Callable) -> Callable: """Add a before request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_request`. It applies to all requests to the app this blueprint is registered on. An...
[ "def", "before_app_request", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "before_request", "(", "func", ")", ")", "return", "func" ]
Add a before request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_request`. It applies to all requests to the app this blueprint is registered on. An example usage, .. code-block:: python blueprin...
[ "Add", "a", "before", "request", "function", "to", "the", "app", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L342-L357
train
pgjones/quart
quart/blueprints.py
Blueprint.before_app_websocket
def before_app_websocket(self, func: Callable) -> Callable: """Add a before request websocket to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_websocket`. It applies to all requests to the app this blueprint is registered o...
python
def before_app_websocket(self, func: Callable) -> Callable: """Add a before request websocket to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_websocket`. It applies to all requests to the app this blueprint is registered o...
[ "def", "before_app_websocket", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "before_websocket", "(", "func", ")", ")", "return", "func" ]
Add a before request websocket to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_websocket`. It applies to all requests to the app this blueprint is registered on. An example usage, .. code-block:: python bluep...
[ "Add", "a", "before", "request", "websocket", "to", "the", "App", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L359-L375
train
pgjones/quart
quart/blueprints.py
Blueprint.before_app_first_request
def before_app_first_request(self, func: Callable) -> Callable: """Add a before request first function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_first_request`. It is triggered before the first request to the app thi...
python
def before_app_first_request(self, func: Callable) -> Callable: """Add a before request first function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_first_request`. It is triggered before the first request to the app thi...
[ "def", "before_app_first_request", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "before_first_request", "(", "func", ")", ")", "return", "func" ]
Add a before request first function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.before_first_request`. It is triggered before the first request to the app this blueprint is registered on. An example usage, .. code-bl...
[ "Add", "a", "before", "request", "first", "function", "to", "the", "app", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L377-L394
train
pgjones/quart
quart/blueprints.py
Blueprint.after_request
def after_request(self, func: Callable) -> Callable: """Add an after request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_request`. It applies only to requests that are routed to an endpoint in this bluepr...
python
def after_request(self, func: Callable) -> Callable: """Add an after request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_request`. It applies only to requests that are routed to an endpoint in this bluepr...
[ "def", "after_request", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "after_request", "(", "func", ",", "self", ".", "name", ")", ")", "return"...
Add an after request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_request`. It applies only to requests that are routed to an endpoint in this blueprint. An example usage, .. code-block:: python ...
[ "Add", "an", "after", "request", "function", "to", "the", "Blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L396-L411
train
pgjones/quart
quart/blueprints.py
Blueprint.after_websocket
def after_websocket(self, func: Callable) -> Callable: """Add an after websocket function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_websocket`. It applies only to requests that are routed to an endpoint in this ...
python
def after_websocket(self, func: Callable) -> Callable: """Add an after websocket function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_websocket`. It applies only to requests that are routed to an endpoint in this ...
[ "def", "after_websocket", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "after_websocket", "(", "func", ",", "self", ".", "name", ")", ")", "ret...
Add an after websocket function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_websocket`. It applies only to requests that are routed to an endpoint in this blueprint. An example usage, .. code-block:: python ...
[ "Add", "an", "after", "websocket", "function", "to", "the", "Blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L413-L428
train
pgjones/quart
quart/blueprints.py
Blueprint.after_app_request
def after_app_request(self, func: Callable) -> Callable: """Add a after request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_request`. It applies to all requests to the app this blueprint is registered on. An ex...
python
def after_app_request(self, func: Callable) -> Callable: """Add a after request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_request`. It applies to all requests to the app this blueprint is registered on. An ex...
[ "def", "after_app_request", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "after_request", "(", "func", ")", ")", "return", "func" ]
Add a after request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_request`. It applies to all requests to the app this blueprint is registered on. An example usage, .. code-block:: python blueprint ...
[ "Add", "a", "after", "request", "function", "to", "the", "app", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L430-L445
train
pgjones/quart
quart/blueprints.py
Blueprint.after_app_websocket
def after_app_websocket(self, func: Callable) -> Callable: """Add an after websocket function to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_websocket`. It applies to all requests to the ppe this blueprint is registerd on....
python
def after_app_websocket(self, func: Callable) -> Callable: """Add an after websocket function to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_websocket`. It applies to all requests to the ppe this blueprint is registerd on....
[ "def", "after_app_websocket", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "after_websocket", "(", "func", ")", ")", "return", "func" ]
Add an after websocket function to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.after_websocket`. It applies to all requests to the ppe this blueprint is registerd on. An example usage, .. code-block:: python bluepr...
[ "Add", "an", "after", "websocket", "function", "to", "the", "App", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L447-L462
train
pgjones/quart
quart/blueprints.py
Blueprint.teardown_request
def teardown_request(self, func: Callable) -> Callable: """Add a teardown request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_request`. It applies only to requests that are routed to an endpoint in thi...
python
def teardown_request(self, func: Callable) -> Callable: """Add a teardown request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_request`. It applies only to requests that are routed to an endpoint in thi...
[ "def", "teardown_request", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "teardown_request", "(", "func", ",", "self", ".", "name", ")", ")", "r...
Add a teardown request function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_request`. It applies only to requests that are routed to an endpoint in this blueprint. An example usage, .. code-block:: python ...
[ "Add", "a", "teardown", "request", "function", "to", "the", "Blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L464-L479
train
pgjones/quart
quart/blueprints.py
Blueprint.teardown_websocket
def teardown_websocket(self, func: Callable) -> Callable: """Add a teardown websocket function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_websocket`. It applies only to requests that are routed to an endpoint ...
python
def teardown_websocket(self, func: Callable) -> Callable: """Add a teardown websocket function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_websocket`. It applies only to requests that are routed to an endpoint ...
[ "def", "teardown_websocket", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "teardown_websocket", "(", "func", ",", "self", ".", "name", ")", ")", ...
Add a teardown websocket function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_websocket`. It applies only to requests that are routed to an endpoint in this blueprint. An example usage, .. code-block::...
[ "Add", "a", "teardown", "websocket", "function", "to", "the", "Blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L481-L498
train
pgjones/quart
quart/blueprints.py
Blueprint.teardown_app_request
def teardown_app_request(self, func: Callable) -> Callable: """Add a teardown request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_request`. It applies to all requests to the app this blueprint is registered ...
python
def teardown_app_request(self, func: Callable) -> Callable: """Add a teardown request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_request`. It applies to all requests to the app this blueprint is registered ...
[ "def", "teardown_app_request", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "teardown_request", "(", "func", ")", ")", "return", "func" ]
Add a teardown request function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.teardown_request`. It applies to all requests to the app this blueprint is registered on. An example usage, .. code-block:: python ...
[ "Add", "a", "teardown", "request", "function", "to", "the", "app", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L500-L516
train
pgjones/quart
quart/blueprints.py
Blueprint.errorhandler
def errorhandler(self, error: Union[Type[Exception], int]) -> Callable: """Add an error handler function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.errorhandler`. It applies only to errors that originate in routes in t...
python
def errorhandler(self, error: Union[Type[Exception], int]) -> Callable: """Add an error handler function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.errorhandler`. It applies only to errors that originate in routes in t...
[ "def", "errorhandler", "(", "self", ",", "error", ":", "Union", "[", "Type", "[", "Exception", "]", ",", "int", "]", ")", "->", "Callable", ":", "def", "decorator", "(", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "register_error_...
Add an error handler function to the Blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.errorhandler`. It applies only to errors that originate in routes in this blueprint. An example usage, .. code-block:: python ...
[ "Add", "an", "error", "handler", "function", "to", "the", "Blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L518-L537
train
pgjones/quart
quart/blueprints.py
Blueprint.app_errorhandler
def app_errorhandler(self, error: Union[Type[Exception], int]) -> Callable: """Add an error handler function to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.errorhandler`. It applies only to all errors. An example usage, ...
python
def app_errorhandler(self, error: Union[Type[Exception], int]) -> Callable: """Add an error handler function to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.errorhandler`. It applies only to all errors. An example usage, ...
[ "def", "app_errorhandler", "(", "self", ",", "error", ":", "Union", "[", "Type", "[", "Exception", "]", ",", "int", "]", ")", "->", "Callable", ":", "def", "decorator", "(", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once...
Add an error handler function to the App. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.errorhandler`. It applies only to all errors. An example usage, .. code-block:: python blueprint = Blueprint(__name__) @bluep...
[ "Add", "an", "error", "handler", "function", "to", "the", "App", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L539-L556
train
pgjones/quart
quart/blueprints.py
Blueprint.register_error_handler
def register_error_handler(self, error: Union[Type[Exception], int], func: Callable) -> None: """Add an error handler function to the blueprint. This is designed to be used on the blueprint directly, and has the same arguments as :meth:`~quart.Quart.register_error_handler`. An example u...
python
def register_error_handler(self, error: Union[Type[Exception], int], func: Callable) -> None: """Add an error handler function to the blueprint. This is designed to be used on the blueprint directly, and has the same arguments as :meth:`~quart.Quart.register_error_handler`. An example u...
[ "def", "register_error_handler", "(", "self", ",", "error", ":", "Union", "[", "Type", "[", "Exception", "]", ",", "int", "]", ",", "func", ":", "Callable", ")", "->", "None", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", ...
Add an error handler function to the blueprint. This is designed to be used on the blueprint directly, and has the same arguments as :meth:`~quart.Quart.register_error_handler`. An example usage, .. code-block:: python def not_found(): ... blue...
[ "Add", "an", "error", "handler", "function", "to", "the", "blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L558-L573
train
pgjones/quart
quart/blueprints.py
Blueprint.context_processor
def context_processor(self, func: Callable) -> Callable: """Add a context processor function to this blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.context_processor`. This will add context to all templates rendered in this bluep...
python
def context_processor(self, func: Callable) -> Callable: """Add a context processor function to this blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.context_processor`. This will add context to all templates rendered in this bluep...
[ "def", "context_processor", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "context_processor", "(", "func", ",", "self", ".", "name", ")", ")", ...
Add a context processor function to this blueprint. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.context_processor`. This will add context to all templates rendered in this blueprint's routes. An example usage, .. code-block:: py...
[ "Add", "a", "context", "processor", "function", "to", "this", "blueprint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L575-L591
train
pgjones/quart
quart/blueprints.py
Blueprint.app_context_processor
def app_context_processor(self, func: Callable) -> Callable: """Add a context processor function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.context_processor`. This will add context to all templates rendered. An example usag...
python
def app_context_processor(self, func: Callable) -> Callable: """Add a context processor function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.context_processor`. This will add context to all templates rendered. An example usag...
[ "def", "app_context_processor", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "record_once", "(", "lambda", "state", ":", "state", ".", "app", ".", "context_processor", "(", "func", ")", ")", "return", "func" ]
Add a context processor function to the app. This is designed to be used as a decorator, and has the same arguments as :meth:`~quart.Quart.context_processor`. This will add context to all templates rendered. An example usage, .. code-block:: python blueprint = Blueprint(__...
[ "Add", "a", "context", "processor", "function", "to", "the", "app", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L593-L608
train
pgjones/quart
quart/blueprints.py
Blueprint.record_once
def record_once(self, func: DeferedSetupFunction) -> None: """Used to register a deferred action that happens only once.""" def wrapper(state: 'BlueprintSetupState') -> None: if state.first_registration: func(state) self.record(update_wrapper(wrapper, func))
python
def record_once(self, func: DeferedSetupFunction) -> None: """Used to register a deferred action that happens only once.""" def wrapper(state: 'BlueprintSetupState') -> None: if state.first_registration: func(state) self.record(update_wrapper(wrapper, func))
[ "def", "record_once", "(", "self", ",", "func", ":", "DeferedSetupFunction", ")", "->", "None", ":", "def", "wrapper", "(", "state", ":", "'BlueprintSetupState'", ")", "->", "None", ":", "if", "state", ".", "first_registration", ":", "func", "(", "state", ...
Used to register a deferred action that happens only once.
[ "Used", "to", "register", "a", "deferred", "action", "that", "happens", "only", "once", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L687-L692
train
pgjones/quart
quart/blueprints.py
Blueprint.register
def register( self, app: 'Quart', first_registration: bool, *, url_prefix: Optional[str]=None, ) -> None: """Register this blueprint on the app given.""" state = self.make_setup_state(app, first_registration, url_prefix=url_prefix) ...
python
def register( self, app: 'Quart', first_registration: bool, *, url_prefix: Optional[str]=None, ) -> None: """Register this blueprint on the app given.""" state = self.make_setup_state(app, first_registration, url_prefix=url_prefix) ...
[ "def", "register", "(", "self", ",", "app", ":", "'Quart'", ",", "first_registration", ":", "bool", ",", "*", ",", "url_prefix", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "None", ":", "state", "=", "self", ".", "make_setup_state", ...
Register this blueprint on the app given.
[ "Register", "this", "blueprint", "on", "the", "app", "given", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L694-L711
train
pgjones/quart
quart/blueprints.py
Blueprint.make_setup_state
def make_setup_state( self, app: 'Quart', first_registration: bool, *, url_prefix: Optional[str]=None, ) -> 'BlueprintSetupState': """Return a blueprint setup state instance. Arguments: first_registration: True if this is the f...
python
def make_setup_state( self, app: 'Quart', first_registration: bool, *, url_prefix: Optional[str]=None, ) -> 'BlueprintSetupState': """Return a blueprint setup state instance. Arguments: first_registration: True if this is the f...
[ "def", "make_setup_state", "(", "self", ",", "app", ":", "'Quart'", ",", "first_registration", ":", "bool", ",", "*", ",", "url_prefix", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "'BlueprintSetupState'", ":", "return", "BlueprintSetupSta...
Return a blueprint setup state instance. Arguments: first_registration: True if this is the first registration of this blueprint on the app. url_prefix: An optional prefix to all rules
[ "Return", "a", "blueprint", "setup", "state", "instance", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L713-L727
train
pgjones/quart
quart/datastructures.py
_WerkzeugMultidictMixin.to_dict
def to_dict(self, flat: bool=True) -> Dict[Any, Any]: """Convert the multidict to a plain dictionary. Arguments: flat: If True only return the a value for each key, if False return all values as lists. """ if flat: return {key: value for key, val...
python
def to_dict(self, flat: bool=True) -> Dict[Any, Any]: """Convert the multidict to a plain dictionary. Arguments: flat: If True only return the a value for each key, if False return all values as lists. """ if flat: return {key: value for key, val...
[ "def", "to_dict", "(", "self", ",", "flat", ":", "bool", "=", "True", ")", "->", "Dict", "[", "Any", ",", "Any", "]", ":", "if", "flat", ":", "return", "{", "key", ":", "value", "for", "key", ",", "value", "in", "self", ".", "items", "(", ")", ...
Convert the multidict to a plain dictionary. Arguments: flat: If True only return the a value for each key, if False return all values as lists.
[ "Convert", "the", "multidict", "to", "a", "plain", "dictionary", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/datastructures.py#L42-L53
train
pgjones/quart
quart/datastructures.py
FileStorage.save
def save(self, destination: BinaryIO, buffer_size: int=16384) -> None: """Save the file to the destination. Arguments: destination: A filename (str) or file object to write to. buffer_size: Buffer size as used as length in :func:`shutil.copyfileobj`. """ ...
python
def save(self, destination: BinaryIO, buffer_size: int=16384) -> None: """Save the file to the destination. Arguments: destination: A filename (str) or file object to write to. buffer_size: Buffer size as used as length in :func:`shutil.copyfileobj`. """ ...
[ "def", "save", "(", "self", ",", "destination", ":", "BinaryIO", ",", "buffer_size", ":", "int", "=", "16384", ")", "->", "None", ":", "close_destination", "=", "False", "if", "isinstance", "(", "destination", ",", "str", ")", ":", "destination", "=", "o...
Save the file to the destination. Arguments: destination: A filename (str) or file object to write to. buffer_size: Buffer size as used as length in :func:`shutil.copyfileobj`.
[ "Save", "the", "file", "to", "the", "destination", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/datastructures.py#L136-L152
train
pgjones/quart
quart/wrappers/request.py
Request.get_data
async def get_data(self, raw: bool=True) -> AnyStr: """The request body data.""" try: body_future = asyncio.ensure_future(self.body) raw_data = await asyncio.wait_for(body_future, timeout=self.body_timeout) except asyncio.TimeoutError: body_future.cancel() ...
python
async def get_data(self, raw: bool=True) -> AnyStr: """The request body data.""" try: body_future = asyncio.ensure_future(self.body) raw_data = await asyncio.wait_for(body_future, timeout=self.body_timeout) except asyncio.TimeoutError: body_future.cancel() ...
[ "async", "def", "get_data", "(", "self", ",", "raw", ":", "bool", "=", "True", ")", "->", "AnyStr", ":", "try", ":", "body_future", "=", "asyncio", ".", "ensure_future", "(", "self", ".", "body", ")", "raw_data", "=", "await", "asyncio", ".", "wait_for...
The request body data.
[ "The", "request", "body", "data", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/request.py#L158-L171
train
pgjones/quart
quart/wrappers/request.py
Websocket.accept
async def accept( self, headers: Optional[Union[dict, CIMultiDict, Headers]] = None, subprotocol: Optional[str] = None, ) -> None: """Manually chose to accept the websocket connection. Arguments: headers: Additional headers to send with the acceptance...
python
async def accept( self, headers: Optional[Union[dict, CIMultiDict, Headers]] = None, subprotocol: Optional[str] = None, ) -> None: """Manually chose to accept the websocket connection. Arguments: headers: Additional headers to send with the acceptance...
[ "async", "def", "accept", "(", "self", ",", "headers", ":", "Optional", "[", "Union", "[", "dict", ",", "CIMultiDict", ",", "Headers", "]", "]", "=", "None", ",", "subprotocol", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "None", ...
Manually chose to accept the websocket connection. Arguments: headers: Additional headers to send with the acceptance response. subprotocol: The chosen subprotocol, optional.
[ "Manually", "chose", "to", "accept", "the", "websocket", "connection", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/request.py#L326-L342
train
pgjones/quart
quart/logging.py
create_logger
def create_logger(app: 'Quart') -> Logger: """Create a logger for the app based on the app settings. This creates a logger named quart.app that has a log level based on the app configuration. """ logger = getLogger('quart.app') if app.debug and logger.level == NOTSET: logger.setLevel(D...
python
def create_logger(app: 'Quart') -> Logger: """Create a logger for the app based on the app settings. This creates a logger named quart.app that has a log level based on the app configuration. """ logger = getLogger('quart.app') if app.debug and logger.level == NOTSET: logger.setLevel(D...
[ "def", "create_logger", "(", "app", ":", "'Quart'", ")", "->", "Logger", ":", "logger", "=", "getLogger", "(", "'quart.app'", ")", "if", "app", ".", "debug", "and", "logger", ".", "level", "==", "NOTSET", ":", "logger", ".", "setLevel", "(", "DEBUG", "...
Create a logger for the app based on the app settings. This creates a logger named quart.app that has a log level based on the app configuration.
[ "Create", "a", "logger", "for", "the", "app", "based", "on", "the", "app", "settings", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/logging.py#L15-L27
train
pgjones/quart
quart/logging.py
create_serving_logger
def create_serving_logger() -> Logger: """Create a logger for serving. This creates a logger named quart.serving. """ logger = getLogger('quart.serving') if logger.level == NOTSET: logger.setLevel(INFO) logger.addHandler(serving_handler) return logger
python
def create_serving_logger() -> Logger: """Create a logger for serving. This creates a logger named quart.serving. """ logger = getLogger('quart.serving') if logger.level == NOTSET: logger.setLevel(INFO) logger.addHandler(serving_handler) return logger
[ "def", "create_serving_logger", "(", ")", "->", "Logger", ":", "logger", "=", "getLogger", "(", "'quart.serving'", ")", "if", "logger", ".", "level", "==", "NOTSET", ":", "logger", ".", "setLevel", "(", "INFO", ")", "logger", ".", "addHandler", "(", "servi...
Create a logger for serving. This creates a logger named quart.serving.
[ "Create", "a", "logger", "for", "serving", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/logging.py#L30-L41
train
pgjones/quart
quart/utils.py
create_cookie
def create_cookie( key: str, value: str='', max_age: Optional[Union[int, timedelta]]=None, expires: Optional[Union[int, float, datetime]]=None, path: str='/', domain: Optional[str]=None, secure: bool=False, httponly: bool=False, ) -> SimpleCookie: """C...
python
def create_cookie( key: str, value: str='', max_age: Optional[Union[int, timedelta]]=None, expires: Optional[Union[int, float, datetime]]=None, path: str='/', domain: Optional[str]=None, secure: bool=False, httponly: bool=False, ) -> SimpleCookie: """C...
[ "def", "create_cookie", "(", "key", ":", "str", ",", "value", ":", "str", "=", "''", ",", "max_age", ":", "Optional", "[", "Union", "[", "int", ",", "timedelta", "]", "]", "=", "None", ",", "expires", ":", "Optional", "[", "Union", "[", "int", ",",...
Create a Cookie given the options set The arguments are the standard cookie morsels and this is a wrapper around the stdlib SimpleCookie code.
[ "Create", "a", "Cookie", "given", "the", "options", "set" ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/utils.py#L29-L59
train
pgjones/quart
quart/app.py
Quart.name
def name(self) -> str: """The name of this application. This is taken from the :attr:`import_name` and is used for debugging purposes. """ if self.import_name == '__main__': path = Path(getattr(sys.modules['__main__'], '__file__', '__main__.py')) return p...
python
def name(self) -> str: """The name of this application. This is taken from the :attr:`import_name` and is used for debugging purposes. """ if self.import_name == '__main__': path = Path(getattr(sys.modules['__main__'], '__file__', '__main__.py')) return p...
[ "def", "name", "(", "self", ")", "->", "str", ":", "if", "self", ".", "import_name", "==", "'__main__'", ":", "path", "=", "Path", "(", "getattr", "(", "sys", ".", "modules", "[", "'__main__'", "]", ",", "'__file__'", ",", "'__main__.py'", ")", ")", ...
The name of this application. This is taken from the :attr:`import_name` and is used for debugging purposes.
[ "The", "name", "of", "this", "application", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L223-L232
train
pgjones/quart
quart/app.py
Quart.jinja_env
def jinja_env(self) -> Environment: """The jinja environment used to load templates.""" if self._jinja_env is None: self._jinja_env = self.create_jinja_environment() return self._jinja_env
python
def jinja_env(self) -> Environment: """The jinja environment used to load templates.""" if self._jinja_env is None: self._jinja_env = self.create_jinja_environment() return self._jinja_env
[ "def", "jinja_env", "(", "self", ")", "->", "Environment", ":", "if", "self", ".", "_jinja_env", "is", "None", ":", "self", ".", "_jinja_env", "=", "self", ".", "create_jinja_environment", "(", ")", "return", "self", ".", "_jinja_env" ]
The jinja environment used to load templates.
[ "The", "jinja", "environment", "used", "to", "load", "templates", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L261-L265
train
pgjones/quart
quart/app.py
Quart.auto_find_instance_path
def auto_find_instance_path(self) -> Path: """Locates the instace_path if it was not provided """ prefix, package_path = find_package(self.import_name) if prefix is None: return package_path / "instance" return prefix / "var" / f"{self.name}-instance"
python
def auto_find_instance_path(self) -> Path: """Locates the instace_path if it was not provided """ prefix, package_path = find_package(self.import_name) if prefix is None: return package_path / "instance" return prefix / "var" / f"{self.name}-instance"
[ "def", "auto_find_instance_path", "(", "self", ")", "->", "Path", ":", "prefix", ",", "package_path", "=", "find_package", "(", "self", ".", "import_name", ")", "if", "prefix", "is", "None", ":", "return", "package_path", "/", "\"instance\"", "return", "prefix...
Locates the instace_path if it was not provided
[ "Locates", "the", "instace_path", "if", "it", "was", "not", "provided" ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L272-L278
train
pgjones/quart
quart/app.py
Quart.make_config
def make_config(self, instance_relative: bool = False) -> Config: """Create and return the configuration with appropriate defaults.""" config = self.config_class( self.instance_path if instance_relative else self.root_path, DEFAULT_CONFIG, ) config['ENV'] = get_en...
python
def make_config(self, instance_relative: bool = False) -> Config: """Create and return the configuration with appropriate defaults.""" config = self.config_class( self.instance_path if instance_relative else self.root_path, DEFAULT_CONFIG, ) config['ENV'] = get_en...
[ "def", "make_config", "(", "self", ",", "instance_relative", ":", "bool", "=", "False", ")", "->", "Config", ":", "config", "=", "self", ".", "config_class", "(", "self", ".", "instance_path", "if", "instance_relative", "else", "self", ".", "root_path", ",",...
Create and return the configuration with appropriate defaults.
[ "Create", "and", "return", "the", "configuration", "with", "appropriate", "defaults", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L280-L288
train
pgjones/quart
quart/app.py
Quart.create_url_adapter
def create_url_adapter(self, request: Optional[BaseRequestWebsocket]) -> Optional[MapAdapter]: """Create and return a URL adapter. This will create the adapter based on the request if present otherwise the app configuration. """ if request is not None: host = request...
python
def create_url_adapter(self, request: Optional[BaseRequestWebsocket]) -> Optional[MapAdapter]: """Create and return a URL adapter. This will create the adapter based on the request if present otherwise the app configuration. """ if request is not None: host = request...
[ "def", "create_url_adapter", "(", "self", ",", "request", ":", "Optional", "[", "BaseRequestWebsocket", "]", ")", "->", "Optional", "[", "MapAdapter", "]", ":", "if", "request", "is", "not", "None", ":", "host", "=", "request", ".", "host", "return", "self...
Create and return a URL adapter. This will create the adapter based on the request if present otherwise the app configuration.
[ "Create", "and", "return", "a", "URL", "adapter", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L302-L318
train
pgjones/quart
quart/app.py
Quart.create_jinja_environment
def create_jinja_environment(self) -> Environment: """Create and return the jinja environment. This will create the environment based on the :attr:`jinja_options` and configuration settings. The environment will include the Quart globals by default. """ options = dict(se...
python
def create_jinja_environment(self) -> Environment: """Create and return the jinja environment. This will create the environment based on the :attr:`jinja_options` and configuration settings. The environment will include the Quart globals by default. """ options = dict(se...
[ "def", "create_jinja_environment", "(", "self", ")", "->", "Environment", ":", "options", "=", "dict", "(", "self", ".", "jinja_options", ")", "if", "'autoescape'", "not", "in", "options", ":", "options", "[", "'autoescape'", "]", "=", "self", ".", "select_j...
Create and return the jinja environment. This will create the environment based on the :attr:`jinja_options` and configuration settings. The environment will include the Quart globals by default.
[ "Create", "and", "return", "the", "jinja", "environment", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L320-L342
train
pgjones/quart
quart/app.py
Quart.select_jinja_autoescape
def select_jinja_autoescape(self, filename: str) -> bool: """Returns True if the filename indicates that it should be escaped.""" if filename is None: return True return Path(filename).suffix in {'.htm', '.html', '.xhtml', '.xml'}
python
def select_jinja_autoescape(self, filename: str) -> bool: """Returns True if the filename indicates that it should be escaped.""" if filename is None: return True return Path(filename).suffix in {'.htm', '.html', '.xhtml', '.xml'}
[ "def", "select_jinja_autoescape", "(", "self", ",", "filename", ":", "str", ")", "->", "bool", ":", "if", "filename", "is", "None", ":", "return", "True", "return", "Path", "(", "filename", ")", ".", "suffix", "in", "{", "'.htm'", ",", "'.html'", ",", ...
Returns True if the filename indicates that it should be escaped.
[ "Returns", "True", "if", "the", "filename", "indicates", "that", "it", "should", "be", "escaped", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L348-L352
train
pgjones/quart
quart/app.py
Quart.update_template_context
async def update_template_context(self, context: dict) -> None: """Update the provided template context. This adds additional context from the various template context processors. Arguments: context: The context to update (mutate). """ processors = self.temp...
python
async def update_template_context(self, context: dict) -> None: """Update the provided template context. This adds additional context from the various template context processors. Arguments: context: The context to update (mutate). """ processors = self.temp...
[ "async", "def", "update_template_context", "(", "self", ",", "context", ":", "dict", ")", "->", "None", ":", "processors", "=", "self", ".", "template_context_processors", "[", "None", "]", "if", "has_request_context", "(", ")", ":", "blueprint", "=", "_reques...
Update the provided template context. This adds additional context from the various template context processors. Arguments: context: The context to update (mutate).
[ "Update", "the", "provided", "template", "context", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L354-L373
train
pgjones/quart
quart/app.py
Quart.make_shell_context
def make_shell_context(self) -> dict: """Create a context for interactive shell usage. The :attr:`shell_context_processors` can be used to add additional context. """ context = {'app': self, 'g': g} for processor in self.shell_context_processors: context.upda...
python
def make_shell_context(self) -> dict: """Create a context for interactive shell usage. The :attr:`shell_context_processors` can be used to add additional context. """ context = {'app': self, 'g': g} for processor in self.shell_context_processors: context.upda...
[ "def", "make_shell_context", "(", "self", ")", "->", "dict", ":", "context", "=", "{", "'app'", ":", "self", ",", "'g'", ":", "g", "}", "for", "processor", "in", "self", ".", "shell_context_processors", ":", "context", ".", "update", "(", "processor", "(...
Create a context for interactive shell usage. The :attr:`shell_context_processors` can be used to add additional context.
[ "Create", "a", "context", "for", "interactive", "shell", "usage", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L375-L384
train
pgjones/quart
quart/app.py
Quart.endpoint
def endpoint(self, endpoint: str) -> Callable: """Register a function as an endpoint. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.endpoint('name') def endpoint(): ... Arguments: endpoint...
python
def endpoint(self, endpoint: str) -> Callable: """Register a function as an endpoint. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.endpoint('name') def endpoint(): ... Arguments: endpoint...
[ "def", "endpoint", "(", "self", ",", "endpoint", ":", "str", ")", "->", "Callable", ":", "def", "decorator", "(", "func", ":", "Callable", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "view_functions", "[...
Register a function as an endpoint. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.endpoint('name') def endpoint(): ... Arguments: endpoint: The endpoint name to use.
[ "Register", "a", "function", "as", "an", "endpoint", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L638-L656
train
pgjones/quart
quart/app.py
Quart.register_error_handler
def register_error_handler( self, error: Union[Type[Exception], int], func: Callable, name: AppOrBlueprintKey=None, ) -> None: """Register a function as an error handler. This is designed to be used on the application directly. An example usage, .. code-block:: python ...
python
def register_error_handler( self, error: Union[Type[Exception], int], func: Callable, name: AppOrBlueprintKey=None, ) -> None: """Register a function as an error handler. This is designed to be used on the application directly. An example usage, .. code-block:: python ...
[ "def", "register_error_handler", "(", "self", ",", "error", ":", "Union", "[", "Type", "[", "Exception", "]", ",", "int", "]", ",", "func", ":", "Callable", ",", "name", ":", "AppOrBlueprintKey", "=", "None", ",", ")", "->", "None", ":", "handler", "="...
Register a function as an error handler. This is designed to be used on the application directly. An example usage, .. code-block:: python def error_handler(): return "Error", 500 app.register_error_handler(500, error_handler) Arguments: ...
[ "Register", "a", "function", "as", "an", "error", "handler", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L677-L700
train
pgjones/quart
quart/app.py
Quart.context_processor
def context_processor(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a template context processor. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.context_processor def update_context(context): ...
python
def context_processor(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a template context processor. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.context_processor def update_context(context): ...
[ "def", "context_processor", "(", "self", ",", "func", ":", "Callable", ",", "name", ":", "AppOrBlueprintKey", "=", "None", ")", "->", "Callable", ":", "self", ".", "template_context_processors", "[", "name", "]", ".", "append", "(", "ensure_coroutine", "(", ...
Add a template context processor. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.context_processor def update_context(context): return context
[ "Add", "a", "template", "context", "processor", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L816-L829
train
pgjones/quart
quart/app.py
Quart.shell_context_processor
def shell_context_processor(self, func: Callable) -> Callable: """Add a shell context processor. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.shell_context_processor def additional_context(): return context ...
python
def shell_context_processor(self, func: Callable) -> Callable: """Add a shell context processor. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.shell_context_processor def additional_context(): return context ...
[ "def", "shell_context_processor", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "self", ".", "shell_context_processors", ".", "append", "(", "func", ")", "return", "func" ]
Add a shell context processor. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.shell_context_processor def additional_context(): return context
[ "Add", "a", "shell", "context", "processor", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L831-L844
train
pgjones/quart
quart/app.py
Quart.inject_url_defaults
def inject_url_defaults(self, endpoint: str, values: dict) -> None: """Injects default URL values into the passed values dict. This is used to assist when building urls, see :func:`~quart.helpers.url_for`. """ functions = self.url_value_preprocessors[None] if '.' in endp...
python
def inject_url_defaults(self, endpoint: str, values: dict) -> None: """Injects default URL values into the passed values dict. This is used to assist when building urls, see :func:`~quart.helpers.url_for`. """ functions = self.url_value_preprocessors[None] if '.' in endp...
[ "def", "inject_url_defaults", "(", "self", ",", "endpoint", ":", "str", ",", "values", ":", "dict", ")", "->", "None", ":", "functions", "=", "self", ".", "url_value_preprocessors", "[", "None", "]", "if", "'.'", "in", "endpoint", ":", "blueprint", "=", ...
Injects default URL values into the passed values dict. This is used to assist when building urls, see :func:`~quart.helpers.url_for`.
[ "Injects", "default", "URL", "values", "into", "the", "passed", "values", "dict", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L874-L886
train
pgjones/quart
quart/app.py
Quart.handle_url_build_error
def handle_url_build_error(self, error: Exception, endpoint: str, values: dict) -> str: """Handle a build error. Ideally this will return a valid url given the error endpoint and values. """ for handler in self.url_build_error_handlers: result = handler(error, endpoi...
python
def handle_url_build_error(self, error: Exception, endpoint: str, values: dict) -> str: """Handle a build error. Ideally this will return a valid url given the error endpoint and values. """ for handler in self.url_build_error_handlers: result = handler(error, endpoi...
[ "def", "handle_url_build_error", "(", "self", ",", "error", ":", "Exception", ",", "endpoint", ":", "str", ",", "values", ":", "dict", ")", "->", "str", ":", "for", "handler", "in", "self", ".", "url_build_error_handlers", ":", "result", "=", "handler", "(...
Handle a build error. Ideally this will return a valid url given the error endpoint and values.
[ "Handle", "a", "build", "error", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L888-L898
train
pgjones/quart
quart/app.py
Quart.handle_http_exception
async def handle_http_exception(self, error: Exception) -> Response: """Handle a HTTPException subclass error. This will attempt to find a handler for the error and if fails will fall back to the error response. """ handler = self._find_exception_handler(error) if handle...
python
async def handle_http_exception(self, error: Exception) -> Response: """Handle a HTTPException subclass error. This will attempt to find a handler for the error and if fails will fall back to the error response. """ handler = self._find_exception_handler(error) if handle...
[ "async", "def", "handle_http_exception", "(", "self", ",", "error", ":", "Exception", ")", "->", "Response", ":", "handler", "=", "self", ".", "_find_exception_handler", "(", "error", ")", "if", "handler", "is", "None", ":", "return", "error", ".", "get_resp...
Handle a HTTPException subclass error. This will attempt to find a handler for the error and if fails will fall back to the error response.
[ "Handle", "a", "HTTPException", "subclass", "error", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L914-L924
train
pgjones/quart
quart/app.py
Quart.handle_user_exception
async def handle_user_exception(self, error: Exception) -> Response: """Handle an exception that has been raised. This should forward :class:`~quart.exception.HTTPException` to :meth:`handle_http_exception`, then attempt to handle the error. If it cannot it should reraise the error. ...
python
async def handle_user_exception(self, error: Exception) -> Response: """Handle an exception that has been raised. This should forward :class:`~quart.exception.HTTPException` to :meth:`handle_http_exception`, then attempt to handle the error. If it cannot it should reraise the error. ...
[ "async", "def", "handle_user_exception", "(", "self", ",", "error", ":", "Exception", ")", "->", "Response", ":", "if", "isinstance", "(", "error", ",", "HTTPException", ")", "and", "not", "self", ".", "trap_http_exception", "(", "error", ")", ":", "return",...
Handle an exception that has been raised. This should forward :class:`~quart.exception.HTTPException` to :meth:`handle_http_exception`, then attempt to handle the error. If it cannot it should reraise the error.
[ "Handle", "an", "exception", "that", "has", "been", "raised", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L936-L949
train
pgjones/quart
quart/app.py
Quart.before_request
def before_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a before request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_request def func(): ... Argum...
python
def before_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a before request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_request def func(): ... Argum...
[ "def", "before_request", "(", "self", ",", "func", ":", "Callable", ",", "name", ":", "AppOrBlueprintKey", "=", "None", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "before_request_funcs", "[", "name", "]", ...
Add a before request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_request def func(): ... Arguments: func: The before request function itself. name: Optional blueprin...
[ "Add", "a", "before", "request", "function", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1007-L1024
train
pgjones/quart
quart/app.py
Quart.before_websocket
def before_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a before websocket function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_websocket def func(): ... ...
python
def before_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a before websocket function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_websocket def func(): ... ...
[ "def", "before_websocket", "(", "self", ",", "func", ":", "Callable", ",", "name", ":", "AppOrBlueprintKey", "=", "None", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "before_websocket_funcs", "[", "name", "]...
Add a before websocket function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_websocket def func(): ... Arguments: func: The before websocket function itself. name: Optional bl...
[ "Add", "a", "before", "websocket", "function", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1026-L1043
train
pgjones/quart
quart/app.py
Quart.before_serving
def before_serving(self, func: Callable) -> Callable: """Add a before serving function. This will allow the function provided to be called once before anything is served (before any byte is received). This is designed to be used as a decorator. An example usage, .. code-block:...
python
def before_serving(self, func: Callable) -> Callable: """Add a before serving function. This will allow the function provided to be called once before anything is served (before any byte is received). This is designed to be used as a decorator. An example usage, .. code-block:...
[ "def", "before_serving", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "before_serving_funcs", ".", "append", "(", "handler", ")", "return", "func" ]
Add a before serving function. This will allow the function provided to be called once before anything is served (before any byte is received). This is designed to be used as a decorator. An example usage, .. code-block:: python @app.before_serving def func():...
[ "Add", "a", "before", "serving", "function", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1064-L1083
train
pgjones/quart
quart/app.py
Quart.after_request
def after_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add an after request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.after_request def func(response): return respo...
python
def after_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add an after request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.after_request def func(response): return respo...
[ "def", "after_request", "(", "self", ",", "func", ":", "Callable", ",", "name", ":", "AppOrBlueprintKey", "=", "None", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "after_request_funcs", "[", "name", "]", "...
Add an after request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.after_request def func(response): return response Arguments: func: The after request function itself. name:...
[ "Add", "an", "after", "request", "function", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1085-L1102
train
pgjones/quart
quart/app.py
Quart.after_websocket
def after_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add an after websocket function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.after_websocket def func(response): return...
python
def after_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add an after websocket function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.after_websocket def func(response): return...
[ "def", "after_websocket", "(", "self", ",", "func", ":", "Callable", ",", "name", ":", "AppOrBlueprintKey", "=", "None", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "after_websocket_funcs", "[", "name", "]",...
Add an after websocket function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.after_websocket def func(response): return response Arguments: func: The after websocket function itself. ...
[ "Add", "an", "after", "websocket", "function", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1104-L1121
train
pgjones/quart
quart/app.py
Quart.after_serving
def after_serving(self, func: Callable) -> Callable: """Add a after serving function. This will allow the function provided to be called once after anything is served (after last byte is sent). This is designed to be used as a decorator. An example usage, .. code-block:: pytho...
python
def after_serving(self, func: Callable) -> Callable: """Add a after serving function. This will allow the function provided to be called once after anything is served (after last byte is sent). This is designed to be used as a decorator. An example usage, .. code-block:: pytho...
[ "def", "after_serving", "(", "self", ",", "func", ":", "Callable", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "after_serving_funcs", ".", "append", "(", "handler", ")", "return", "func" ]
Add a after serving function. This will allow the function provided to be called once after anything is served (after last byte is sent). This is designed to be used as a decorator. An example usage, .. code-block:: python @app.after_serving def func(): ...
[ "Add", "a", "after", "serving", "function", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1123-L1143
train
pgjones/quart
quart/app.py
Quart.teardown_request
def teardown_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a teardown request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.teardown_request def func(): ... ...
python
def teardown_request(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable: """Add a teardown request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.teardown_request def func(): ... ...
[ "def", "teardown_request", "(", "self", ",", "func", ":", "Callable", ",", "name", ":", "AppOrBlueprintKey", "=", "None", ")", "->", "Callable", ":", "handler", "=", "ensure_coroutine", "(", "func", ")", "self", ".", "teardown_request_funcs", "[", "name", "]...
Add a teardown request function. This is designed to be used as a decorator. An example usage, .. code-block:: python @app.teardown_request def func(): ... Arguments: func: The teardown request function itself. name: Optional bl...
[ "Add", "a", "teardown", "request", "function", "." ]
7cb2d3bd98e8746025764f2b933abc12041fa175
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1145-L1162
train