Safely query whether an API is importable, without importing it
(api)
| 190 | |
| 191 | |
| 192 | def can_import(api): |
| 193 | """Safely query whether an API is importable, without importing it""" |
| 194 | if not has_binding(api): |
| 195 | return False |
| 196 | |
| 197 | current = loaded_api() |
| 198 | if api == QT_API_PYQT_DEFAULT: |
| 199 | return current in [QT_API_PYQT, QT_API_PYQTv1, QT_API_PYQT5, QT_API_PYQT6, None] |
| 200 | else: |
| 201 | return current in [api, None] |
| 202 | |
| 203 | |
| 204 | def import_pyqt4(version=2): |
no test coverage detected