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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
pgjones/quart | quart/app.py | Quart.teardown_websocket | def teardown_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a teardown websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_websocket
def func():
...
... | python | def teardown_websocket(self, func: Callable, name: AppOrBlueprintKey=None) -> Callable:
"""Add a teardown websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_websocket
def func():
...
... | [
"def",
"teardown_websocket",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"AppOrBlueprintKey",
"=",
"None",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"teardown_websocket_funcs",
"[",
"name",
... | Add a teardown websocket function.
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.teardown_websocket
def func():
...
Arguments:
func: The teardown websocket function itself.
name: Optio... | [
"Add",
"a",
"teardown",
"websocket",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1164-L1181 | train |
pgjones/quart | quart/app.py | Quart.register_blueprint | def register_blueprint(self, blueprint: Blueprint, url_prefix: Optional[str]=None) -> None:
"""Register a blueprint on the app.
This results in the blueprint's routes, error handlers
etc... being added to the app.
Arguments:
blueprint: The blueprint to register.
... | python | def register_blueprint(self, blueprint: Blueprint, url_prefix: Optional[str]=None) -> None:
"""Register a blueprint on the app.
This results in the blueprint's routes, error handlers
etc... being added to the app.
Arguments:
blueprint: The blueprint to register.
... | [
"def",
"register_blueprint",
"(",
"self",
",",
"blueprint",
":",
"Blueprint",
",",
"url_prefix",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"first_registration",
"=",
"False",
"if",
"blueprint",
".",
"name",
"in",
"self",
".",
... | Register a blueprint on the app.
This results in the blueprint's routes, error handlers
etc... being added to the app.
Arguments:
blueprint: The blueprint to register.
url_prefix: Optional prefix to apply to all paths. | [
"Register",
"a",
"blueprint",
"on",
"the",
"app",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1202-L1222 | train |
pgjones/quart | quart/app.py | Quart.open_session | async def open_session(self, request: BaseRequestWebsocket) -> Session:
"""Open and return a Session using the request."""
return await ensure_coroutine(self.session_interface.open_session)(self, request) | python | async def open_session(self, request: BaseRequestWebsocket) -> Session:
"""Open and return a Session using the request."""
return await ensure_coroutine(self.session_interface.open_session)(self, request) | [
"async",
"def",
"open_session",
"(",
"self",
",",
"request",
":",
"BaseRequestWebsocket",
")",
"->",
"Session",
":",
"return",
"await",
"ensure_coroutine",
"(",
"self",
".",
"session_interface",
".",
"open_session",
")",
"(",
"self",
",",
"request",
")"
] | Open and return a Session using the request. | [
"Open",
"and",
"return",
"a",
"Session",
"using",
"the",
"request",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1228-L1230 | train |
pgjones/quart | quart/app.py | Quart.save_session | async def save_session(self, session: Session, response: Response) -> None:
"""Saves the session to the response."""
await ensure_coroutine(self.session_interface.save_session)(self, session, response) | python | async def save_session(self, session: Session, response: Response) -> None:
"""Saves the session to the response."""
await ensure_coroutine(self.session_interface.save_session)(self, session, response) | [
"async",
"def",
"save_session",
"(",
"self",
",",
"session",
":",
"Session",
",",
"response",
":",
"Response",
")",
"->",
"None",
":",
"await",
"ensure_coroutine",
"(",
"self",
".",
"session_interface",
".",
"save_session",
")",
"(",
"self",
",",
"session",
... | Saves the session to the response. | [
"Saves",
"the",
"session",
"to",
"the",
"response",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1236-L1238 | train |
pgjones/quart | quart/app.py | Quart.do_teardown_request | async def do_teardown_request(
self,
exc: Optional[BaseException],
request_context: Optional[RequestContext]=None,
) -> None:
"""Teardown the request, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the reques... | python | async def do_teardown_request(
self,
exc: Optional[BaseException],
request_context: Optional[RequestContext]=None,
) -> None:
"""Teardown the request, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the reques... | [
"async",
"def",
"do_teardown_request",
"(",
"self",
",",
"exc",
":",
"Optional",
"[",
"BaseException",
"]",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"request_",
"=",
"(",
"request_context"... | Teardown the request, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the request
to teardown.
request_context: The request context, optional as Flask
omits this argument. | [
"Teardown",
"the",
"request",
"calling",
"the",
"teardown",
"functions",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1240-L1261 | train |
pgjones/quart | quart/app.py | Quart.do_teardown_websocket | async def do_teardown_websocket(
self,
exc: Optional[BaseException],
websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Teardown the websocket, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused th... | python | async def do_teardown_websocket(
self,
exc: Optional[BaseException],
websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Teardown the websocket, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused th... | [
"async",
"def",
"do_teardown_websocket",
"(",
"self",
",",
"exc",
":",
"Optional",
"[",
"BaseException",
"]",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"websocket_",
"=",
"(",
"websocke... | Teardown the websocket, calling the teardown functions.
Arguments:
exc: Any exception not handled that has caused the websocket
to teardown.
websocket_context: The websocket context, optional as Flask
omits this argument. | [
"Teardown",
"the",
"websocket",
"calling",
"the",
"teardown",
"functions",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1263-L1284 | train |
pgjones/quart | quart/app.py | Quart.run | def run(
self,
host: str='127.0.0.1',
port: int=5000,
debug: Optional[bool]=None,
use_reloader: bool=True,
loop: Optional[asyncio.AbstractEventLoop]=None,
ca_certs: Optional[str]=None,
certfile: Optional[str]=None,
... | python | def run(
self,
host: str='127.0.0.1',
port: int=5000,
debug: Optional[bool]=None,
use_reloader: bool=True,
loop: Optional[asyncio.AbstractEventLoop]=None,
ca_certs: Optional[str]=None,
certfile: Optional[str]=None,
... | [
"def",
"run",
"(",
"self",
",",
"host",
":",
"str",
"=",
"'127.0.0.1'",
",",
"port",
":",
"int",
"=",
"5000",
",",
"debug",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"use_reloader",
":",
"bool",
"=",
"True",
",",
"loop",
":",
"Optional",... | Run this application.
This is best used for development only, see Hypercorn for
production servers.
Arguments:
host: Hostname to listen on. By default this is loopback
only, use 0.0.0.0 to have the server listen externally.
port: Port number to listen on... | [
"Run",
"this",
"application",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1336-L1393 | train |
pgjones/quart | quart/app.py | Quart.try_trigger_before_first_request_functions | async def try_trigger_before_first_request_functions(self) -> None:
"""Trigger the before first request methods."""
if self._got_first_request:
return
# Reverse the teardown functions, so as to match the expected usage
self.teardown_appcontext_funcs = list(reversed(self.tear... | python | async def try_trigger_before_first_request_functions(self) -> None:
"""Trigger the before first request methods."""
if self._got_first_request:
return
# Reverse the teardown functions, so as to match the expected usage
self.teardown_appcontext_funcs = list(reversed(self.tear... | [
"async",
"def",
"try_trigger_before_first_request_functions",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_got_first_request",
":",
"return",
"self",
".",
"teardown_appcontext_funcs",
"=",
"list",
"(",
"reversed",
"(",
"self",
".",
"teardown_appcontext_... | Trigger the before first request methods. | [
"Trigger",
"the",
"before",
"first",
"request",
"methods",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1437-L1454 | train |
pgjones/quart | quart/app.py | Quart.make_default_options_response | async def make_default_options_response(self) -> Response:
"""This is the default route function for OPTIONS requests."""
methods = _request_ctx_stack.top.url_adapter.allowed_methods()
return self.response_class('', headers={'Allow': ', '.join(methods)}) | python | async def make_default_options_response(self) -> Response:
"""This is the default route function for OPTIONS requests."""
methods = _request_ctx_stack.top.url_adapter.allowed_methods()
return self.response_class('', headers={'Allow': ', '.join(methods)}) | [
"async",
"def",
"make_default_options_response",
"(",
"self",
")",
"->",
"Response",
":",
"methods",
"=",
"_request_ctx_stack",
".",
"top",
".",
"url_adapter",
".",
"allowed_methods",
"(",
")",
"return",
"self",
".",
"response_class",
"(",
"''",
",",
"headers",
... | This is the default route function for OPTIONS requests. | [
"This",
"is",
"the",
"default",
"route",
"function",
"for",
"OPTIONS",
"requests",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1456-L1459 | train |
pgjones/quart | quart/app.py | Quart.make_response | async def make_response(self, result: ResponseReturnValue) -> Response:
"""Make a Response from the result of the route handler.
The result itself can either be:
- A Response object (or subclass).
- A tuple of a ResponseValue and a header dictionary.
- A tuple of a Respons... | python | async def make_response(self, result: ResponseReturnValue) -> Response:
"""Make a Response from the result of the route handler.
The result itself can either be:
- A Response object (or subclass).
- A tuple of a ResponseValue and a header dictionary.
- A tuple of a Respons... | [
"async",
"def",
"make_response",
"(",
"self",
",",
"result",
":",
"ResponseReturnValue",
")",
"->",
"Response",
":",
"status_or_headers",
"=",
"None",
"headers",
"=",
"None",
"status",
"=",
"None",
"if",
"isinstance",
"(",
"result",
",",
"tuple",
")",
":",
... | Make a Response from the result of the route handler.
The result itself can either be:
- A Response object (or subclass).
- A tuple of a ResponseValue and a header dictionary.
- A tuple of a ResponseValue, status code and a header dictionary.
A ResponseValue is either a R... | [
"Make",
"a",
"Response",
"from",
"the",
"result",
"of",
"the",
"route",
"handler",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1461-L1501 | train |
pgjones/quart | quart/app.py | Quart.full_dispatch_request | async def full_dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> Response:
"""Adds pre and post processing to the request dispatching.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
... | python | async def full_dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> Response:
"""Adds pre and post processing to the request dispatching.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
... | [
"async",
"def",
"full_dispatch_request",
"(",
"self",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"Response",
":",
"await",
"self",
".",
"try_trigger_before_first_request_functions",
"(",
")",
"await",
"request... | Adds pre and post processing to the request dispatching.
Arguments:
request_context: The request context, optional as Flask
omits this argument. | [
"Adds",
"pre",
"and",
"post",
"processing",
"to",
"the",
"request",
"dispatching",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1512-L1529 | train |
pgjones/quart | quart/app.py | Quart.preprocess_request | async def preprocess_request(
self, request_context: Optional[RequestContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the request i.e. call before_request functions.
Arguments:
request_context: The request context, optional as Flask
omits this arg... | python | async def preprocess_request(
self, request_context: Optional[RequestContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the request i.e. call before_request functions.
Arguments:
request_context: The request context, optional as Flask
omits this arg... | [
"async",
"def",
"preprocess_request",
"(",
"self",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"ResponseReturnValue",
"]",
":",
"request_",
"=",
"(",
"request_context",
"or",
"_request_ctx_st... | Preprocess the request i.e. call before_request functions.
Arguments:
request_context: The request context, optional as Flask
omits this argument. | [
"Preprocess",
"the",
"request",
"i",
".",
"e",
".",
"call",
"before_request",
"functions",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1531-L1555 | train |
pgjones/quart | quart/app.py | Quart.dispatch_request | async def dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> ResponseReturnValue:
"""Dispatch the request to the view function.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
r... | python | async def dispatch_request(
self, request_context: Optional[RequestContext]=None,
) -> ResponseReturnValue:
"""Dispatch the request to the view function.
Arguments:
request_context: The request context, optional as Flask
omits this argument.
"""
r... | [
"async",
"def",
"dispatch_request",
"(",
"self",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"ResponseReturnValue",
":",
"request_",
"=",
"(",
"request_context",
"or",
"_request_ctx_stack",
".",
"top",
")",
... | Dispatch the request to the view function.
Arguments:
request_context: The request context, optional as Flask
omits this argument. | [
"Dispatch",
"the",
"request",
"to",
"the",
"view",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1557-L1574 | train |
pgjones/quart | quart/app.py | Quart.process_response | async def process_response(
self,
response: Response,
request_context: Optional[RequestContext]=None,
) -> Response:
"""Postprocess the request acting on the response.
Arguments:
response: The response after the request is finalized.
request_context: ... | python | async def process_response(
self,
response: Response,
request_context: Optional[RequestContext]=None,
) -> Response:
"""Postprocess the request acting on the response.
Arguments:
response: The response after the request is finalized.
request_context: ... | [
"async",
"def",
"process_response",
"(",
"self",
",",
"response",
":",
"Response",
",",
"request_context",
":",
"Optional",
"[",
"RequestContext",
"]",
"=",
"None",
",",
")",
"->",
"Response",
":",
"request_",
"=",
"(",
"request_context",
"or",
"_request_ctx_s... | Postprocess the request acting on the response.
Arguments:
response: The response after the request is finalized.
request_context: The request context, optional as Flask
omits this argument. | [
"Postprocess",
"the",
"request",
"acting",
"on",
"the",
"response",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1599-L1624 | train |
pgjones/quart | quart/app.py | Quart.full_dispatch_websocket | async def full_dispatch_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> Optional[Response]:
"""Adds pre and post processing to the websocket dispatching.
Arguments:
websocket_context: The websocket context, optional to match
the Flask co... | python | async def full_dispatch_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> Optional[Response]:
"""Adds pre and post processing to the websocket dispatching.
Arguments:
websocket_context: The websocket context, optional to match
the Flask co... | [
"async",
"def",
"full_dispatch_websocket",
"(",
"self",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"Response",
"]",
":",
"await",
"self",
".",
"try_trigger_before_first_request_functions",
... | Adds pre and post processing to the websocket dispatching.
Arguments:
websocket_context: The websocket context, optional to match
the Flask convention. | [
"Adds",
"pre",
"and",
"post",
"processing",
"to",
"the",
"websocket",
"dispatching",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1635-L1652 | train |
pgjones/quart | quart/app.py | Quart.preprocess_websocket | async def preprocess_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the websocket i.e. call before_websocket functions.
Arguments:
websocket_context: The websocket context, optional as Flask
... | python | async def preprocess_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> Optional[ResponseReturnValue]:
"""Preprocess the websocket i.e. call before_websocket functions.
Arguments:
websocket_context: The websocket context, optional as Flask
... | [
"async",
"def",
"preprocess_websocket",
"(",
"self",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"ResponseReturnValue",
"]",
":",
"websocket_",
"=",
"(",
"websocket_context",
"or",
"_webs... | Preprocess the websocket i.e. call before_websocket functions.
Arguments:
websocket_context: The websocket context, optional as Flask
omits this argument. | [
"Preprocess",
"the",
"websocket",
"i",
".",
"e",
".",
"call",
"before_websocket",
"functions",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1654-L1678 | train |
pgjones/quart | quart/app.py | Quart.dispatch_websocket | async def dispatch_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Dispatch the websocket to the view function.
Arguments:
websocket_context: The websocket context, optional to match
the Flask convention.
"""
web... | python | async def dispatch_websocket(
self, websocket_context: Optional[WebsocketContext]=None,
) -> None:
"""Dispatch the websocket to the view function.
Arguments:
websocket_context: The websocket context, optional to match
the Flask convention.
"""
web... | [
"async",
"def",
"dispatch_websocket",
"(",
"self",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"websocket_",
"=",
"(",
"websocket_context",
"or",
"_websocket_ctx_stack",
".",
"top",
")",
".... | Dispatch the websocket to the view function.
Arguments:
websocket_context: The websocket context, optional to match
the Flask convention. | [
"Dispatch",
"the",
"websocket",
"to",
"the",
"view",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1680-L1694 | train |
pgjones/quart | quart/app.py | Quart.postprocess_websocket | async def postprocess_websocket(
self,
response: Optional[Response],
websocket_context: Optional[WebsocketContext]=None,
) -> Response:
"""Postprocess the websocket acting on the response.
Arguments:
response: The response after the websocket is finalized.
... | python | async def postprocess_websocket(
self,
response: Optional[Response],
websocket_context: Optional[WebsocketContext]=None,
) -> Response:
"""Postprocess the websocket acting on the response.
Arguments:
response: The response after the websocket is finalized.
... | [
"async",
"def",
"postprocess_websocket",
"(",
"self",
",",
"response",
":",
"Optional",
"[",
"Response",
"]",
",",
"websocket_context",
":",
"Optional",
"[",
"WebsocketContext",
"]",
"=",
"None",
",",
")",
"->",
"Response",
":",
"websocket_",
"=",
"(",
"webs... | Postprocess the websocket acting on the response.
Arguments:
response: The response after the websocket is finalized.
webcoket_context: The websocket context, optional as Flask
omits this argument. | [
"Postprocess",
"the",
"websocket",
"acting",
"on",
"the",
"response",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1722-L1753 | train |
pgjones/quart | quart/ctx.py | after_this_request | def after_this_request(func: Callable) -> Callable:
"""Schedule the func to be called after the current request.
This is useful in situations whereby you want an after request
function for a specific route or circumstance only, for example,
.. code-block:: python
def index():
@aft... | python | def after_this_request(func: Callable) -> Callable:
"""Schedule the func to be called after the current request.
This is useful in situations whereby you want an after request
function for a specific route or circumstance only, for example,
.. code-block:: python
def index():
@aft... | [
"def",
"after_this_request",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"_request_ctx_stack",
".",
"top",
".",
"_after_request_functions",
".",
"append",
"(",
"func",
")",
"return",
"func"
] | Schedule the func to be called after the current request.
This is useful in situations whereby you want an after request
function for a specific route or circumstance only, for example,
.. code-block:: python
def index():
@after_this_request
def set_cookie(response):
... | [
"Schedule",
"the",
"func",
"to",
"be",
"called",
"after",
"the",
"current",
"request",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L183-L200 | train |
pgjones/quart | quart/ctx.py | after_this_websocket | def after_this_websocket(func: Callable) -> Callable:
"""Schedule the func to be called after the current websocket.
This is useful in situations whereby you want an after websocket
function for a specific route or circumstance only, for example,
.. note::
The response is an optional argument,... | python | def after_this_websocket(func: Callable) -> Callable:
"""Schedule the func to be called after the current websocket.
This is useful in situations whereby you want an after websocket
function for a specific route or circumstance only, for example,
.. note::
The response is an optional argument,... | [
"def",
"after_this_websocket",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"_websocket_ctx_stack",
".",
"top",
".",
"_after_websocket_functions",
".",
"append",
"(",
"func",
")",
"return",
"func"
] | Schedule the func to be called after the current websocket.
This is useful in situations whereby you want an after websocket
function for a specific route or circumstance only, for example,
.. note::
The response is an optional argument, and will only be
passed if the websocket was not act... | [
"Schedule",
"the",
"func",
"to",
"be",
"called",
"after",
"the",
"current",
"websocket",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L203-L226 | train |
pgjones/quart | quart/ctx.py | copy_current_app_context | def copy_current_app_context(func: Callable) -> Callable:
"""Share the current app context with the function decorated.
The app context is local per task and hence will not be available
in any other task. This decorator can be used to make the context
available,
.. code-block:: python
@co... | python | def copy_current_app_context(func: Callable) -> Callable:
"""Share the current app context with the function decorated.
The app context is local per task and hence will not be available
in any other task. This decorator can be used to make the context
available,
.. code-block:: python
@co... | [
"def",
"copy_current_app_context",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"if",
"not",
"has_app_context",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"'Attempt to copy app context outside of a app context'",
")",
"app_context",
"=",
"_app_ctx_stack",... | Share the current app context with the function decorated.
The app context is local per task and hence will not be available
in any other task. This decorator can be used to make the context
available,
.. code-block:: python
@copy_current_app_context
async def within_context() -> None... | [
"Share",
"the",
"current",
"app",
"context",
"with",
"the",
"function",
"decorated",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L229-L253 | train |
pgjones/quart | quart/ctx.py | copy_current_request_context | def copy_current_request_context(func: Callable) -> Callable:
"""Share the current request context with the function decorated.
The request context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: python
... | python | def copy_current_request_context(func: Callable) -> Callable:
"""Share the current request context with the function decorated.
The request context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: python
... | [
"def",
"copy_current_request_context",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"if",
"not",
"has_request_context",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"'Attempt to copy request context outside of a request context'",
")",
"request_context",
"=",... | Share the current request context with the function decorated.
The request context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: python
@copy_current_request_context
async def within_conte... | [
"Share",
"the",
"current",
"request",
"context",
"with",
"the",
"function",
"decorated",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L256-L280 | train |
pgjones/quart | quart/ctx.py | copy_current_websocket_context | def copy_current_websocket_context(func: Callable) -> Callable:
"""Share the current websocket context with the function decorated.
The websocket context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: p... | python | def copy_current_websocket_context(func: Callable) -> Callable:
"""Share the current websocket context with the function decorated.
The websocket context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: p... | [
"def",
"copy_current_websocket_context",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"if",
"not",
"has_websocket_context",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"'Attempt to copy websocket context outside of a websocket context'",
")",
"websocket_contex... | Share the current websocket context with the function decorated.
The websocket context is local per task and hence will not be
available in any other task. This decorator can be used to make
the context available,
.. code-block:: python
@copy_current_websocket_context
async def within... | [
"Share",
"the",
"current",
"websocket",
"context",
"with",
"the",
"function",
"decorated",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L283-L307 | train |
pgjones/quart | quart/ctx.py | _BaseRequestWebsocketContext.match_request | def match_request(self) -> None:
"""Match the request against the adapter.
Override this method to configure request matching, it should
set the request url_rule and view_args and optionally a
routing_exception.
"""
try:
self.request_websocket.url_rule, self.... | python | def match_request(self) -> None:
"""Match the request against the adapter.
Override this method to configure request matching, it should
set the request url_rule and view_args and optionally a
routing_exception.
"""
try:
self.request_websocket.url_rule, self.... | [
"def",
"match_request",
"(",
"self",
")",
"->",
"None",
":",
"try",
":",
"self",
".",
"request_websocket",
".",
"url_rule",
",",
"self",
".",
"request_websocket",
".",
"view_args",
"=",
"self",
".",
"url_adapter",
".",
"match",
"(",
")",
"except",
"(",
"... | Match the request against the adapter.
Override this method to configure request matching, it should
set the request url_rule and view_args and optionally a
routing_exception. | [
"Match",
"the",
"request",
"against",
"the",
"adapter",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L37-L47 | train |
pgjones/quart | quart/ctx.py | _AppCtxGlobals.get | def get(self, name: str, default: Optional[Any]=None) -> Any:
"""Get a named attribute of this instance, or return the default."""
return self.__dict__.get(name, default) | python | def get(self, name: str, default: Optional[Any]=None) -> Any:
"""Get a named attribute of this instance, or return the default."""
return self.__dict__.get(name, default) | [
"def",
"get",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
")",
"->",
"Any",
":",
"return",
"self",
".",
"__dict__",
".",
"get",
"(",
"name",
",",
"default",
")"
] | Get a named attribute of this instance, or return the default. | [
"Get",
"a",
"named",
"attribute",
"of",
"this",
"instance",
"or",
"return",
"the",
"default",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L364-L366 | train |
pgjones/quart | quart/ctx.py | _AppCtxGlobals.pop | def pop(self, name: str, default: Any=_sentinel) -> Any:
"""Pop, get and remove the named attribute of this instance."""
if default is _sentinel:
return self.__dict__.pop(name)
else:
return self.__dict__.pop(name, default) | python | def pop(self, name: str, default: Any=_sentinel) -> Any:
"""Pop, get and remove the named attribute of this instance."""
if default is _sentinel:
return self.__dict__.pop(name)
else:
return self.__dict__.pop(name, default) | [
"def",
"pop",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Any",
"=",
"_sentinel",
")",
"->",
"Any",
":",
"if",
"default",
"is",
"_sentinel",
":",
"return",
"self",
".",
"__dict__",
".",
"pop",
"(",
"name",
")",
"else",
":",
"return"... | Pop, get and remove the named attribute of this instance. | [
"Pop",
"get",
"and",
"remove",
"the",
"named",
"attribute",
"of",
"this",
"instance",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L368-L373 | train |
pgjones/quart | quart/ctx.py | _AppCtxGlobals.setdefault | def setdefault(self, name: str, default: Any=None) -> Any:
"""Set an attribute with a default value."""
return self.__dict__.setdefault(name, default) | python | def setdefault(self, name: str, default: Any=None) -> Any:
"""Set an attribute with a default value."""
return self.__dict__.setdefault(name, default) | [
"def",
"setdefault",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Any",
"=",
"None",
")",
"->",
"Any",
":",
"return",
"self",
".",
"__dict__",
".",
"setdefault",
"(",
"name",
",",
"default",
")"
] | Set an attribute with a default value. | [
"Set",
"an",
"attribute",
"with",
"a",
"default",
"value",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/ctx.py#L375-L377 | train |
pgjones/quart | quart/sessions.py | SessionInterface.get_cookie_domain | def get_cookie_domain(self, app: 'Quart') -> Optional[str]:
"""Helper method to return the Cookie Domain for the App."""
if app.config['SESSION_COOKIE_DOMAIN'] is not None:
return app.config['SESSION_COOKIE_DOMAIN']
elif app.config['SERVER_NAME'] is not None:
return '.' +... | python | def get_cookie_domain(self, app: 'Quart') -> Optional[str]:
"""Helper method to return the Cookie Domain for the App."""
if app.config['SESSION_COOKIE_DOMAIN'] is not None:
return app.config['SESSION_COOKIE_DOMAIN']
elif app.config['SERVER_NAME'] is not None:
return '.' +... | [
"def",
"get_cookie_domain",
"(",
"self",
",",
"app",
":",
"'Quart'",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"app",
".",
"config",
"[",
"'SESSION_COOKIE_DOMAIN'",
"]",
"is",
"not",
"None",
":",
"return",
"app",
".",
"config",
"[",
"'SESSION_CO... | Helper method to return the Cookie Domain for the App. | [
"Helper",
"method",
"to",
"return",
"the",
"Cookie",
"Domain",
"for",
"the",
"App",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L129-L136 | train |
pgjones/quart | quart/sessions.py | SessionInterface.get_expiration_time | def get_expiration_time(self, app: 'Quart', session: SessionMixin) -> Optional[datetime]:
"""Helper method to return the Session expiration time.
If the session is not 'permanent' it will expire as and when
the browser stops accessing the app.
"""
if session.permanent:
... | python | def get_expiration_time(self, app: 'Quart', session: SessionMixin) -> Optional[datetime]:
"""Helper method to return the Session expiration time.
If the session is not 'permanent' it will expire as and when
the browser stops accessing the app.
"""
if session.permanent:
... | [
"def",
"get_expiration_time",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"session",
":",
"SessionMixin",
")",
"->",
"Optional",
"[",
"datetime",
"]",
":",
"if",
"session",
".",
"permanent",
":",
"return",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"app... | Helper method to return the Session expiration time.
If the session is not 'permanent' it will expire as and when
the browser stops accessing the app. | [
"Helper",
"method",
"to",
"return",
"the",
"Session",
"expiration",
"time",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L150-L159 | train |
pgjones/quart | quart/sessions.py | SessionInterface.should_set_cookie | def should_set_cookie(self, app: 'Quart', session: SessionMixin) -> bool:
"""Helper method to return if the Set Cookie header should be present.
This triggers if the session is marked as modified or the app
is configured to always refresh the cookie.
"""
if session.modified:
... | python | def should_set_cookie(self, app: 'Quart', session: SessionMixin) -> bool:
"""Helper method to return if the Set Cookie header should be present.
This triggers if the session is marked as modified or the app
is configured to always refresh the cookie.
"""
if session.modified:
... | [
"def",
"should_set_cookie",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"session",
":",
"SessionMixin",
")",
"->",
"bool",
":",
"if",
"session",
".",
"modified",
":",
"return",
"True",
"save_each",
"=",
"app",
".",
"config",
"[",
"'SESSION_REFRESH_EACH_REQ... | Helper method to return if the Set Cookie header should be present.
This triggers if the session is marked as modified or the app
is configured to always refresh the cookie. | [
"Helper",
"method",
"to",
"return",
"if",
"the",
"Set",
"Cookie",
"header",
"should",
"be",
"present",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L161-L170 | train |
pgjones/quart | quart/sessions.py | SecureCookieSessionInterface.get_signing_serializer | def get_signing_serializer(self, app: 'Quart') -> Optional[URLSafeTimedSerializer]:
"""Return a serializer for the session that also signs data.
This will return None if the app is not configured for secrets.
"""
if not app.secret_key:
return None
options = {
... | python | def get_signing_serializer(self, app: 'Quart') -> Optional[URLSafeTimedSerializer]:
"""Return a serializer for the session that also signs data.
This will return None if the app is not configured for secrets.
"""
if not app.secret_key:
return None
options = {
... | [
"def",
"get_signing_serializer",
"(",
"self",
",",
"app",
":",
"'Quart'",
")",
"->",
"Optional",
"[",
"URLSafeTimedSerializer",
"]",
":",
"if",
"not",
"app",
".",
"secret_key",
":",
"return",
"None",
"options",
"=",
"{",
"'key_derivation'",
":",
"self",
".",... | Return a serializer for the session that also signs data.
This will return None if the app is not configured for secrets. | [
"Return",
"a",
"serializer",
"for",
"the",
"session",
"that",
"also",
"signs",
"data",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L204-L218 | train |
pgjones/quart | quart/sessions.py | SecureCookieSessionInterface.open_session | async def open_session(
self,
app: 'Quart',
request: BaseRequestWebsocket,
) -> Optional[SecureCookieSession]:
"""Open a secure cookie based session.
This will return None if a signing serializer is not availabe,
usually if the config SECRET_KEY is not se... | python | async def open_session(
self,
app: 'Quart',
request: BaseRequestWebsocket,
) -> Optional[SecureCookieSession]:
"""Open a secure cookie based session.
This will return None if a signing serializer is not availabe,
usually if the config SECRET_KEY is not se... | [
"async",
"def",
"open_session",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"request",
":",
"BaseRequestWebsocket",
",",
")",
"->",
"Optional",
"[",
"SecureCookieSession",
"]",
":",
"signer",
"=",
"self",
".",
"get_signing_serializer",
"(",
"app",
")",
"if... | Open a secure cookie based session.
This will return None if a signing serializer is not availabe,
usually if the config SECRET_KEY is not set. | [
"Open",
"a",
"secure",
"cookie",
"based",
"session",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L220-L243 | train |
pgjones/quart | quart/sessions.py | SecureCookieSessionInterface.save_session | async def save_session( # type: ignore
self, app: 'Quart', session: SecureCookieSession, response: Response,
) -> None:
"""Saves the session to the response in a secure cookie."""
domain = self.get_cookie_domain(app)
path = self.get_cookie_path(app)
if not session:
... | python | async def save_session( # type: ignore
self, app: 'Quart', session: SecureCookieSession, response: Response,
) -> None:
"""Saves the session to the response in a secure cookie."""
domain = self.get_cookie_domain(app)
path = self.get_cookie_path(app)
if not session:
... | [
"async",
"def",
"save_session",
"(",
"self",
",",
"app",
":",
"'Quart'",
",",
"session",
":",
"SecureCookieSession",
",",
"response",
":",
"Response",
",",
")",
"->",
"None",
":",
"domain",
"=",
"self",
".",
"get_cookie_domain",
"(",
"app",
")",
"path",
... | Saves the session to the response in a secure cookie. | [
"Saves",
"the",
"session",
"to",
"the",
"response",
"in",
"a",
"secure",
"cookie",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/sessions.py#L245-L271 | train |
pgjones/quart | quart/wrappers/response.py | Response.get_data | async def get_data(self, raw: bool=True) -> AnyStr:
"""Return the body data."""
if self.implicit_sequence_conversion:
self.response = self.data_body_class(await self.response.convert_to_sequence())
result = b'' if raw else ''
async with self.response as body: # type: ignore
... | python | async def get_data(self, raw: bool=True) -> AnyStr:
"""Return the body data."""
if self.implicit_sequence_conversion:
self.response = self.data_body_class(await self.response.convert_to_sequence())
result = b'' if raw else ''
async with self.response as body: # type: ignore
... | [
"async",
"def",
"get_data",
"(",
"self",
",",
"raw",
":",
"bool",
"=",
"True",
")",
"->",
"AnyStr",
":",
"if",
"self",
".",
"implicit_sequence_conversion",
":",
"self",
".",
"response",
"=",
"self",
".",
"data_body_class",
"(",
"await",
"self",
".",
"res... | Return the body data. | [
"Return",
"the",
"body",
"data",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/response.py#L272-L283 | train |
pgjones/quart | quart/wrappers/response.py | Response.set_data | def set_data(self, data: AnyStr) -> None:
"""Set the response data.
This will encode using the :attr:`charset`.
"""
if isinstance(data, str):
bytes_data = data.encode(self.charset)
else:
bytes_data = data
self.response = self.data_body_class(bytes... | python | def set_data(self, data: AnyStr) -> None:
"""Set the response data.
This will encode using the :attr:`charset`.
"""
if isinstance(data, str):
bytes_data = data.encode(self.charset)
else:
bytes_data = data
self.response = self.data_body_class(bytes... | [
"def",
"set_data",
"(",
"self",
",",
"data",
":",
"AnyStr",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"bytes_data",
"=",
"data",
".",
"encode",
"(",
"self",
".",
"charset",
")",
"else",
":",
"bytes_data",
"=",
"... | Set the response data.
This will encode using the :attr:`charset`. | [
"Set",
"the",
"response",
"data",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/response.py#L285-L296 | train |
pgjones/quart | quart/wrappers/response.py | Response.make_conditional | async def make_conditional(
self,
request_range: Range,
max_partial_size: Optional[int]=None,
) -> None:
"""Make the response conditional to the
Arguments:
request_range: The range as requested by the request.
max_partial_size: The maximum... | python | async def make_conditional(
self,
request_range: Range,
max_partial_size: Optional[int]=None,
) -> None:
"""Make the response conditional to the
Arguments:
request_range: The range as requested by the request.
max_partial_size: The maximum... | [
"async",
"def",
"make_conditional",
"(",
"self",
",",
"request_range",
":",
"Range",
",",
"max_partial_size",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"self",
".",
"accept_ranges",
"=",
"\"bytes\"",
"if",
"len",
"(",
"r... | Make the response conditional to the
Arguments:
request_range: The range as requested by the request.
max_partial_size: The maximum length the server is willing
to serve in a single response. Defaults to unlimited. | [
"Make",
"the",
"response",
"conditional",
"to",
"the"
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/response.py#L298-L335 | train |
pgjones/quart | quart/wrappers/response.py | Response.set_cookie | def set_cookie( # type: ignore
self,
key: str,
value: AnyStr='',
max_age: Optional[Union[int, timedelta]]=None,
expires: Optional[datetime]=None,
path: str='/',
domain: Optional[str]=None,
secure: bool=False,
ht... | python | def set_cookie( # type: ignore
self,
key: str,
value: AnyStr='',
max_age: Optional[Union[int, timedelta]]=None,
expires: Optional[datetime]=None,
path: str='/',
domain: Optional[str]=None,
secure: bool=False,
ht... | [
"def",
"set_cookie",
"(",
"self",
",",
"key",
":",
"str",
",",
"value",
":",
"AnyStr",
"=",
"''",
",",
"max_age",
":",
"Optional",
"[",
"Union",
"[",
"int",
",",
"timedelta",
"]",
"]",
"=",
"None",
",",
"expires",
":",
"Optional",
"[",
"datetime",
... | Set a cookie in the response headers.
The arguments are the standard cookie morsels and this is a
wrapper around the stdlib SimpleCookie code. | [
"Set",
"a",
"cookie",
"in",
"the",
"response",
"headers",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/response.py#L341-L360 | train |
pgjones/quart | quart/routing.py | Rule.match | def match(self, path: str) -> Tuple[Optional[Dict[str, Any]], bool]:
"""Check if the path matches this Rule.
If it does it returns a dict of matched and converted values,
otherwise None is returned.
"""
match = self._pattern.match(path)
if match is not None:
... | python | def match(self, path: str) -> Tuple[Optional[Dict[str, Any]], bool]:
"""Check if the path matches this Rule.
If it does it returns a dict of matched and converted values,
otherwise None is returned.
"""
match = self._pattern.match(path)
if match is not None:
... | [
"def",
"match",
"(",
"self",
",",
"path",
":",
"str",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"bool",
"]",
":",
"match",
"=",
"self",
".",
"_pattern",
".",
"match",
"(",
"path",
")",
"if",
"match... | Check if the path matches this Rule.
If it does it returns a dict of matched and converted values,
otherwise None is returned. | [
"Check",
"if",
"the",
"path",
"matches",
"this",
"Rule",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L335-L360 | train |
pgjones/quart | quart/routing.py | Rule.provides_defaults_for | def provides_defaults_for(self, rule: 'Rule', **values: Any) -> bool:
"""Returns true if this rule provides defaults for the argument and values."""
defaults_match = all(
values[key] == self.defaults[key] for key in self.defaults if key in values # noqa: S101, E501
)
return ... | python | def provides_defaults_for(self, rule: 'Rule', **values: Any) -> bool:
"""Returns true if this rule provides defaults for the argument and values."""
defaults_match = all(
values[key] == self.defaults[key] for key in self.defaults if key in values # noqa: S101, E501
)
return ... | [
"def",
"provides_defaults_for",
"(",
"self",
",",
"rule",
":",
"'Rule'",
",",
"**",
"values",
":",
"Any",
")",
"->",
"bool",
":",
"defaults_match",
"=",
"all",
"(",
"values",
"[",
"key",
"]",
"==",
"self",
".",
"defaults",
"[",
"key",
"]",
"for",
"ke... | Returns true if this rule provides defaults for the argument and values. | [
"Returns",
"true",
"if",
"this",
"rule",
"provides",
"defaults",
"for",
"the",
"argument",
"and",
"values",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L362-L367 | train |
pgjones/quart | quart/routing.py | Rule.build | def build(self, **values: Any) -> str:
"""Build this rule into a path using the values given."""
converted_values = {
key: self._converters[key].to_url(value)
for key, value in values.items()
if key in self._converters
}
result = self._builder.format(*... | python | def build(self, **values: Any) -> str:
"""Build this rule into a path using the values given."""
converted_values = {
key: self._converters[key].to_url(value)
for key, value in values.items()
if key in self._converters
}
result = self._builder.format(*... | [
"def",
"build",
"(",
"self",
",",
"**",
"values",
":",
"Any",
")",
"->",
"str",
":",
"converted_values",
"=",
"{",
"key",
":",
"self",
".",
"_converters",
"[",
"key",
"]",
".",
"to_url",
"(",
"value",
")",
"for",
"key",
",",
"value",
"in",
"values"... | Build this rule into a path using the values given. | [
"Build",
"this",
"rule",
"into",
"a",
"path",
"using",
"the",
"values",
"given",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L369-L387 | train |
pgjones/quart | quart/routing.py | Rule.buildable | def buildable(self, values: Optional[dict]=None, method: Optional[str]=None) -> bool:
"""Return True if this rule can build with the values and method."""
if method is not None and method not in self.methods:
return False
defaults_match = all(
values[key] == self.defaults... | python | def buildable(self, values: Optional[dict]=None, method: Optional[str]=None) -> bool:
"""Return True if this rule can build with the values and method."""
if method is not None and method not in self.methods:
return False
defaults_match = all(
values[key] == self.defaults... | [
"def",
"buildable",
"(",
"self",
",",
"values",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
",",
"method",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"method",
"is",
"not",
"None",
"and",
"method",
"not",
"in",... | Return True if this rule can build with the values and method. | [
"Return",
"True",
"if",
"this",
"rule",
"can",
"build",
"with",
"the",
"values",
"and",
"method",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L389-L396 | train |
pgjones/quart | quart/routing.py | Rule.bind | def bind(self, map: Map) -> None:
"""Bind the Rule to a Map and compile it."""
if self.map is not None:
raise RuntimeError(f"{self!r} is already bound to {self.map!r}")
self.map = map
pattern = ''
builder = ''
full_rule = "{}\\|{}".format(self.host or '', se... | python | def bind(self, map: Map) -> None:
"""Bind the Rule to a Map and compile it."""
if self.map is not None:
raise RuntimeError(f"{self!r} is already bound to {self.map!r}")
self.map = map
pattern = ''
builder = ''
full_rule = "{}\\|{}".format(self.host or '', se... | [
"def",
"bind",
"(",
"self",
",",
"map",
":",
"Map",
")",
"->",
"None",
":",
"if",
"self",
".",
"map",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"f\"{self!r} is already bound to {self.map!r}\"",
")",
"self",
".",
"map",
"=",
"map",
"pattern",
... | Bind the Rule to a Map and compile it. | [
"Bind",
"the",
"Rule",
"to",
"a",
"Map",
"and",
"compile",
"it",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L398-L427 | train |
pgjones/quart | quart/routing.py | Rule.match_key | def match_key(self) -> Tuple[bool, bool, int, List[WeightedPart]]:
"""A Key to sort the rules by weight for matching.
The key leads to ordering:
- By first order by defaults as they are simple rules without
conversions.
- Then on the complexity of the rule, i.e. does it ha... | python | def match_key(self) -> Tuple[bool, bool, int, List[WeightedPart]]:
"""A Key to sort the rules by weight for matching.
The key leads to ordering:
- By first order by defaults as they are simple rules without
conversions.
- Then on the complexity of the rule, i.e. does it ha... | [
"def",
"match_key",
"(",
"self",
")",
"->",
"Tuple",
"[",
"bool",
",",
"bool",
",",
"int",
",",
"List",
"[",
"WeightedPart",
"]",
"]",
":",
"if",
"self",
".",
"map",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"f\"{self!r} is not bound to a Map\"",
... | A Key to sort the rules by weight for matching.
The key leads to ordering:
- By first order by defaults as they are simple rules without
conversions.
- Then on the complexity of the rule, i.e. does it have any
converted parts. This is as simple rules are quick to match
... | [
"A",
"Key",
"to",
"sort",
"the",
"rules",
"by",
"weight",
"for",
"matching",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L430-L448 | train |
pgjones/quart | quart/routing.py | Rule.build_key | def build_key(self) -> Tuple[bool, int]:
"""A Key to sort the rules by weight for building.
The key leads to ordering:
- By routes with defaults first, as these must be evaulated
for building before ones without.
- Then the more complex routes (most converted parts).
... | python | def build_key(self) -> Tuple[bool, int]:
"""A Key to sort the rules by weight for building.
The key leads to ordering:
- By routes with defaults first, as these must be evaulated
for building before ones without.
- Then the more complex routes (most converted parts).
... | [
"def",
"build_key",
"(",
"self",
")",
"->",
"Tuple",
"[",
"bool",
",",
"int",
"]",
":",
"if",
"self",
".",
"map",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"f\"{self!r} is not bound to a Map\"",
")",
"return",
"(",
"not",
"bool",
"(",
"self",
".",... | A Key to sort the rules by weight for building.
The key leads to ordering:
- By routes with defaults first, as these must be evaulated
for building before ones without.
- Then the more complex routes (most converted parts). | [
"A",
"Key",
"to",
"sort",
"the",
"rules",
"by",
"weight",
"for",
"building",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/routing.py#L451-L462 | train |
pgjones/quart | examples/http2_push/http2_push.py | get_tile | def get_tile(tile_number):
"""
Returns a crop of `img` based on a sequence number `tile_number`.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises TileOutOfBoundsError: When `tile_number` exceeds `max_tiles`^2
:rtype PIL.Image:
"""
tile_number = int(tile_number... | python | def get_tile(tile_number):
"""
Returns a crop of `img` based on a sequence number `tile_number`.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises TileOutOfBoundsError: When `tile_number` exceeds `max_tiles`^2
:rtype PIL.Image:
"""
tile_number = int(tile_number... | [
"def",
"get_tile",
"(",
"tile_number",
")",
":",
"tile_number",
"=",
"int",
"(",
"tile_number",
")",
"max_tiles",
"=",
"app",
".",
"max_tiles",
"if",
"tile_number",
">",
"max_tiles",
"*",
"max_tiles",
":",
"raise",
"TileOutOfBoundsError",
"(",
"'Requested an out... | Returns a crop of `img` based on a sequence number `tile_number`.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises TileOutOfBoundsError: When `tile_number` exceeds `max_tiles`^2
:rtype PIL.Image: | [
"Returns",
"a",
"crop",
"of",
"img",
"based",
"on",
"a",
"sequence",
"number",
"tile_number",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/examples/http2_push/http2_push.py#L21-L44 | train |
pgjones/quart | examples/http2_push/http2_push.py | tile | async def tile(tile_number):
"""
Handles GET requests for a tile number.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises HTTPError: 404 if tile exceeds `max_tiles`^2.
"""
try:
tile = get_tile(tile_number)
except TileOutOfBoundsError:
abort(404... | python | async def tile(tile_number):
"""
Handles GET requests for a tile number.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises HTTPError: 404 if tile exceeds `max_tiles`^2.
"""
try:
tile = get_tile(tile_number)
except TileOutOfBoundsError:
abort(404... | [
"async",
"def",
"tile",
"(",
"tile_number",
")",
":",
"try",
":",
"tile",
"=",
"get_tile",
"(",
"tile_number",
")",
"except",
"TileOutOfBoundsError",
":",
"abort",
"(",
"404",
")",
"buf",
"=",
"BytesIO",
"(",
"tile",
".",
"tobytes",
"(",
")",
")",
"til... | Handles GET requests for a tile number.
:param int tile_number: Number of the tile between 0 and `max_tiles`^2.
:raises HTTPError: 404 if tile exceeds `max_tiles`^2. | [
"Handles",
"GET",
"requests",
"for",
"a",
"tile",
"number",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/examples/http2_push/http2_push.py#L66-L86 | train |
pgjones/quart | quart/wrappers/_base.py | JSONMixin.is_json | def is_json(self) -> bool:
"""Returns True if the content_type is json like."""
content_type = self.mimetype
if content_type == 'application/json' or (
content_type.startswith('application/') and content_type.endswith('+json')
):
return True
else:
... | python | def is_json(self) -> bool:
"""Returns True if the content_type is json like."""
content_type = self.mimetype
if content_type == 'application/json' or (
content_type.startswith('application/') and content_type.endswith('+json')
):
return True
else:
... | [
"def",
"is_json",
"(",
"self",
")",
"->",
"bool",
":",
"content_type",
"=",
"self",
".",
"mimetype",
"if",
"content_type",
"==",
"'application/json'",
"or",
"(",
"content_type",
".",
"startswith",
"(",
"'application/'",
")",
"and",
"content_type",
".",
"endswi... | Returns True if the content_type is json like. | [
"Returns",
"True",
"if",
"the",
"content_type",
"is",
"json",
"like",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L40-L48 | train |
pgjones/quart | quart/wrappers/_base.py | JSONMixin.get_json | async def get_json(
self, force: bool=False, silent: bool=False, cache: bool=True,
) -> Any:
"""Parses the body data as JSON and returns it.
Arguments:
force: Force JSON parsing even if the mimetype is not JSON.
silent: Do not trigger error handling if parsing fails,... | python | async def get_json(
self, force: bool=False, silent: bool=False, cache: bool=True,
) -> Any:
"""Parses the body data as JSON and returns it.
Arguments:
force: Force JSON parsing even if the mimetype is not JSON.
silent: Do not trigger error handling if parsing fails,... | [
"async",
"def",
"get_json",
"(",
"self",
",",
"force",
":",
"bool",
"=",
"False",
",",
"silent",
":",
"bool",
"=",
"False",
",",
"cache",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Any",
":",
"if",
"cache",
"and",
"self",
".",
"_cached_json",
"is",... | Parses the body data as JSON and returns it.
Arguments:
force: Force JSON parsing even if the mimetype is not JSON.
silent: Do not trigger error handling if parsing fails, without
this the :meth:`on_json_loading_failed` will be called on
error.
... | [
"Parses",
"the",
"body",
"data",
"as",
"JSON",
"and",
"returns",
"it",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L54-L82 | train |
pgjones/quart | quart/wrappers/_base.py | _BaseRequestResponse.mimetype | def mimetype(self, value: str) -> None:
"""Set the mimetype to the value."""
if (
value.startswith('text/') or value == 'application/xml' or
(value.startswith('application/') and value.endswith('+xml'))
):
mimetype = f"{value}; charset={self.charset}"
... | python | def mimetype(self, value: str) -> None:
"""Set the mimetype to the value."""
if (
value.startswith('text/') or value == 'application/xml' or
(value.startswith('application/') and value.endswith('+xml'))
):
mimetype = f"{value}; charset={self.charset}"
... | [
"def",
"mimetype",
"(",
"self",
",",
"value",
":",
"str",
")",
"->",
"None",
":",
"if",
"(",
"value",
".",
"startswith",
"(",
"'text/'",
")",
"or",
"value",
"==",
"'application/xml'",
"or",
"(",
"value",
".",
"startswith",
"(",
"'application/'",
")",
"... | Set the mimetype to the value. | [
"Set",
"the",
"mimetype",
"to",
"the",
"value",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L117-L126 | train |
pgjones/quart | quart/wrappers/_base.py | BaseRequestWebsocket.blueprint | def blueprint(self) -> Optional[str]:
"""Returns the blueprint the matched endpoint belongs to.
This can be None if the request has not been matched or the
endpoint is not in a blueprint.
"""
if self.endpoint is not None and '.' in self.endpoint:
return self.endpoint... | python | def blueprint(self) -> Optional[str]:
"""Returns the blueprint the matched endpoint belongs to.
This can be None if the request has not been matched or the
endpoint is not in a blueprint.
"""
if self.endpoint is not None and '.' in self.endpoint:
return self.endpoint... | [
"def",
"blueprint",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"endpoint",
"is",
"not",
"None",
"and",
"'.'",
"in",
"self",
".",
"endpoint",
":",
"return",
"self",
".",
"endpoint",
".",
"rsplit",
"(",
"'.'",
",",
"... | Returns the blueprint the matched endpoint belongs to.
This can be None if the request has not been matched or the
endpoint is not in a blueprint. | [
"Returns",
"the",
"blueprint",
"the",
"matched",
"endpoint",
"belongs",
"to",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L195-L204 | train |
pgjones/quart | quart/wrappers/_base.py | BaseRequestWebsocket.base_url | def base_url(self) -> str:
"""Returns the base url without query string or fragments."""
return urlunparse(ParseResult(self.scheme, self.host, self.path, '', '', '')) | python | def base_url(self) -> str:
"""Returns the base url without query string or fragments."""
return urlunparse(ParseResult(self.scheme, self.host, self.path, '', '', '')) | [
"def",
"base_url",
"(",
"self",
")",
"->",
"str",
":",
"return",
"urlunparse",
"(",
"ParseResult",
"(",
"self",
".",
"scheme",
",",
"self",
".",
"host",
",",
"self",
".",
"path",
",",
"''",
",",
"''",
",",
"''",
")",
")"
] | Returns the base url without query string or fragments. | [
"Returns",
"the",
"base",
"url",
"without",
"query",
"string",
"or",
"fragments",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L266-L268 | train |
pgjones/quart | quart/wrappers/_base.py | BaseRequestWebsocket.url | def url(self) -> str:
"""Returns the full url requested."""
return urlunparse(
ParseResult(
self.scheme, self.host, self.path, '', self.query_string.decode('ascii'), '',
),
) | python | def url(self) -> str:
"""Returns the full url requested."""
return urlunparse(
ParseResult(
self.scheme, self.host, self.path, '', self.query_string.decode('ascii'), '',
),
) | [
"def",
"url",
"(",
"self",
")",
"->",
"str",
":",
"return",
"urlunparse",
"(",
"ParseResult",
"(",
"self",
".",
"scheme",
",",
"self",
".",
"host",
",",
"self",
".",
"path",
",",
"''",
",",
"self",
".",
"query_string",
".",
"decode",
"(",
"'ascii'",
... | Returns the full url requested. | [
"Returns",
"the",
"full",
"url",
"requested",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L286-L292 | train |
pgjones/quart | quart/wrappers/_base.py | BaseRequestWebsocket.cookies | def cookies(self) -> Dict[str, str]:
"""The parsed cookies attached to this request."""
cookies = SimpleCookie()
cookies.load(self.headers.get('Cookie', ''))
return {key: cookie.value for key, cookie in cookies.items()} | python | def cookies(self) -> Dict[str, str]:
"""The parsed cookies attached to this request."""
cookies = SimpleCookie()
cookies.load(self.headers.get('Cookie', ''))
return {key: cookie.value for key, cookie in cookies.items()} | [
"def",
"cookies",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"cookies",
"=",
"SimpleCookie",
"(",
")",
"cookies",
".",
"load",
"(",
"self",
".",
"headers",
".",
"get",
"(",
"'Cookie'",
",",
"''",
")",
")",
"return",
"{",
"k... | The parsed cookies attached to this request. | [
"The",
"parsed",
"cookies",
"attached",
"to",
"this",
"request",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/wrappers/_base.py#L307-L311 | train |
pgjones/quart | quart/config.py | Config.from_envvar | def from_envvar(self, variable_name: str, silent: bool=False) -> None:
"""Load the configuration from a location specified in the environment.
This will load a cfg file using :meth:`from_pyfile` from the
location specified in the environment, for example the two blocks
below are equival... | python | def from_envvar(self, variable_name: str, silent: bool=False) -> None:
"""Load the configuration from a location specified in the environment.
This will load a cfg file using :meth:`from_pyfile` from the
location specified in the environment, for example the two blocks
below are equival... | [
"def",
"from_envvar",
"(",
"self",
",",
"variable_name",
":",
"str",
",",
"silent",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"value",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"variable_name",
")",
"if",
"value",
"is",
"None",
"and",
"not... | Load the configuration from a location specified in the environment.
This will load a cfg file using :meth:`from_pyfile` from the
location specified in the environment, for example the two blocks
below are equivalent.
.. code-block:: python
app.config.from_envvar('CONFIG')... | [
"Load",
"the",
"configuration",
"from",
"a",
"location",
"specified",
"in",
"the",
"environment",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L88-L109 | train |
pgjones/quart | quart/config.py | Config.from_pyfile | def from_pyfile(self, filename: str, silent: bool=False) -> None:
"""Load the configuration from a Python cfg or py file.
See Python's ConfigParser docs for details on the cfg format.
It is a common practice to load the defaults from the source
using the :meth:`from_object` and then ove... | python | def from_pyfile(self, filename: str, silent: bool=False) -> None:
"""Load the configuration from a Python cfg or py file.
See Python's ConfigParser docs for details on the cfg format.
It is a common practice to load the defaults from the source
using the :meth:`from_object` and then ove... | [
"def",
"from_pyfile",
"(",
"self",
",",
"filename",
":",
"str",
",",
"silent",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"file_path",
"=",
"self",
".",
"root_path",
"/",
"filename",
"try",
":",
"spec",
"=",
"importlib",
".",
"util",
".",
"sp... | Load the configuration from a Python cfg or py file.
See Python's ConfigParser docs for details on the cfg format.
It is a common practice to load the defaults from the source
using the :meth:`from_object` and then override with a cfg or
py file, for example
.. code-block:: pyt... | [
"Load",
"the",
"configuration",
"from",
"a",
"Python",
"cfg",
"or",
"py",
"file",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L111-L145 | train |
pgjones/quart | quart/config.py | Config.from_object | def from_object(self, instance: Union[object, str]) -> None:
"""Load the configuration from a Python object.
This can be used to reference modules or objects within
modules for example,
.. code-block:: python
app.config.from_object('module')
app.config.from_obj... | python | def from_object(self, instance: Union[object, str]) -> None:
"""Load the configuration from a Python object.
This can be used to reference modules or objects within
modules for example,
.. code-block:: python
app.config.from_object('module')
app.config.from_obj... | [
"def",
"from_object",
"(",
"self",
",",
"instance",
":",
"Union",
"[",
"object",
",",
"str",
"]",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"instance",
",",
"str",
")",
":",
"try",
":",
"path",
",",
"config",
"=",
"instance",
".",
"rsplit",
... | Load the configuration from a Python object.
This can be used to reference modules or objects within
modules for example,
.. code-block:: python
app.config.from_object('module')
app.config.from_object('module.instance')
from module import instance
... | [
"Load",
"the",
"configuration",
"from",
"a",
"Python",
"object",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L147-L179 | train |
pgjones/quart | quart/config.py | Config.from_json | def from_json(self, filename: str, silent: bool=False) -> None:
"""Load the configuration values from a JSON formatted file.
This allows configuration to be loaded as so
.. code-block:: python
app.config.from_json('config.json')
Arguments:
filename: The filena... | python | def from_json(self, filename: str, silent: bool=False) -> None:
"""Load the configuration values from a JSON formatted file.
This allows configuration to be loaded as so
.. code-block:: python
app.config.from_json('config.json')
Arguments:
filename: The filena... | [
"def",
"from_json",
"(",
"self",
",",
"filename",
":",
"str",
",",
"silent",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"file_path",
"=",
"self",
".",
"root_path",
"/",
"filename",
"try",
":",
"with",
"open",
"(",
"file_path",
")",
"as",
"fil... | Load the configuration values from a JSON formatted file.
This allows configuration to be loaded as so
.. code-block:: python
app.config.from_json('config.json')
Arguments:
filename: The filename which when appended to
:attr:`root_path` gives the path ... | [
"Load",
"the",
"configuration",
"values",
"from",
"a",
"JSON",
"formatted",
"file",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L181-L203 | train |
pgjones/quart | quart/config.py | Config.from_mapping | def from_mapping(self, mapping: Optional[Mapping[str, Any]]=None, **kwargs: Any) -> None:
"""Load the configuration values from a mapping.
This allows either a mapping to be directly passed or as
keyword arguments, for example,
.. code-block:: python
config = {'FOO': 'bar'... | python | def from_mapping(self, mapping: Optional[Mapping[str, Any]]=None, **kwargs: Any) -> None:
"""Load the configuration values from a mapping.
This allows either a mapping to be directly passed or as
keyword arguments, for example,
.. code-block:: python
config = {'FOO': 'bar'... | [
"def",
"from_mapping",
"(",
"self",
",",
"mapping",
":",
"Optional",
"[",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"**",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"mappings",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"="... | Load the configuration values from a mapping.
This allows either a mapping to be directly passed or as
keyword arguments, for example,
.. code-block:: python
config = {'FOO': 'bar'}
app.config.from_mapping(config)
app.config.form_mapping(FOO='bar')
... | [
"Load",
"the",
"configuration",
"values",
"from",
"a",
"mapping",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L205-L228 | train |
pgjones/quart | quart/config.py | Config.get_namespace | def get_namespace(
self,
namespace: str,
lowercase: bool=True,
trim_namespace: bool=True,
) -> Dict[str, Any]:
"""Return a dictionary of keys within a namespace.
A namespace is considered to be a key prefix, for example the
keys ``FOO_A, FOO_B... | python | def get_namespace(
self,
namespace: str,
lowercase: bool=True,
trim_namespace: bool=True,
) -> Dict[str, Any]:
"""Return a dictionary of keys within a namespace.
A namespace is considered to be a key prefix, for example the
keys ``FOO_A, FOO_B... | [
"def",
"get_namespace",
"(",
"self",
",",
"namespace",
":",
"str",
",",
"lowercase",
":",
"bool",
"=",
"True",
",",
"trim_namespace",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"config",
"=",
"{",
"}",
"for"... | Return a dictionary of keys within a namespace.
A namespace is considered to be a key prefix, for example the
keys ``FOO_A, FOO_BAR, FOO_B`` are all within the ``FOO``
namespace. This method would return a dictionary with these
keys and values present.
.. code-block:: python
... | [
"Return",
"a",
"dictionary",
"of",
"keys",
"within",
"a",
"namespace",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L230-L265 | train |
pgjones/quart | quart/helpers.py | make_response | async def make_response(*args: Any) -> Response:
"""Create a response, a simple wrapper function.
This is most useful when you want to alter a Response before
returning it, for example
.. code-block:: python
response = make_response(render_template('index.html'))
response.headers['X-H... | python | async def make_response(*args: Any) -> Response:
"""Create a response, a simple wrapper function.
This is most useful when you want to alter a Response before
returning it, for example
.. code-block:: python
response = make_response(render_template('index.html'))
response.headers['X-H... | [
"async",
"def",
"make_response",
"(",
"*",
"args",
":",
"Any",
")",
"->",
"Response",
":",
"if",
"not",
"args",
":",
"return",
"current_app",
".",
"response_class",
"(",
")",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"args",
"=",
"args",
"[",
... | Create a response, a simple wrapper function.
This is most useful when you want to alter a Response before
returning it, for example
.. code-block:: python
response = make_response(render_template('index.html'))
response.headers['X-Header'] = 'Something' | [
"Create",
"a",
"response",
"a",
"simple",
"wrapper",
"function",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/helpers.py#L38-L55 | train |
pgjones/quart | quart/helpers.py | get_flashed_messages | def get_flashed_messages(
with_categories: bool=False,
category_filter: List[str]=[],
) -> Union[List[str], List[Tuple[str, str]]]:
"""Retrieve the flashed messages stored in the session.
This is mostly useful in templates where it is exposed as a global
function, for example
.. code-b... | python | def get_flashed_messages(
with_categories: bool=False,
category_filter: List[str]=[],
) -> Union[List[str], List[Tuple[str, str]]]:
"""Retrieve the flashed messages stored in the session.
This is mostly useful in templates where it is exposed as a global
function, for example
.. code-b... | [
"def",
"get_flashed_messages",
"(",
"with_categories",
":",
"bool",
"=",
"False",
",",
"category_filter",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
",",
")",
"->",
"Union",
"[",
"List",
"[",
"str",
"]",
",",
"List",
"[",
"Tuple",
"[",
"str",
",",
... | Retrieve the flashed messages stored in the session.
This is mostly useful in templates where it is exposed as a global
function, for example
.. code-block:: html+jinja
<ul>
{% for message in get_flashed_messages() %}
<li>{{ message }}</li>
{% endfor %}
</ul>
... | [
"Retrieve",
"the",
"flashed",
"messages",
"stored",
"in",
"the",
"session",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/helpers.py#L95-L121 | train |
pgjones/quart | quart/helpers.py | url_for | def url_for(
endpoint: str,
*,
_anchor: Optional[str]=None,
_external: Optional[bool]=None,
_method: Optional[str]=None,
_scheme: Optional[str]=None,
**values: Any,
) -> str:
"""Return the url for a specific endpoint.
This is most useful in templates and ... | python | def url_for(
endpoint: str,
*,
_anchor: Optional[str]=None,
_external: Optional[bool]=None,
_method: Optional[str]=None,
_scheme: Optional[str]=None,
**values: Any,
) -> str:
"""Return the url for a specific endpoint.
This is most useful in templates and ... | [
"def",
"url_for",
"(",
"endpoint",
":",
"str",
",",
"*",
",",
"_anchor",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"_external",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"_method",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",... | Return the url for a specific endpoint.
This is most useful in templates and redirects to create a URL
that can be used in the browser.
Arguments:
endpoint: The endpoint to build a url for, if prefixed with
``.`` it targets endpoint's in the current blueprint.
_anchor: Addition... | [
"Return",
"the",
"url",
"for",
"a",
"specific",
"endpoint",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/helpers.py#L137-L198 | train |
pgjones/quart | quart/helpers.py | stream_with_context | def stream_with_context(func: Callable) -> Callable:
"""Share the current request context with a generator.
This allows the request context to be accessed within a streaming
generator, for example,
.. code-block:: python
@app.route('/')
def index() -> AsyncGenerator[bytes, None]:
... | python | def stream_with_context(func: Callable) -> Callable:
"""Share the current request context with a generator.
This allows the request context to be accessed within a streaming
generator, for example,
.. code-block:: python
@app.route('/')
def index() -> AsyncGenerator[bytes, None]:
... | [
"def",
"stream_with_context",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"request_context",
"=",
"_request_ctx_stack",
".",
"top",
".",
"copy",
"(",
")",
"@",
"wraps",
"(",
"func",
")",
"async",
"def",
"generator",
"(",
"*",
"args",
":",
"... | Share the current request context with a generator.
This allows the request context to be accessed within a streaming
generator, for example,
.. code-block:: python
@app.route('/')
def index() -> AsyncGenerator[bytes, None]:
@stream_with_context
async def generator... | [
"Share",
"the",
"current",
"request",
"context",
"with",
"a",
"generator",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/helpers.py#L201-L227 | train |
pgjones/quart | quart/static.py | safe_join | def safe_join(directory: FilePath, *paths: FilePath) -> Path:
"""Safely join the paths to the known directory to return a full path.
Raises:
NotFound: if the full path does not share a commonprefix with
the directory.
"""
try:
safe_path = file_path_to_path(directory).resolve(str... | python | def safe_join(directory: FilePath, *paths: FilePath) -> Path:
"""Safely join the paths to the known directory to return a full path.
Raises:
NotFound: if the full path does not share a commonprefix with
the directory.
"""
try:
safe_path = file_path_to_path(directory).resolve(str... | [
"def",
"safe_join",
"(",
"directory",
":",
"FilePath",
",",
"*",
"paths",
":",
"FilePath",
")",
"->",
"Path",
":",
"try",
":",
"safe_path",
"=",
"file_path_to_path",
"(",
"directory",
")",
".",
"resolve",
"(",
"strict",
"=",
"True",
")",
"full_path",
"="... | Safely join the paths to the known directory to return a full path.
Raises:
NotFound: if the full path does not share a commonprefix with
the directory. | [
"Safely",
"join",
"the",
"paths",
"to",
"the",
"known",
"directory",
"to",
"return",
"a",
"full",
"path",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/static.py#L117-L133 | train |
pgjones/quart | quart/static.py | send_from_directory | async def send_from_directory(
directory: FilePath,
file_name: str,
*,
mimetype: Optional[str]=None,
as_attachment: bool=False,
attachment_filename: Optional[str]=None,
add_etags: bool=True,
cache_timeout: Optional[int]=None,
conditional: bool=True... | python | async def send_from_directory(
directory: FilePath,
file_name: str,
*,
mimetype: Optional[str]=None,
as_attachment: bool=False,
attachment_filename: Optional[str]=None,
add_etags: bool=True,
cache_timeout: Optional[int]=None,
conditional: bool=True... | [
"async",
"def",
"send_from_directory",
"(",
"directory",
":",
"FilePath",
",",
"file_name",
":",
"str",
",",
"*",
",",
"mimetype",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"as_attachment",
":",
"bool",
"=",
"False",
",",
"attachment_filename",
"... | Send a file from a given directory.
Arguments:
directory: Directory that when combined with file_name gives
the file path.
file_name: File name that when combined with directory gives
the file path.
See :func:`send_file` for the other arguments. | [
"Send",
"a",
"file",
"from",
"a",
"given",
"directory",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/static.py#L136-L169 | train |
pgjones/quart | quart/static.py | send_file | async def send_file(
filename: FilePath,
mimetype: Optional[str]=None,
as_attachment: bool=False,
attachment_filename: Optional[str]=None,
add_etags: bool=True,
cache_timeout: Optional[int]=None,
conditional: bool=False,
last_modified: Optional[datetime]=N... | python | async def send_file(
filename: FilePath,
mimetype: Optional[str]=None,
as_attachment: bool=False,
attachment_filename: Optional[str]=None,
add_etags: bool=True,
cache_timeout: Optional[int]=None,
conditional: bool=False,
last_modified: Optional[datetime]=N... | [
"async",
"def",
"send_file",
"(",
"filename",
":",
"FilePath",
",",
"mimetype",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"as_attachment",
":",
"bool",
"=",
"False",
",",
"attachment_filename",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
","... | Return a Reponse to send the filename given.
Arguments:
filename: The filename (path) to send, remember to use
:func:`safe_join`.
mimetype: Mimetype to use, by default it will be guessed or
revert to the DEFAULT_MIMETYPE.
as_attachment: If true use the attachment fil... | [
"Return",
"a",
"Reponse",
"to",
"send",
"the",
"filename",
"given",
"."
] | 7cb2d3bd98e8746025764f2b933abc12041fa175 | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/static.py#L172-L230 | train |
manrajgrover/halo | halo/halo.py | Halo._render_frame | def _render_frame(self):
"""Renders the frame on the line after clearing it.
"""
frame = self.frame()
output = '\r{0}'.format(frame)
self.clear()
try:
self._stream.write(output)
except UnicodeEncodeError:
self._stream.write(encode_utf_8_tex... | python | def _render_frame(self):
"""Renders the frame on the line after clearing it.
"""
frame = self.frame()
output = '\r{0}'.format(frame)
self.clear()
try:
self._stream.write(output)
except UnicodeEncodeError:
self._stream.write(encode_utf_8_tex... | [
"def",
"_render_frame",
"(",
"self",
")",
":",
"frame",
"=",
"self",
".",
"frame",
"(",
")",
"output",
"=",
"'\\r{0}'",
".",
"format",
"(",
"frame",
")",
"self",
".",
"clear",
"(",
")",
"try",
":",
"self",
".",
"_stream",
".",
"write",
"(",
"output... | Renders the frame on the line after clearing it. | [
"Renders",
"the",
"frame",
"on",
"the",
"line",
"after",
"clearing",
"it",
"."
] | 0ac5149dea965b27b09f0776df9095ebf013fb4d | https://github.com/manrajgrover/halo/blob/0ac5149dea965b27b09f0776df9095ebf013fb4d/halo/halo.py#L336-L345 | train |
manrajgrover/halo | halo/_utils.py | get_environment | def get_environment():
"""Get the environment in which halo is running
Returns
-------
str
Environment name
"""
try:
from IPython import get_ipython
except ImportError:
return 'terminal'
try:
shell = get_ipython().__class__.__name__
if shell == ... | python | def get_environment():
"""Get the environment in which halo is running
Returns
-------
str
Environment name
"""
try:
from IPython import get_ipython
except ImportError:
return 'terminal'
try:
shell = get_ipython().__class__.__name__
if shell == ... | [
"def",
"get_environment",
"(",
")",
":",
"try",
":",
"from",
"IPython",
"import",
"get_ipython",
"except",
"ImportError",
":",
"return",
"'terminal'",
"try",
":",
"shell",
"=",
"get_ipython",
"(",
")",
".",
"__class__",
".",
"__name__",
"if",
"shell",
"==",
... | Get the environment in which halo is running
Returns
-------
str
Environment name | [
"Get",
"the",
"environment",
"in",
"which",
"halo",
"is",
"running"
] | 0ac5149dea965b27b09f0776df9095ebf013fb4d | https://github.com/manrajgrover/halo/blob/0ac5149dea965b27b09f0776df9095ebf013fb4d/halo/_utils.py#L35-L59 | train |
manrajgrover/halo | halo/_utils.py | is_text_type | def is_text_type(text):
"""Check if given parameter is a string or not
Parameters
----------
text : *
Parameter to be checked for text type
Returns
-------
bool
Whether parameter is a string or not
"""
if isinstance(text, six.text_type) or isinstance(text, six.strin... | python | def is_text_type(text):
"""Check if given parameter is a string or not
Parameters
----------
text : *
Parameter to be checked for text type
Returns
-------
bool
Whether parameter is a string or not
"""
if isinstance(text, six.text_type) or isinstance(text, six.strin... | [
"def",
"is_text_type",
"(",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"six",
".",
"text_type",
")",
"or",
"isinstance",
"(",
"text",
",",
"six",
".",
"string_types",
")",
":",
"return",
"True",
"return",
"False"
] | Check if given parameter is a string or not
Parameters
----------
text : *
Parameter to be checked for text type
Returns
-------
bool
Whether parameter is a string or not | [
"Check",
"if",
"given",
"parameter",
"is",
"a",
"string",
"or",
"not"
] | 0ac5149dea965b27b09f0776df9095ebf013fb4d | https://github.com/manrajgrover/halo/blob/0ac5149dea965b27b09f0776df9095ebf013fb4d/halo/_utils.py#L80-L96 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | find_stateless_by_name | def find_stateless_by_name(name):
'''
Find stateless app given its name
First search the Django ORM, and if not found then look the app up in a local registry.
If the app does not have an ORM entry then a StatelessApp model instance is created.
'''
try:
dsa_app = StatelessApp.objects.ge... | python | def find_stateless_by_name(name):
'''
Find stateless app given its name
First search the Django ORM, and if not found then look the app up in a local registry.
If the app does not have an ORM entry then a StatelessApp model instance is created.
'''
try:
dsa_app = StatelessApp.objects.ge... | [
"def",
"find_stateless_by_name",
"(",
"name",
")",
":",
"try",
":",
"dsa_app",
"=",
"StatelessApp",
".",
"objects",
".",
"get",
"(",
"app_name",
"=",
"name",
")",
"return",
"dsa_app",
".",
"as_dash_app",
"(",
")",
"except",
":",
"pass",
"dash_app",
"=",
... | Find stateless app given its name
First search the Django ORM, and if not found then look the app up in a local registry.
If the app does not have an ORM entry then a StatelessApp model instance is created. | [
"Find",
"stateless",
"app",
"given",
"its",
"name"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L63-L79 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | StatelessApp.as_dash_app | def as_dash_app(self):
'''
Return a DjangoDash instance of the dash application
'''
dateless_dash_app = getattr(self, '_stateless_dash_app_instance', None)
if not dateless_dash_app:
dateless_dash_app = get_stateless_by_name(self.app_name)
setattr(self, '_s... | python | def as_dash_app(self):
'''
Return a DjangoDash instance of the dash application
'''
dateless_dash_app = getattr(self, '_stateless_dash_app_instance', None)
if not dateless_dash_app:
dateless_dash_app = get_stateless_by_name(self.app_name)
setattr(self, '_s... | [
"def",
"as_dash_app",
"(",
"self",
")",
":",
"dateless_dash_app",
"=",
"getattr",
"(",
"self",
",",
"'_stateless_dash_app_instance'",
",",
"None",
")",
"if",
"not",
"dateless_dash_app",
":",
"dateless_dash_app",
"=",
"get_stateless_by_name",
"(",
"self",
".",
"app... | Return a DjangoDash instance of the dash application | [
"Return",
"a",
"DjangoDash",
"instance",
"of",
"the",
"dash",
"application"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L53-L61 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | DashApp.handle_current_state | def handle_current_state(self):
'''
Check to see if the current hydrated state and the saved state are different.
If they are, then persist the current state in the database by saving the model instance.
'''
if getattr(self, '_current_state_hydrated_changed', False) and self.sav... | python | def handle_current_state(self):
'''
Check to see if the current hydrated state and the saved state are different.
If they are, then persist the current state in the database by saving the model instance.
'''
if getattr(self, '_current_state_hydrated_changed', False) and self.sav... | [
"def",
"handle_current_state",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'_current_state_hydrated_changed'",
",",
"False",
")",
"and",
"self",
".",
"save_on_change",
":",
"new_base_state",
"=",
"json",
".",
"dumps",
"(",
"getattr",
"(",
"self"... | Check to see if the current hydrated state and the saved state are different.
If they are, then persist the current state in the database by saving the model instance. | [
"Check",
"to",
"see",
"if",
"the",
"current",
"hydrated",
"state",
"and",
"the",
"saved",
"state",
"are",
"different",
"."
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L114-L124 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | DashApp.have_current_state_entry | def have_current_state_entry(self, wid, key):
'Return True if there is a cached current state for this app'
cscoll = self.current_state()
c_state = cscoll.get(wid, {})
return key in c_state | python | def have_current_state_entry(self, wid, key):
'Return True if there is a cached current state for this app'
cscoll = self.current_state()
c_state = cscoll.get(wid, {})
return key in c_state | [
"def",
"have_current_state_entry",
"(",
"self",
",",
"wid",
",",
"key",
")",
":",
"'Return True if there is a cached current state for this app'",
"cscoll",
"=",
"self",
".",
"current_state",
"(",
")",
"c_state",
"=",
"cscoll",
".",
"get",
"(",
"wid",
",",
"{",
... | Return True if there is a cached current state for this app | [
"Return",
"True",
"if",
"there",
"is",
"a",
"cached",
"current",
"state",
"for",
"this",
"app"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L126-L130 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | DashApp.current_state | def current_state(self):
'''
Return the current internal state of the model instance.
This is not necessarily the same as the persisted state
stored in the self.base_state variable.
'''
c_state = getattr(self, '_current_state_hydrated', None)
if not c_state:
... | python | def current_state(self):
'''
Return the current internal state of the model instance.
This is not necessarily the same as the persisted state
stored in the self.base_state variable.
'''
c_state = getattr(self, '_current_state_hydrated', None)
if not c_state:
... | [
"def",
"current_state",
"(",
"self",
")",
":",
"c_state",
"=",
"getattr",
"(",
"self",
",",
"'_current_state_hydrated'",
",",
"None",
")",
"if",
"not",
"c_state",
":",
"c_state",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"base_state",
")",
"setattr",
... | Return the current internal state of the model instance.
This is not necessarily the same as the persisted state
stored in the self.base_state variable. | [
"Return",
"the",
"current",
"internal",
"state",
"of",
"the",
"model",
"instance",
"."
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L146-L158 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | DashApp.as_dash_instance | def as_dash_instance(self, cache_id=None):
'Return a dash application instance for this model instance'
dash_app = self.stateless_app.as_dash_app() # pylint: disable=no-member
base = self.current_state()
return dash_app.do_form_dash_instance(replacements=base,
... | python | def as_dash_instance(self, cache_id=None):
'Return a dash application instance for this model instance'
dash_app = self.stateless_app.as_dash_app() # pylint: disable=no-member
base = self.current_state()
return dash_app.do_form_dash_instance(replacements=base,
... | [
"def",
"as_dash_instance",
"(",
"self",
",",
"cache_id",
"=",
"None",
")",
":",
"'Return a dash application instance for this model instance'",
"dash_app",
"=",
"self",
".",
"stateless_app",
".",
"as_dash_app",
"(",
")",
"base",
"=",
"self",
".",
"current_state",
"(... | Return a dash application instance for this model instance | [
"Return",
"a",
"dash",
"application",
"instance",
"for",
"this",
"model",
"instance"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L160-L166 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | DashApp._get_base_state | def _get_base_state(self):
'''
Get the base state of the object, as defined by the app.layout code, as a python dict
'''
base_app_inst = self.stateless_app.as_dash_app().as_dash_instance() # pylint: disable=no-member
# Get base layout response, from a base object
base_re... | python | def _get_base_state(self):
'''
Get the base state of the object, as defined by the app.layout code, as a python dict
'''
base_app_inst = self.stateless_app.as_dash_app().as_dash_instance() # pylint: disable=no-member
# Get base layout response, from a base object
base_re... | [
"def",
"_get_base_state",
"(",
"self",
")",
":",
"base_app_inst",
"=",
"self",
".",
"stateless_app",
".",
"as_dash_app",
"(",
")",
".",
"as_dash_instance",
"(",
")",
"base_resp",
"=",
"base_app_inst",
".",
"locate_endpoint_function",
"(",
"'dash-layout'",
")",
"... | Get the base state of the object, as defined by the app.layout code, as a python dict | [
"Get",
"the",
"base",
"state",
"of",
"the",
"object",
"as",
"defined",
"by",
"the",
"app",
".",
"layout",
"code",
"as",
"a",
"python",
"dict"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L168-L182 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | DashApp.populate_values | def populate_values(self):
'''
Add values from the underlying dash layout configuration
'''
obj = self._get_base_state()
self.base_state = json.dumps(obj) | python | def populate_values(self):
'''
Add values from the underlying dash layout configuration
'''
obj = self._get_base_state()
self.base_state = json.dumps(obj) | [
"def",
"populate_values",
"(",
"self",
")",
":",
"obj",
"=",
"self",
".",
"_get_base_state",
"(",
")",
"self",
".",
"base_state",
"=",
"json",
".",
"dumps",
"(",
"obj",
")"
] | Add values from the underlying dash layout configuration | [
"Add",
"values",
"from",
"the",
"underlying",
"dash",
"layout",
"configuration"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L184-L189 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/models.py | DashApp.locate_item | def locate_item(ident, stateless=False, cache_id=None):
'''Locate a dash application, given either the
slug of an instance or the name for a stateless app'''
if stateless:
dash_app = find_stateless_by_name(ident)
else:
dash_app = get_object_or_404(DashApp, slug=id... | python | def locate_item(ident, stateless=False, cache_id=None):
'''Locate a dash application, given either the
slug of an instance or the name for a stateless app'''
if stateless:
dash_app = find_stateless_by_name(ident)
else:
dash_app = get_object_or_404(DashApp, slug=id... | [
"def",
"locate_item",
"(",
"ident",
",",
"stateless",
"=",
"False",
",",
"cache_id",
"=",
"None",
")",
":",
"if",
"stateless",
":",
"dash_app",
"=",
"find_stateless_by_name",
"(",
"ident",
")",
"else",
":",
"dash_app",
"=",
"get_object_or_404",
"(",
"DashApp... | Locate a dash application, given either the
slug of an instance or the name for a stateless app | [
"Locate",
"a",
"dash",
"application",
"given",
"either",
"the",
"slug",
"of",
"an",
"instance",
"or",
"the",
"name",
"for",
"a",
"stateless",
"app"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/models.py#L192-L201 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/consumers.py | send_to_pipe_channel | def send_to_pipe_channel(channel_name,
label,
value):
'Send message through pipe to client component'
async_to_sync(async_send_to_pipe_channel)(channel_name=channel_name,
label=label,
... | python | def send_to_pipe_channel(channel_name,
label,
value):
'Send message through pipe to client component'
async_to_sync(async_send_to_pipe_channel)(channel_name=channel_name,
label=label,
... | [
"def",
"send_to_pipe_channel",
"(",
"channel_name",
",",
"label",
",",
"value",
")",
":",
"'Send message through pipe to client component'",
"async_to_sync",
"(",
"async_send_to_pipe_channel",
")",
"(",
"channel_name",
"=",
"channel_name",
",",
"label",
"=",
"label",
",... | Send message through pipe to client component | [
"Send",
"message",
"through",
"pipe",
"to",
"client",
"component"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/consumers.py#L35-L41 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/consumers.py | async_send_to_pipe_channel | async def async_send_to_pipe_channel(channel_name,
label,
value):
'Send message asynchronously through pipe to client component'
pcn = _form_pipe_channel_name(channel_name)
channel_layer = get_channel_layer()
await channel_layer.... | python | async def async_send_to_pipe_channel(channel_name,
label,
value):
'Send message asynchronously through pipe to client component'
pcn = _form_pipe_channel_name(channel_name)
channel_layer = get_channel_layer()
await channel_layer.... | [
"async",
"def",
"async_send_to_pipe_channel",
"(",
"channel_name",
",",
"label",
",",
"value",
")",
":",
"'Send message asynchronously through pipe to client component'",
"pcn",
"=",
"_form_pipe_channel_name",
"(",
"channel_name",
")",
"channel_layer",
"=",
"get_channel_layer... | Send message asynchronously through pipe to client component | [
"Send",
"message",
"asynchronously",
"through",
"pipe",
"to",
"client",
"component"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/consumers.py#L43-L53 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/consumers.py | MessageConsumer.pipe_value | def pipe_value(self, message):
'Send a new value into the ws pipe'
jmsg = json.dumps(message)
self.send(jmsg) | python | def pipe_value(self, message):
'Send a new value into the ws pipe'
jmsg = json.dumps(message)
self.send(jmsg) | [
"def",
"pipe_value",
"(",
"self",
",",
"message",
")",
":",
"'Send a new value into the ws pipe'",
"jmsg",
"=",
"json",
".",
"dumps",
"(",
"message",
")",
"self",
".",
"send",
"(",
"jmsg",
")"
] | Send a new value into the ws pipe | [
"Send",
"a",
"new",
"value",
"into",
"the",
"ws",
"pipe"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/consumers.py#L72-L75 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/consumers.py | MessageConsumer.update_pipe_channel | def update_pipe_channel(self, uid, channel_name, label): # pylint: disable=unused-argument
'''
Update this consumer to listen on channel_name for the js widget associated with uid
'''
pipe_group_name = _form_pipe_channel_name(channel_name)
if self.channel_layer:
curr... | python | def update_pipe_channel(self, uid, channel_name, label): # pylint: disable=unused-argument
'''
Update this consumer to listen on channel_name for the js widget associated with uid
'''
pipe_group_name = _form_pipe_channel_name(channel_name)
if self.channel_layer:
curr... | [
"def",
"update_pipe_channel",
"(",
"self",
",",
"uid",
",",
"channel_name",
",",
"label",
")",
":",
"pipe_group_name",
"=",
"_form_pipe_channel_name",
"(",
"channel_name",
")",
"if",
"self",
".",
"channel_layer",
":",
"current",
"=",
"self",
".",
"channel_maps",... | Update this consumer to listen on channel_name for the js widget associated with uid | [
"Update",
"this",
"consumer",
"to",
"listen",
"on",
"channel_name",
"for",
"the",
"js",
"widget",
"associated",
"with",
"uid"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/consumers.py#L77-L90 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/util.py | store_initial_arguments | def store_initial_arguments(request, initial_arguments=None):
'Store initial arguments, if any, and return a cache identifier'
if initial_arguments is None:
return None
# Generate a cache id
cache_id = "dpd-initial-args-%s" % str(uuid.uuid4()).replace('-', '')
# Store args in json form in... | python | def store_initial_arguments(request, initial_arguments=None):
'Store initial arguments, if any, and return a cache identifier'
if initial_arguments is None:
return None
# Generate a cache id
cache_id = "dpd-initial-args-%s" % str(uuid.uuid4()).replace('-', '')
# Store args in json form in... | [
"def",
"store_initial_arguments",
"(",
"request",
",",
"initial_arguments",
"=",
"None",
")",
":",
"'Store initial arguments, if any, and return a cache identifier'",
"if",
"initial_arguments",
"is",
"None",
":",
"return",
"None",
"cache_id",
"=",
"\"dpd-initial-args-%s\"",
... | Store initial arguments, if any, and return a cache identifier | [
"Store",
"initial",
"arguments",
"if",
"any",
"and",
"return",
"a",
"cache",
"identifier"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/util.py#L72-L87 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/util.py | get_initial_arguments | def get_initial_arguments(request, cache_id=None):
'Extract initial arguments for the dash app'
if cache_id is None:
return None
if initial_argument_location():
return cache.get(cache_id)
return request.session[cache_id] | python | def get_initial_arguments(request, cache_id=None):
'Extract initial arguments for the dash app'
if cache_id is None:
return None
if initial_argument_location():
return cache.get(cache_id)
return request.session[cache_id] | [
"def",
"get_initial_arguments",
"(",
"request",
",",
"cache_id",
"=",
"None",
")",
":",
"'Extract initial arguments for the dash app'",
"if",
"cache_id",
"is",
"None",
":",
"return",
"None",
"if",
"initial_argument_location",
"(",
")",
":",
"return",
"cache",
".",
... | Extract initial arguments for the dash app | [
"Extract",
"initial",
"arguments",
"for",
"the",
"dash",
"app"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/util.py#L89-L98 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/views.py | dependencies | def dependencies(request, ident, stateless=False, **kwargs):
'Return the dependencies'
_, app = DashApp.locate_item(ident, stateless)
with app.app_context():
view_func = app.locate_endpoint_function('dash-dependencies')
resp = view_func()
return HttpResponse(resp.data,
... | python | def dependencies(request, ident, stateless=False, **kwargs):
'Return the dependencies'
_, app = DashApp.locate_item(ident, stateless)
with app.app_context():
view_func = app.locate_endpoint_function('dash-dependencies')
resp = view_func()
return HttpResponse(resp.data,
... | [
"def",
"dependencies",
"(",
"request",
",",
"ident",
",",
"stateless",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"'Return the dependencies'",
"_",
",",
"app",
"=",
"DashApp",
".",
"locate_item",
"(",
"ident",
",",
"stateless",
")",
"with",
"app",
".",
... | Return the dependencies | [
"Return",
"the",
"dependencies"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/views.py#L39-L47 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/views.py | layout | def layout(request, ident, stateless=False, cache_id=None, **kwargs):
'Return the layout of the dash application'
_, app = DashApp.locate_item(ident, stateless)
view_func = app.locate_endpoint_function('dash-layout')
resp = view_func()
initial_arguments = get_initial_arguments(request, cache_id)
... | python | def layout(request, ident, stateless=False, cache_id=None, **kwargs):
'Return the layout of the dash application'
_, app = DashApp.locate_item(ident, stateless)
view_func = app.locate_endpoint_function('dash-layout')
resp = view_func()
initial_arguments = get_initial_arguments(request, cache_id)
... | [
"def",
"layout",
"(",
"request",
",",
"ident",
",",
"stateless",
"=",
"False",
",",
"cache_id",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"'Return the layout of the dash application'",
"_",
",",
"app",
"=",
"DashApp",
".",
"locate_item",
"(",
"ident",
",",... | Return the layout of the dash application | [
"Return",
"the",
"layout",
"of",
"the",
"dash",
"application"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/views.py#L49-L60 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/views.py | update | def update(request, ident, stateless=False, **kwargs):
'Generate update json response'
dash_app, app = DashApp.locate_item(ident, stateless)
request_body = json.loads(request.body.decode('utf-8'))
if app.use_dash_dispatch():
# Force call through dash
view_func = app.locate_endpoint_fun... | python | def update(request, ident, stateless=False, **kwargs):
'Generate update json response'
dash_app, app = DashApp.locate_item(ident, stateless)
request_body = json.loads(request.body.decode('utf-8'))
if app.use_dash_dispatch():
# Force call through dash
view_func = app.locate_endpoint_fun... | [
"def",
"update",
"(",
"request",
",",
"ident",
",",
"stateless",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"'Generate update json response'",
"dash_app",
",",
"app",
"=",
"DashApp",
".",
"locate_item",
"(",
"ident",
",",
"stateless",
")",
"request_body",
... | Generate update json response | [
"Generate",
"update",
"json",
"response"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/views.py#L62-L102 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/views.py | main_view | def main_view(request, ident, stateless=False, cache_id=None, **kwargs):
'Main view for a dash app'
_, app = DashApp.locate_item(ident, stateless, cache_id=cache_id)
view_func = app.locate_endpoint_function()
resp = view_func()
return HttpResponse(resp) | python | def main_view(request, ident, stateless=False, cache_id=None, **kwargs):
'Main view for a dash app'
_, app = DashApp.locate_item(ident, stateless, cache_id=cache_id)
view_func = app.locate_endpoint_function()
resp = view_func()
return HttpResponse(resp) | [
"def",
"main_view",
"(",
"request",
",",
"ident",
",",
"stateless",
"=",
"False",
",",
"cache_id",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"'Main view for a dash app'",
"_",
",",
"app",
"=",
"DashApp",
".",
"locate_item",
"(",
"ident",
",",
"stateless"... | Main view for a dash app | [
"Main",
"view",
"for",
"a",
"dash",
"app"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/views.py#L104-L110 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/views.py | app_assets | def app_assets(request, **kwargs):
'Return a local dash app asset, served up through the Django static framework'
get_params = request.GET.urlencode()
extra_part = ""
if get_params:
redone_url = "/static/dash/assets/%s?%s" %(extra_part, get_params)
else:
redone_url = "/static/dash/as... | python | def app_assets(request, **kwargs):
'Return a local dash app asset, served up through the Django static framework'
get_params = request.GET.urlencode()
extra_part = ""
if get_params:
redone_url = "/static/dash/assets/%s?%s" %(extra_part, get_params)
else:
redone_url = "/static/dash/as... | [
"def",
"app_assets",
"(",
"request",
",",
"**",
"kwargs",
")",
":",
"'Return a local dash app asset, served up through the Django static framework'",
"get_params",
"=",
"request",
".",
"GET",
".",
"urlencode",
"(",
")",
"extra_part",
"=",
"\"\"",
"if",
"get_params",
"... | Return a local dash app asset, served up through the Django static framework | [
"Return",
"a",
"local",
"dash",
"app",
"asset",
"served",
"up",
"through",
"the",
"Django",
"static",
"framework"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/views.py#L131-L140 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/views.py | add_to_session | def add_to_session(request, template_name="index.html", **kwargs):
'Add some info to a session in a place that django-plotly-dash can pass to a callback'
django_plotly_dash = request.session.get("django_plotly_dash", dict())
session_add_count = django_plotly_dash.get('add_counter', 0)
django_plotly_da... | python | def add_to_session(request, template_name="index.html", **kwargs):
'Add some info to a session in a place that django-plotly-dash can pass to a callback'
django_plotly_dash = request.session.get("django_plotly_dash", dict())
session_add_count = django_plotly_dash.get('add_counter', 0)
django_plotly_da... | [
"def",
"add_to_session",
"(",
"request",
",",
"template_name",
"=",
"\"index.html\"",
",",
"**",
"kwargs",
")",
":",
"'Add some info to a session in a place that django-plotly-dash can pass to a callback'",
"django_plotly_dash",
"=",
"request",
".",
"session",
".",
"get",
"... | Add some info to a session in a place that django-plotly-dash can pass to a callback | [
"Add",
"some",
"info",
"to",
"a",
"session",
"in",
"a",
"place",
"that",
"django",
"-",
"plotly",
"-",
"dash",
"can",
"pass",
"to",
"a",
"callback"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/views.py#L145-L154 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/views.py | asset_redirection | def asset_redirection(request, path, ident=None, stateless=False, **kwargs):
'Redirect static assets for a component'
X, app = DashApp.locate_item(ident, stateless)
# Redirect to a location based on the import path of the module containing the DjangoDash app
static_path = X.get_asset_static_url(path)
... | python | def asset_redirection(request, path, ident=None, stateless=False, **kwargs):
'Redirect static assets for a component'
X, app = DashApp.locate_item(ident, stateless)
# Redirect to a location based on the import path of the module containing the DjangoDash app
static_path = X.get_asset_static_url(path)
... | [
"def",
"asset_redirection",
"(",
"request",
",",
"path",
",",
"ident",
"=",
"None",
",",
"stateless",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"'Redirect static assets for a component'",
"X",
",",
"app",
"=",
"DashApp",
".",
"locate_item",
"(",
"ident",
... | Redirect static assets for a component | [
"Redirect",
"static",
"assets",
"for",
"a",
"component"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/views.py#L156-L164 | train |
GibbsConsulting/django-plotly-dash | demo/demo/views.py | dash_example_1_view | def dash_example_1_view(request, template_name="demo_six.html", **kwargs):
'Example view that inserts content into the dash context passed to the dash application'
context = {}
# create some context to send over to Dash:
dash_context = request.session.get("django_plotly_dash", dict())
dash_context... | python | def dash_example_1_view(request, template_name="demo_six.html", **kwargs):
'Example view that inserts content into the dash context passed to the dash application'
context = {}
# create some context to send over to Dash:
dash_context = request.session.get("django_plotly_dash", dict())
dash_context... | [
"def",
"dash_example_1_view",
"(",
"request",
",",
"template_name",
"=",
"\"demo_six.html\"",
",",
"**",
"kwargs",
")",
":",
"'Example view that inserts content into the dash context passed to the dash application'",
"context",
"=",
"{",
"}",
"dash_context",
"=",
"request",
... | Example view that inserts content into the dash context passed to the dash application | [
"Example",
"view",
"that",
"inserts",
"content",
"into",
"the",
"dash",
"context",
"passed",
"to",
"the",
"dash",
"application"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/views.py#L9-L19 | train |
GibbsConsulting/django-plotly-dash | demo/demo/views.py | session_state_view | def session_state_view(request, template_name, **kwargs):
'Example view that exhibits the use of sessions to store state'
session = request.session
demo_count = session.get('django_plotly_dash', {})
ind_use = demo_count.get('ind_use', 0)
ind_use += 1
demo_count['ind_use'] = ind_use
conte... | python | def session_state_view(request, template_name, **kwargs):
'Example view that exhibits the use of sessions to store state'
session = request.session
demo_count = session.get('django_plotly_dash', {})
ind_use = demo_count.get('ind_use', 0)
ind_use += 1
demo_count['ind_use'] = ind_use
conte... | [
"def",
"session_state_view",
"(",
"request",
",",
"template_name",
",",
"**",
"kwargs",
")",
":",
"'Example view that exhibits the use of sessions to store state'",
"session",
"=",
"request",
".",
"session",
"demo_count",
"=",
"session",
".",
"get",
"(",
"'django_plotly... | Example view that exhibits the use of sessions to store state | [
"Example",
"view",
"that",
"exhibits",
"the",
"use",
"of",
"sessions",
"to",
"store",
"state"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/views.py#L21-L36 | train |
GibbsConsulting/django-plotly-dash | django_plotly_dash/middleware.py | ContentCollector.adjust_response | def adjust_response(self, response):
'Locate placeholder magic strings and replace with content'
try:
c1 = self._replace(response.content,
self.header_placeholder,
self.embedded_holder.css)
response.content = self._r... | python | def adjust_response(self, response):
'Locate placeholder magic strings and replace with content'
try:
c1 = self._replace(response.content,
self.header_placeholder,
self.embedded_holder.css)
response.content = self._r... | [
"def",
"adjust_response",
"(",
"self",
",",
"response",
")",
":",
"'Locate placeholder magic strings and replace with content'",
"try",
":",
"c1",
"=",
"self",
".",
"_replace",
"(",
"response",
".",
"content",
",",
"self",
".",
"header_placeholder",
",",
"self",
"... | Locate placeholder magic strings and replace with content | [
"Locate",
"placeholder",
"magic",
"strings",
"and",
"replace",
"with",
"content"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/middleware.py#L65-L81 | train |
GibbsConsulting/django-plotly-dash | demo/demo/plotly_apps.py | callback_c | def callback_c(*args, **kwargs):
'Update the output following a change of the input selection'
#da = kwargs['dash_app']
session_state = kwargs['session_state']
calls_so_far = session_state.get('calls_so_far', 0)
session_state['calls_so_far'] = calls_so_far + 1
user_counts = session_state.get(... | python | def callback_c(*args, **kwargs):
'Update the output following a change of the input selection'
#da = kwargs['dash_app']
session_state = kwargs['session_state']
calls_so_far = session_state.get('calls_so_far', 0)
session_state['calls_so_far'] = calls_so_far + 1
user_counts = session_state.get(... | [
"def",
"callback_c",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"'Update the output following a change of the input selection'",
"session_state",
"=",
"kwargs",
"[",
"'session_state'",
"]",
"calls_so_far",
"=",
"session_state",
".",
"get",
"(",
"'calls_so_far'",
... | Update the output following a change of the input selection | [
"Update",
"the",
"output",
"following",
"a",
"change",
"of",
"the",
"input",
"selection"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/plotly_apps.py#L101-L118 | train |
GibbsConsulting/django-plotly-dash | demo/demo/plotly_apps.py | callback_liveIn_button_press | def callback_liveIn_button_press(red_clicks, blue_clicks, green_clicks,
rc_timestamp, bc_timestamp, gc_timestamp, **kwargs): # pylint: disable=unused-argument
'Input app button pressed, so do something interesting'
if not rc_timestamp:
rc_timestamp = 0
if not bc_tim... | python | def callback_liveIn_button_press(red_clicks, blue_clicks, green_clicks,
rc_timestamp, bc_timestamp, gc_timestamp, **kwargs): # pylint: disable=unused-argument
'Input app button pressed, so do something interesting'
if not rc_timestamp:
rc_timestamp = 0
if not bc_tim... | [
"def",
"callback_liveIn_button_press",
"(",
"red_clicks",
",",
"blue_clicks",
",",
"green_clicks",
",",
"rc_timestamp",
",",
"bc_timestamp",
",",
"gc_timestamp",
",",
"**",
"kwargs",
")",
":",
"'Input app button pressed, so do something interesting'",
"if",
"not",
"rc_tim... | Input app button pressed, so do something interesting | [
"Input",
"app",
"button",
"pressed",
"so",
"do",
"something",
"interesting"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/plotly_apps.py#L149-L188 | train |
GibbsConsulting/django-plotly-dash | demo/demo/plotly_apps.py | generate_liveOut_layout | def generate_liveOut_layout():
'Generate the layout per-app, generating each tine a new uuid for the state_uid argument'
return html.Div([
dpd.Pipe(id="named_count_pipe",
value=None,
label="named_counts",
channel_name="live_button_counter"),
htm... | python | def generate_liveOut_layout():
'Generate the layout per-app, generating each tine a new uuid for the state_uid argument'
return html.Div([
dpd.Pipe(id="named_count_pipe",
value=None,
label="named_counts",
channel_name="live_button_counter"),
htm... | [
"def",
"generate_liveOut_layout",
"(",
")",
":",
"'Generate the layout per-app, generating each tine a new uuid for the state_uid argument'",
"return",
"html",
".",
"Div",
"(",
"[",
"dpd",
".",
"Pipe",
"(",
"id",
"=",
"\"named_count_pipe\"",
",",
"value",
"=",
"None",
"... | Generate the layout per-app, generating each tine a new uuid for the state_uid argument | [
"Generate",
"the",
"layout",
"per",
"-",
"app",
"generating",
"each",
"tine",
"a",
"new",
"uuid",
"for",
"the",
"state_uid",
"argument"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/plotly_apps.py#L195-L210 | train |
GibbsConsulting/django-plotly-dash | demo/demo/plotly_apps.py | callback_liveOut_pipe_in | def callback_liveOut_pipe_in(named_count, state_uid, **kwargs):
'Handle something changing the value of the input pipe or the associated state uid'
cache_key = _get_cache_key(state_uid)
state = cache.get(cache_key)
# If nothing in cache, prepopulate
if not state:
state = {}
# Guard ag... | python | def callback_liveOut_pipe_in(named_count, state_uid, **kwargs):
'Handle something changing the value of the input pipe or the associated state uid'
cache_key = _get_cache_key(state_uid)
state = cache.get(cache_key)
# If nothing in cache, prepopulate
if not state:
state = {}
# Guard ag... | [
"def",
"callback_liveOut_pipe_in",
"(",
"named_count",
",",
"state_uid",
",",
"**",
"kwargs",
")",
":",
"'Handle something changing the value of the input pipe or the associated state uid'",
"cache_key",
"=",
"_get_cache_key",
"(",
"state_uid",
")",
"state",
"=",
"cache",
"... | Handle something changing the value of the input pipe or the associated state uid | [
"Handle",
"something",
"changing",
"the",
"value",
"of",
"the",
"input",
"pipe",
"or",
"the",
"associated",
"state",
"uid"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/plotly_apps.py#L221-L266 | train |
GibbsConsulting/django-plotly-dash | demo/demo/plotly_apps.py | callback_show_timeseries | def callback_show_timeseries(internal_state_string, state_uid, **kwargs):
'Build a timeseries from the internal state'
cache_key = _get_cache_key(state_uid)
state = cache.get(cache_key)
# If nothing in cache, prepopulate
if not state:
state = {}
colour_series = {}
colors = {'red'... | python | def callback_show_timeseries(internal_state_string, state_uid, **kwargs):
'Build a timeseries from the internal state'
cache_key = _get_cache_key(state_uid)
state = cache.get(cache_key)
# If nothing in cache, prepopulate
if not state:
state = {}
colour_series = {}
colors = {'red'... | [
"def",
"callback_show_timeseries",
"(",
"internal_state_string",
",",
"state_uid",
",",
"**",
"kwargs",
")",
":",
"'Build a timeseries from the internal state'",
"cache_key",
"=",
"_get_cache_key",
"(",
"state_uid",
")",
"state",
"=",
"cache",
".",
"get",
"(",
"cache_... | Build a timeseries from the internal state | [
"Build",
"a",
"timeseries",
"from",
"the",
"internal",
"state"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/plotly_apps.py#L273-L311 | train |
GibbsConsulting/django-plotly-dash | demo/demo/bootstrap_app.py | session_demo_danger_callback | def session_demo_danger_callback(da_children, session_state=None, **kwargs):
'Update output based just on state'
if not session_state:
return "Session state not yet available"
return "Session state contains: " + str(session_state.get('bootstrap_demo_state', "NOTHING")) + " and the page render count... | python | def session_demo_danger_callback(da_children, session_state=None, **kwargs):
'Update output based just on state'
if not session_state:
return "Session state not yet available"
return "Session state contains: " + str(session_state.get('bootstrap_demo_state', "NOTHING")) + " and the page render count... | [
"def",
"session_demo_danger_callback",
"(",
"da_children",
",",
"session_state",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"'Update output based just on state'",
"if",
"not",
"session_state",
":",
"return",
"\"Session state not yet available\"",
"return",
"\"Session state... | Update output based just on state | [
"Update",
"output",
"based",
"just",
"on",
"state"
] | 773ed081fc2ea3cc7607590322a14686a7a79bc5 | https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/demo/demo/bootstrap_app.py#L57-L62 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.