| 1 |
""" |
| 2 |
flask_security.quart_compat |
| 3 |
~~~~~~~~~~~~~~~~~~~~ |
| 4 |
|
| 5 |
Flask-Security quart compatibility modiles |
| 6 |
|
| 7 |
:copyright: (c) 2019 by Shinon. |
| 8 |
:license: MIT, see LICENSE for more details. |
| 9 |
|
| 10 |
This modules tests whether we are using quart or not |
| 11 |
we can test if the name of the imported flask is: quart.flask_patch |
| 12 |
""" |
| 13 |
|
| 14 |
import flask |
| 15 |
|
| 16 |
if "quart." in flask.__name__ or hasattr(flask, "_quart_patched"): # pragma: no cover |
| 17 |
is_quart = True |
| 18 |
else: |
| 19 |
is_quart = False |
| 20 |
|
| 21 |
|
| 22 |
@property # type: ignore |
| 23 |
def best(self): # pragma: no cover |
| 24 |
options = sorted( |
| 25 |
self.options, |
| 26 |
key=lambda option: (option.value != "*", option.quality, option.value), |
| 27 |
reverse=True, |
| 28 |
) |
| 29 |
return options[0].value |
| 30 |
|
| 31 |
|
| 32 |
def get_quart_status(): |
| 33 |
""" |
| 34 |
Tests if we are using Quart Patched Flask or Vanilla Flask. |
| 35 |
:return: boolean value determining if it is quart patched flask or not |
| 36 |
""" |
| 37 |
return is_quart |