parameters: (api)
return_statement: return True
docstring: Safely check for PyQt4/5, PySide or PySide2, without importing submodules
  
          Parameters
          ----------
          api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
               Which module to check for
  
          Returns
          -------
          True if the relevant module appears to be importable
docstring_summary: Safely check for PyQt4/5, PySide or PySide2, without importing submodules
docstring_tokens: Safely check for PyQt4 / 5 PySide or PySide2 without importing submodules
function: def has_binding(api):
      """Safely check for PyQt4/5, PySide or PySide2, without importing submodules
  
          Parameters
          ----------
          api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
               Which module to check for
  
          Returns
          -------
          True if the relevant module appears to be importable
       """
      module_name = api_to_module[api]
      from importlib.util import find_spec
  
      required = ['QtCore', 'QtGui', 'QtSvg']
      if api in (QT_API_PYQT5, QT_API_PYSIDE2, QT_API_PYQT6, QT_API_PYSIDE6):
          # QT5 requires QtWidgets too
          required.append('QtWidgets')
  
      for submod in required:
          try:
              spec = find_spec('%s.%s' % (module_name, submod))
          except ImportError:
              # Package (e.g. PyQt5) not found
              return False
          else:
              if spec is None:
                  # Submodule (e.g. PyQt5.QtCore) not found
                  return False
  
      if api == QT_API_PYSIDE:
          # We can also safely check PySide version
          import PySide
          return check_version(PySide.__version__, '1.0.3')
  
      return True
function_tokens: def has_binding ( api ) : module_name = api_to_module [ api ] from importlib . util import find_spec required = [ 'QtCore' , 'QtGui' , 'QtSvg' ] if api in ( QT_API_PYQT5 , QT_API_PYSIDE2 , QT_API_PYQT6 , QT_API_PYSIDE6 ) : # QT5 requires QtWidgets too required . append ( 'QtWidgets' ) for submod in required : try : spec = find_spec ( '%s.%s' % ( module_name , submod ) ) except ImportError : # Package (e.g. PyQt5) not found return False else : if spec is None : # Submodule (e.g. PyQt5.QtCore) not found return False if api == QT_API_PYSIDE : # We can also safely check PySide version import PySide return check_version ( PySide . __version__ , '1.0.3' ) return True