mirror of
https://github.com/simonw/datasette.git
synced 2026-06-07 01:27:00 +02:00
await_me_maybe utility function
This commit is contained in:
parent
f65c45674d
commit
26b2922f17
3 changed files with 20 additions and 34 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import asyncio
|
||||
from contextlib import contextmanager
|
||||
from collections import OrderedDict
|
||||
import base64
|
||||
|
|
@ -51,6 +52,14 @@ ENV SQLITE_EXTENSIONS /usr/lib/x86_64-linux-gnu/mod_spatialite.so
|
|||
"""
|
||||
|
||||
|
||||
async def await_me_maybe(value):
|
||||
if callable(value):
|
||||
value = value()
|
||||
if asyncio.iscoroutine(value):
|
||||
value = await value
|
||||
return value
|
||||
|
||||
|
||||
def urlsafe_components(token):
|
||||
"Splits token on commas and URL decodes each component"
|
||||
return [urllib.parse.unquote_plus(b) for b in token.split(",")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue