@@ -156,11 +156,11 @@ def get_available_api(apis_to_search):
156156
157157def get_api_information (api_name ):
158158 """Get API information of version and Qt version.
159-
159+
160160 ``api_name`` is an importing name, case sensitive.
161161
162- Note: this function is not prepared to be called more than once.
163- Multiple calls will accumulate imports on sys.modules if they are
162+ Note: this function is not prepared to be called more than once, yet .
163+ Multiple calls will accumulate imports on sys.modules if api_name is
164164 installed. It must be rewrite to use pkgutil/importlib to check
165165 check version numbers.
166166 """
@@ -236,7 +236,8 @@ def get_api_information(api_name):
236236
237237# All False/None because they were not imported yet
238238PYQT5 = PYQT4 = PYSIDE = PYSIDE2 = False
239- API_VERSION = QT_VERSION = ''
239+ API_NAME = API_VERSION = QT_VERSION = ''
240+ PYQT_VERSION = PYSIDE_VERSION = None
240241
241242is_old_pyqt = is_pyqt46 = False
242243api_trial = []
@@ -248,8 +249,8 @@ def get_api_information(api_name):
248249# Check if it was correctly set with environment variable
249250if env_api not in api_names .keys ():
250251 raise PythonQtError ('Qt binding "{}" is unknown, please use a name '
251- '(not case sensitive) from {}' .format (env_api ,
252- list (api_names .keys ())))
252+ '(not case sensitive) from {}. ' .format (env_api ,
253+ list (api_names .keys ())))
253254environment_api_list = api_names [env_api ]
254255
255256# Check if Qt binding was already imported in 'sys.modules'
@@ -260,7 +261,7 @@ def get_api_information(api_name):
260261if len (imported_api_list ) >= 2 :
261262 warnings .warn ('There is more than one imported Qt binding {}. '
262263 'This may cause some issues, check your code '
263- 'consistence' .format (imported_api_list ), RuntimeWarning )
264+ 'consistence. ' .format (imported_api_list ), RuntimeWarning )
264265
265266# Priority for imported binding(s), even QT_API is set
266267if imported_api_list :
@@ -273,38 +274,39 @@ def get_api_information(api_name):
273274
274275for api_name in api_trial :
275276 try :
276- api_version , qt_version = get_api_information (api_name )
277+ API_VERSION , QT_VERSION = get_api_information (api_name )
277278 except PythonQtError :
278279 pass
279280 else :
280- if api_version and qt_version :
281- API = api_name
282- API_VERSION = api_version
283- QT_VERSION = qt_version
284- if API == 'PyQt4' :
281+ if API_VERSION and QT_VERSION :
282+ API = api_name .lower ()
283+ API_NAME = api_name
284+ if api_name == 'PyQt4' :
285285 PYQT4 = True
286- elif API == 'PyQt5' :
286+ PYQT4_VERSION = API_VERSION
287+ elif api_name == 'PyQt5' :
287288 PYQT5 = True
288- elif API == 'PySide' :
289+ PYQT4_VERSION = API_VERSION
290+ elif api_name == 'PySide' :
289291 PYSIDE = True
290- elif API == 'PySide2' :
292+ PYSIDE_VERSION = API_VERSION
293+ elif api_name == 'PySide2' :
291294 PYSIDE2 = True
295+ PYSIDE_VERSION = API_VERSION
292296 break
293297
294298# If a correct API name is passed to QT_API and it cannot be found,
295299# switches to another and informs through the warning
296- if API != initial_api :
300+ if API_NAME != initial_api :
297301 if imported_api_list :
298302 # If the code is using QtPy is not supposed do directly import Qt api's,
299303 # so a warning is sent to check consistence
300- warnings .warn ('Selected binding "{}" could not be set because there is '
301- 'already imported "{}", please check your code for '
302- 'consistence' .format (initial_api , API ), RuntimeWarning )
304+ warnings .warn ('Selected binding "{}" could not be set because {} '
305+ 'has already been imported. Please check your code for '
306+ 'consistence. ' .format (initial_api , API_NAME ), RuntimeWarning )
303307 else :
304308 warnings .warn ('Selected binding "{}" could not be found, '
305- 'using "{}"' .format (initial_api , API ), RuntimeWarning )
306-
307- API_NAME = API
309+ 'using "{}".' .format (initial_api , API_NAME ), RuntimeWarning )
308310
309311if PYQT4 :
310312 is_old_pyqt = API_VERSION .startswith (('4.4' , '4.5' , '4.6' , '4.7' ))
0 commit comments