[Python-modules-commits] [python-qtpy] 04/13: Import python-qtpy_1.2.0.orig.tar.gz

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jan 17 18:40:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository python-qtpy.

commit 49a11dc01716ddaf15f3184b17023620f8821a33
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date:   Mon Jan 16 23:59:18 2017 +0000

    Import python-qtpy_1.2.0.orig.tar.gz
---
 .ciocheck                            | 107 +++++++++++++++++++++++++++++++++++
 .travis.yml                          |   6 +-
 CHANGELOG.md                         |  40 +++++++++++++
 LICENSE.txt                          |   2 +-
 MANIFEST.in                          |   4 ++
 README.md                            |   2 +-
 appveyor.yml                         |  10 +++-
 circle.yml                           |  31 ++++++----
 qtpy/QtCore.py                       |   8 ++-
 qtpy/QtDesigner.py                   |   2 +-
 qtpy/QtGui.py                        |   2 +-
 qtpy/QtMultimedia.py                 |  13 +++++
 qtpy/QtNetwork.py                    |   2 +-
 qtpy/QtPrintSupport.py               |   2 +-
 qtpy/QtSvg.py                        |  15 ++---
 qtpy/QtTest.py                       |   2 +-
 qtpy/QtWebEngineWidgets.py           |   2 +-
 qtpy/QtWidgets.py                    |  16 ++++--
 qtpy/__init__.py                     |   2 +-
 qtpy/_patch/qcombobox.py             |   4 +-
 qtpy/_patch/qheaderview.py           |  89 +++++++++++++++++++++++++++++
 qtpy/_version.py                     |   2 +-
 qtpy/compat.py                       |   8 +--
 qtpy/tests/test_patch_qheaderview.py |  91 +++++++++++++++++++++++++++++
 qtpy/tests/test_qtmultimedia.py      |  12 ++++
 qtpy/tests/test_uic.py               |  13 +++++
 qtpy/uic.py                          |  11 ++--
 27 files changed, 447 insertions(+), 51 deletions(-)

diff --git a/.ciocheck b/.ciocheck
new file mode 100644
index 0000000..6c06a60
--- /dev/null
+++ b/.ciocheck
@@ -0,0 +1,107 @@
+# -----------------------------------------------------------------------------
+# ciocheck
+# https://github.com/ContinuumIO/ciocheck
+# -----------------------------------------------------------------------------
+[ciocheck]
+branch = origin/master
+diff_mode = commited
+file_mode = all
+check = pep8,pydocstyle,flake8,pylint
+
+# Python (pyformat)
+add_copyright = true
+add_header = true
+add_init = true
+
+# -----------------------------------------------------------------------------
+# pep8
+# http://pep8.readthedocs.io/en/latest/intro.html#configuration
+# -----------------------------------------------------------------------------
+[pep8]
+exclude = */tests/*
+ignore = E126
+max-line-length = 79
+
+# -----------------------------------------------------------------------------
+# pydocstyle
+# http://www.pydocstyle.org/en/latest/usage.html#example
+# -----------------------------------------------------------------------------
+[pydocstyle]
+add-ignore = D203
+inherit = false
+
+# -----------------------------------------------------------------------------
+# Flake 8
+# http://flake8.readthedocs.io/en/latest/config.html
+# -----------------------------------------------------------------------------
+[flake8]
+exclude = */tests/*
+ignore = E126,F401
+max-line-length = 79
+max-complexity = 64
+
+# -----------------------------------------------------------------------------
+# pylint
+# https://pylint.readthedocs.io/en/latest/
+# -----------------------------------------------------------------------------
+[pylint:messages]
+disable=unused-import
+
+# -----------------------------------------------------------------------------
+# isort
+# https://github.com/timothycrosley/isort/wiki/isort-Settings
+# -----------------------------------------------------------------------------
+[isort]
+from_first = true
+import_heading_stdlib = Standard library imports
+import_heading_firstparty = Local imports
+import_heading_thirdparty = Third party imports
+indent = '    '
+known_first_party = qtpy
+known_third_party = PySide, PyQt4, PyQt5
+line_length = 79
+sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
+
+# -----------------------------------------------------------------------------
+# yapf
+# https://github.com/google/yapf#formatting-style
+# -----------------------------------------------------------------------------
+[yapf:style]
+based_on_style = pep8
+column_limit = 79
+spaces_before_comment = 2
+
+# -----------------------------------------------------------------------------
+# autopep8
+# http://pep8.readthedocs.io/en/latest/intro.html#configuration
+# -----------------------------------------------------------------------------
+[autopep8]
+exclude = */tests/*
+ignore = E126,
+max-line-length = 79
+
+# -----------------------------------------------------------------------------
+# Coverage
+# http://coverage.readthedocs.io/en/latest/config.html
+# -----------------------------------------------------------------------------
+[coverage:run]
+omit =
+    */tests/*
+    */build/*
+
+[coverage:report]
+fail_under = 0
+show_missing = true
+skip_covered = true
+exclude_lines =
+    pragma: no cover
+    def test():
+    if __name__ == .__main__.:
+
+# -----------------------------------------------------------------------------
+# pytest
+# http://doc.pytest.org/en/latest/usage.html
+# -----------------------------------------------------------------------------
+[pytest]
+addopts = -rfew --durations=10
+python_functions = test_*
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index bc3c532..1557337 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,13 +12,12 @@ branches:
     - master
 
 os:
-  - linux
   - osx
 
 env:
   global:
     - SETUP_XVFB=True
-    - CONDA_CHANNELS="qttesting"
+    - CONDA_CHANNELS="conda-forge"
     - CONDA_DEPENDENCIES="pytest pytest-cov"
     - PIP_DEPENDENCIES="coveralls"
 
@@ -43,11 +42,10 @@ before_install:
 install:
   - git clone git://github.com/astropy/ci-helpers.git
   - source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh
-  - python setup.py install
+  - python setup.py develop
 
 script:
   - python qtpy/tests/runtests.py
 
 after_success:
   - coveralls
-
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc0cef2..1d6c00e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,45 @@
 # History of changes
 
+## Version 1.2 (2017/01/08)
+
+### New features
+
+* Add support for QtMultimedia
+* Use relative imports so its vendored more easily
+
+### Bugs fixed
+
+**Issues**
+
+* [Issue 83](https://github.com/spyder-ide/qtpy/issues/83) - Include core doc files in PyPi releases
+* [Issue 78](https://github.com/spyder-ide/qtpy/issues/78) - Request for a new bugfix release
+* [Issue 75](https://github.com/spyder-ide/qtpy/issues/75) - Missing copyright headers
+* [Issue 67](https://github.com/spyder-ide/qtpy/issues/67) - uic.loadUiType is missing
+* [Issue 64](https://github.com/spyder-ide/qtpy/issues/64) - QHeaderView.setSectionResizeMode
+* [Issue 49](https://github.com/spyder-ide/qtpy/issues/49) - QtMultimedia support
+
+In this release 6 issues were closed
+
+**Pull requests**
+
+* [PR 93](https://github.com/spyder-ide/qtpy/pull/93) - Restore uic full namespace for PyQt5 and PyQt4
+* [PR 92](https://github.com/spyder-ide/qtpy/pull/92) - Add missing copyright header in _patch/qheaderview.py
+* [PR 91](https://github.com/spyder-ide/qtpy/pull/91) - Use star imports in QtSvg again instead of direct ones (reverts PR #55)
+* [PR 88](https://github.com/spyder-ide/qtpy/pull/88) - PR: Add manifest
+* [PR 74](https://github.com/spyder-ide/qtpy/pull/74) - Move QStringListModel to QtCore
+* [PR 71](https://github.com/spyder-ide/qtpy/pull/71) - PR: Use relative imports so its vendored more easily
+* [PR 65](https://github.com/spyder-ide/qtpy/pull/65) - Introduce renamed methods of QHeaderView in PyQt4 and PySide
+* [PR 59](https://github.com/spyder-ide/qtpy/pull/59) - Don't install qtpy as a conda package in CircleCI
+* [PR 58](https://github.com/spyder-ide/qtpy/pull/58) - Remove reference to how qtpy is pronounced in README
+* [PR 55](https://github.com/spyder-ide/qtpy/pull/55) - PR: Add explicit imports to QtSvg module
+* [PR 50](https://github.com/spyder-ide/qtpy/pull/50) - Add support for QtMultimedia
+
+In this release 11 pull requests were merged
+
+
+----
+
+
 ## Version 1.1.2 (2016-08-08)
 
 ### Bugfixes
diff --git a/LICENSE.txt b/LICENSE.txt
index 4152f52..4a79181 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2015 Gonzalo Peña-Castellanos
+Copyright (c) The Spyder Development Team
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..f753229
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,4 @@
+include AUTHORS.md
+include CHANGELOG.md
+include LICENSE.txt
+include README.md
\ No newline at end of file
diff --git a/README.md b/README.md
index 4585fcb..fefb604 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ Copyright © 2009- The Spyder Development Team.
 
 ## Description
 
-**QtPy** (pronounced *'cutie pie'*) is a small abstraction layer that lets you
+**QtPy** is a small abstraction layer that lets you
 write applications using a single API call to either PyQt or PySide.
 
 It provides support for PyQt5, PyQt4 and PySide using the PyQt5 layout (where
diff --git a/appveyor.yml b/appveyor.yml
index 52ce588..be164b7 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -34,6 +34,15 @@ platform:
     -x64
 
 install:
+    # If there is a newer build queued for the same PR, cancel this one.
+    # The AppVeyor 'rollout builds' option is supposed to serve the same
+    # purpose but it is problematic because it tends to cancel builds pushed
+    # directly to master instead of just PR builds (or the converse).
+    # credits: JuliaLang developers.
+    - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
+        https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
+        Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
+          throw "There are newer queued builds for this pull request, failing early." }
     - "git clone git://github.com/astropy/ci-helpers.git"
     - "powershell ci-helpers/appveyor/install-miniconda.ps1"
     - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
@@ -45,4 +54,3 @@ build: false
 
 test_script:
   - "%CMD_IN_ENV% python qtpy/tests/runtests.py"
-
diff --git a/circle.yml b/circle.yml
index 6638b5c..1633226 100644
--- a/circle.yml
+++ b/circle.yml
@@ -1,33 +1,42 @@
 # https://circleci.com/gh/spyder-ide/qtpy/
-
 machine:
   environment:
     # Used by test scripts
     TEST_CI: "True"
-    PYTHON_TEST: "$HOME/miniconda/envs/test/bin/python"
-    PYTEST: "$HOME/miniconda/envs/test/bin/py.test"
-    PATH: "$HOME/miniconda/bin:$PATH"  # To avoid prepending this to the commands on circle-ci
     # Python versions to test (Maximum of 4 different versions for now)
-    PY_VERSIONS: "2.7 3.4 3.5"
+    PY_VERSIONS: "3.5 3.4 2.7"
     # Used by astropy-ci helpers
     TRAVIS_OS_NAME: "linux"
-    CONDA_CHANNELS: "spyder-ide qttesting"
-    CONDA_DEPENDENCIES: "pyqt pytest pytest-cov qt qtpy"
     PIP_DEPENDENCIES: "coveralls"
 
 dependencies:
   override:
-    # First convert PY_VERSIONS to an array and then select the python version based on the CIRCLE_NODE_INDEX
+    # First convert PY_VERSIONS to an array and then select the Python version
+    # based on the CIRCLE_NODE_INDEX
     - PY_VERSIONS=($PY_VERSIONS) &&
       TRAVIS_PYTHON_VERSION=${PY_VERSIONS[$CIRCLE_NODE_INDEX]} && 
       echo -e "PYTHON = $TRAVIS_PYTHON_VERSION \n============" &&
       git clone git://github.com/astropy/ci-helpers.git &&
       source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh &&
-      "$PYTHON_TEST" setup.py install;
+      export PATH="$HOME/miniconda/bin:$PATH" &&
+      source activate test &&
+      conda install -q ciocheck -c spyder-ide &&
+      python setup.py develop;
 
 test:
   override:
-    - conda info --json: # note the colon
+    # Check style
+    - export PATH="$HOME/miniconda/bin:$PATH" && source activate test && ciocheck qtpy: # note the colon
+        parallel: true
+    # Check PyQt5
+    - export PATH="$HOME/miniconda/bin:$PATH" && source activate test && conda install -q qt=5.* pyqt=5.* && python qtpy/tests/runtests.py: # note the colon
         parallel: true
-    - "$PYTHON_TEST qtpy/tests/runtests.py": # note the colon
+    # Check PySide2
+#    - export PATH="$HOME/miniconda/bin:$PATH" && source activate test && conda install -q qt=5.* pyside2 && python qtpy/tests/runtests.py: # note the colon
+#        parallel: true
+    # Check PyQt4
+    - export PATH="$HOME/miniconda/bin:$PATH" && source activate test && conda install -q qt=4.* pyqt=4.* && python qtpy/tests/runtests.py: # note the colon
         parallel: true
+    # Check Pyside
+    #- export PATH="$HOME/miniconda/bin:$PATH" && source activate test && conda remove -q qt pyqt && conda install -c conda-forge qt=4.* pyside && python qtpy/tests/runtests.py: # note the colon
+    #    parallel: true
diff --git a/qtpy/QtCore.py b/qtpy/QtCore.py
index 07adafb..6794cb4 100644
--- a/qtpy/QtCore.py
+++ b/qtpy/QtCore.py
@@ -10,7 +10,7 @@
 Provides QtCore classes and functions.
 """
 
-from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
+from . import PYQT5, PYQT4, PYSIDE, PythonQtError
 
 
 if PYQT5:
@@ -32,7 +32,8 @@ elif PYQT4:
     from PyQt4.QtCore import pyqtSlot as Slot
     from PyQt4.QtCore import pyqtProperty as Property
     from PyQt4.QtGui import (QItemSelection, QItemSelectionModel,
-                             QItemSelectionRange, QSortFilterProxyModel)
+                             QItemSelectionRange, QSortFilterProxyModel,
+                             QStringListModel)
     from PyQt4.QtCore import QT_VERSION_STR as __version__
 
     # Those are imported from `import *`
@@ -40,7 +41,8 @@ elif PYQT4:
 elif PYSIDE:
     from PySide.QtCore import *
     from PySide.QtGui import (QItemSelection, QItemSelectionModel,
-                              QItemSelectionRange, QSortFilterProxyModel)
+                              QItemSelectionRange, QSortFilterProxyModel,
+                              QStringListModel)
     import PySide.QtCore
     __version__ = PySide.QtCore.__version__
 else:
diff --git a/qtpy/QtDesigner.py b/qtpy/QtDesigner.py
index 8b2dded..4aaafc8 100644
--- a/qtpy/QtDesigner.py
+++ b/qtpy/QtDesigner.py
@@ -9,7 +9,7 @@
 Provides QtDesigner classes and functions.
 """
 
-from qtpy import PYQT5, PYQT4, PythonQtError
+from . import PYQT5, PYQT4, PythonQtError
 
 
 if PYQT5:
diff --git a/qtpy/QtGui.py b/qtpy/QtGui.py
index 84049e5..99477c0 100644
--- a/qtpy/QtGui.py
+++ b/qtpy/QtGui.py
@@ -13,7 +13,7 @@ Provides QtGui classes and functions.
     the ``PyQt5.QtGui`` module.
 """
 
-from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
+from . import PYQT5, PYQT4, PYSIDE, PythonQtError
 
 
 if PYQT5:
diff --git a/qtpy/QtMultimedia.py b/qtpy/QtMultimedia.py
new file mode 100644
index 0000000..7ed307e
--- /dev/null
+++ b/qtpy/QtMultimedia.py
@@ -0,0 +1,13 @@
+from . import PYQT5
+from . import PYQT4
+from . import PYSIDE
+
+
+if PYQT5:
+    from PyQt5.QtMultimedia import *
+elif PYQT4:
+    from PyQt4.QtMultimedia import *
+    from PyQt4.QtGui import QSound
+elif PYSIDE:
+    from PySide.QtMultimedia import *
+    from PySide.QtGui import QSound
diff --git a/qtpy/QtNetwork.py b/qtpy/QtNetwork.py
index aca335b..de4ff47 100644
--- a/qtpy/QtNetwork.py
+++ b/qtpy/QtNetwork.py
@@ -10,7 +10,7 @@
 Provides QtNetwork classes and functions.
 """
 
-from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
+from . import PYQT5, PYQT4, PYSIDE, PythonQtError
 
 
 if PYQT5:
diff --git a/qtpy/QtPrintSupport.py b/qtpy/QtPrintSupport.py
index b272174..8959fad 100644
--- a/qtpy/QtPrintSupport.py
+++ b/qtpy/QtPrintSupport.py
@@ -9,7 +9,7 @@
 Provides QtPrintSupport classes and functions.
 """
 
-from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
+from . import PYQT5, PYQT4, PYSIDE, PythonQtError
 
 
 if PYQT5:
diff --git a/qtpy/QtSvg.py b/qtpy/QtSvg.py
index 10e4183..0bc7320 100644
--- a/qtpy/QtSvg.py
+++ b/qtpy/QtSvg.py
@@ -1,15 +1,14 @@
 # -*- coding: utf-8 -*-
-#
+# -----------------------------------------------------------------------------
 # Copyright © 2009- The Spyder Development Team
+#
 # Licensed under the terms of the MIT License
 # (see LICENSE.txt for details)
+# -----------------------------------------------------------------------------
+"""Provides QtSvg classes and functions."""
 
-"""
-Provides QtSvg classes and functions.
-"""
-
-from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
-
+# Local imports
+from . import PYQT4, PYQT5, PYSIDE, PythonQtError
 
 if PYQT5:
     from PyQt5.QtSvg import *
@@ -19,3 +18,5 @@ elif PYSIDE:
     from PySide.QtSvg import *
 else:
     raise PythonQtError('No Qt bindings could be found')
+
+del PYQT4, PYQT5, PYSIDE
diff --git a/qtpy/QtTest.py b/qtpy/QtTest.py
index 6d59c76..28067d8 100644
--- a/qtpy/QtTest.py
+++ b/qtpy/QtTest.py
@@ -10,7 +10,7 @@
 Provides QtTest and functions
 """
 
-from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
+from . import PYQT5, PYQT4, PYSIDE, PythonQtError
 
 
 if PYQT5:
diff --git a/qtpy/QtWebEngineWidgets.py b/qtpy/QtWebEngineWidgets.py
index bd07369..18b5e58 100644
--- a/qtpy/QtWebEngineWidgets.py
+++ b/qtpy/QtWebEngineWidgets.py
@@ -10,7 +10,7 @@
 Provides QtWebEngineWidgets classes and functions.
 """
 
-from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
+from . import PYQT5, PYQT4, PYSIDE, PythonQtError
 
 
 # To test if we are using WebEngine or WebKit
diff --git a/qtpy/QtWidgets.py b/qtpy/QtWidgets.py
index 2f3ff81..62fa44e 100644
--- a/qtpy/QtWidgets.py
+++ b/qtpy/QtWidgets.py
@@ -13,8 +13,9 @@ Provides widget classes and functions.
     were the ``PyQt5.QtWidgets`` module.
 """
 
-from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
-from qtpy._patch.qcombobox import patch_qcombobox
+from . import PYQT5, PYQT4, PYSIDE, PythonQtError
+from ._patch.qcombobox import patch_qcombobox
+from ._patch.qheaderview import introduce_renamed_methods_qheaderview
 
 
 if PYQT5:
@@ -52,7 +53,8 @@ elif PYQT4:
          QTextTableCellFormat, QTextTableFormat, QTouchEvent, QTransform,
          QValidator, QVector2D, QVector3D, QVector4D, QWhatsThisClickedEvent,
          QWheelEvent, QWindowStateChangeEvent, qAlpha, qBlue, qFuzzyCompare,
-         qGray, qGreen, qIsGray, qRed, qRgb, qRgba, QIntValidator)
+         qGray, qGreen, qIsGray, qRed, qRgb, qRgba, QIntValidator,
+         QStringListModel)
 
     # These objects belong to QtPrintSupport
     del (QAbstractPrintDialog, QPageSetupDialog, QPrintDialog, QPrintEngine,
@@ -65,6 +67,9 @@ elif PYQT4:
     # Patch QComboBox to allow Python objects to be passed to userData
     patch_qcombobox(QComboBox)
 
+    # QHeaderView: renamed methods
+    introduce_renamed_methods_qheaderview(QHeaderView)
+
 elif PYSIDE:
     from PySide.QtGui import *
     QStyleOptionViewItem = QStyleOptionViewItemV4
@@ -98,7 +103,7 @@ elif PYSIDE:
          QTextTableCellFormat, QTextTableFormat, QTouchEvent, QTransform,
          QValidator, QVector2D, QVector3D, QVector4D, QWhatsThisClickedEvent,
          QWheelEvent, QWindowStateChangeEvent, qAlpha, qBlue, qGray, qGreen,
-         qIsGray, qRed, qRgb, qRgba, QIntValidator)
+         qIsGray, qRed, qRgb, qRgba, QIntValidator, QStringListModel)
 
     # These objects belong to QtPrintSupport
     del (QAbstractPrintDialog, QPageSetupDialog, QPrintDialog, QPrintEngine,
@@ -111,5 +116,8 @@ elif PYSIDE:
     # Patch QComboBox to allow Python objects to be passed to userData
     patch_qcombobox(QComboBox)
 
+    # QHeaderView: renamed methods
+    introduce_renamed_methods_qheaderview(QHeaderView)
+
 else:
     raise PythonQtError('No Qt bindings could be found')
diff --git a/qtpy/__init__.py b/qtpy/__init__.py
index b837343..273df1d 100644
--- a/qtpy/__init__.py
+++ b/qtpy/__init__.py
@@ -53,7 +53,7 @@ packages::
 import os
 
 # Version of QtPy
-from qtpy._version import __version__
+from ._version import __version__
 
 #: Qt API environment variable name
 QT_API = 'QT_API'
diff --git a/qtpy/_patch/qcombobox.py b/qtpy/_patch/qcombobox.py
index ec7c01d..d3e98be 100644
--- a/qtpy/_patch/qcombobox.py
+++ b/qtpy/_patch/qcombobox.py
@@ -42,8 +42,8 @@ def patch_qcombobox(QComboBox):
     using PyQt4 and PySide to avoid issues.
     """
 
-    from qtpy.QtGui import QIcon
-    from qtpy.QtCore import Qt, QObject
+    from ..QtGui import QIcon
+    from ..QtCore import Qt, QObject
 
     class userDataWrapper():
         """
diff --git a/qtpy/_patch/qheaderview.py b/qtpy/_patch/qheaderview.py
new file mode 100644
index 0000000..99cd20a
--- /dev/null
+++ b/qtpy/_patch/qheaderview.py
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright © The Spyder Development Team
+#
+# Licensed under the terms of the MIT License
+# (see LICENSE.txt for details)
+
+def introduce_renamed_methods_qheaderview(QHeaderView):
+
+    _isClickable = QHeaderView.isClickable
+    def sectionsClickable(self):
+        """
+        QHeaderView.sectionsClickable() -> bool
+        """
+        return _isClickable(self)
+    QHeaderView.sectionsClickable = sectionsClickable
+    def isClickable(self):
+        raise Exception('isClickable is only available in Qt4. Use '
+                        'sectionsClickable instead.')
+    QHeaderView.isClickable = isClickable
+
+
+    _isMovable = QHeaderView.isMovable
+    def sectionsMovable(self):
+        """
+        QHeaderView.sectionsMovable() -> bool
+        """
+        return _isMovable(self)
+    QHeaderView.sectionsMovable = sectionsMovable
+    def isMovable(self):
+        raise Exception('isMovable is only available in Qt4. Use '
+                        'sectionsMovable instead.')
+    QHeaderView.isMovable = isMovable
+
+
+    _resizeMode = QHeaderView.resizeMode
+    def sectionResizeMode(self, logicalIndex):
+        """
+        QHeaderView.sectionResizeMode(int) -> QHeaderView.ResizeMode
+        """
+        return _resizeMode(self, logicalIndex)
+    QHeaderView.sectionResizeMode = sectionResizeMode
+    def resizeMode(self, logicalIndex):
+        raise Exception('resizeMode is only available in Qt4. Use '
+                        'sectionResizeMode instead.')
+    QHeaderView.resizeMode = resizeMode
+
+    _setClickable = QHeaderView.setClickable
+    def setSectionsClickable(self, clickable):
+        """
+        QHeaderView.setSectionsClickable(bool)
+        """
+        return _setClickable(self, clickable)
+    QHeaderView.setSectionsClickable = setSectionsClickable
+    def setClickable(self, clickable):
+        raise Exception('setClickable is only available in Qt4. Use '
+                        'setSectionsClickable instead.')
+    QHeaderView.setClickable = setClickable
+
+
+    _setMovable = QHeaderView.setMovable
+    def setSectionsMovable(self, movable):
+        """
+        QHeaderView.setSectionsMovable(bool)
+        """
+        return _setMovable(self, movable)
+    QHeaderView.setSectionsMovable = setSectionsMovable
+    def setMovable(self, movable):
+        raise Exception('setMovable is only available in Qt4. Use '
+                        'setSectionsMovable instead.')
+    QHeaderView.setMovable = setMovable
+
+
+    _setResizeMode = QHeaderView.setResizeMode
+    def setSectionResizeMode(self, *args):
+        """
+        QHeaderView.setSectionResizeMode(QHeaderView.ResizeMode)
+        QHeaderView.setSectionResizeMode(int, QHeaderView.ResizeMode)
+        """
+        _setResizeMode(self, *args)
+    QHeaderView.setSectionResizeMode = setSectionResizeMode
+    def setResizeMode(self, *args):
+        raise Exception('setResizeMode is only available in Qt4. Use '
+                        'setSectionResizeMode instead.')
+    QHeaderView.setResizeMode = setResizeMode
+
+
+
+
diff --git a/qtpy/_version.py b/qtpy/_version.py
index 95d1e54..d1115f8 100644
--- a/qtpy/_version.py
+++ b/qtpy/_version.py
@@ -1,2 +1,2 @@
-version_info = (1, 1, 2)
+version_info = (1, 2, 0)
 __version__ = '.'.join(map(str, version_info))
diff --git a/qtpy/compat.py b/qtpy/compat.py
index ae38090..e6bdd1b 100644
--- a/qtpy/compat.py
+++ b/qtpy/compat.py
@@ -11,9 +11,9 @@ from __future__ import print_function
 import sys
 import collections
 
-from qtpy import PYQT4
-from qtpy.QtWidgets import QFileDialog
-from qtpy.py3compat import is_text_string, to_text_string, TEXT_TYPES
+from . import PYQT4
+from .QtWidgets import QFileDialog
+from .py3compat import is_text_string, to_text_string, TEXT_TYPES
 
 
 # =============================================================================
@@ -105,7 +105,7 @@ def _qfiledialog_wrapper(attr, parent=None, caption='', basedir='',
         options = QFileDialog.Options(0)
     try:
         # PyQt <v4.6 (API #1)
-        from qtpy.QtCore import QString
+        from .QtCore import QString
     except ImportError:
         # PySide or PyQt >=v4.6
         QString = None  # analysis:ignore
diff --git a/qtpy/tests/test_patch_qheaderview.py b/qtpy/tests/test_patch_qheaderview.py
new file mode 100644
index 0000000..6f30c33
--- /dev/null
+++ b/qtpy/tests/test_patch_qheaderview.py
@@ -0,0 +1,91 @@
+from __future__ import absolute_import
+
+from qtpy import PYSIDE, PYQT4
+from qtpy.QtWidgets import QApplication
+from qtpy.QtWidgets import QHeaderView
+from qtpy.QtCore import Qt
+from qtpy.QtCore import QAbstractListModel
+
+import pytest
+
+def get_qapp(icon_path=None):
+    qapp = QApplication.instance()
+    if qapp is None:
+        qapp = QApplication([''])
+    return qapp
+
+def test_patched_qheaderview():
+    """
+    This will test whether QHeaderView has the new methods introduced in Qt5.
+    It will then create an instance of QHeaderView and test that no exceptions
+    are raised and that some basic behaviour works.
+    """
+    assert QHeaderView.sectionsClickable is not None
+    assert QHeaderView.sectionsMovable is not None
+    assert QHeaderView.sectionResizeMode is not None
+    assert QHeaderView.setSectionsClickable is not None
+    assert QHeaderView.setSectionsMovable is not None
+    assert QHeaderView.setSectionResizeMode is not None
+
+    # setup a model and add it to a headerview
+    qapp = get_qapp()
+    headerview = QHeaderView(Qt.Horizontal)
+    class Model(QAbstractListModel):
+        pass
+    model = Model()
+    headerview.setModel(model)
+    assert headerview.count() == 1
+
+    # test it
+    assert isinstance(headerview.sectionsClickable(), bool)
+    assert isinstance(headerview.sectionsMovable(), bool)
+    if PYSIDE:
+        assert isinstance(headerview.sectionResizeMode(0),
+                          QHeaderView.ResizeMode)
+    else:
+        assert isinstance(headerview.sectionResizeMode(0), int)
+
+    headerview.setSectionsClickable(True)
+    assert headerview.sectionsClickable() == True
+    headerview.setSectionsClickable(False)
+    assert headerview.sectionsClickable() == False
+
+    headerview.setSectionsMovable(True)
+    assert headerview.sectionsMovable() == True
+    headerview.setSectionsMovable(False)
+    assert headerview.sectionsMovable() == False
+
+    headerview.setSectionResizeMode(QHeaderView.Interactive)
+    assert headerview.sectionResizeMode(0) == QHeaderView.Interactive
+    headerview.setSectionResizeMode(QHeaderView.Fixed)
+    assert headerview.sectionResizeMode(0) == QHeaderView.Fixed
+    headerview.setSectionResizeMode(QHeaderView.Stretch)
+    assert headerview.sectionResizeMode(0) == QHeaderView.Stretch
+    headerview.setSectionResizeMode(QHeaderView.ResizeToContents)
+    assert headerview.sectionResizeMode(0) == QHeaderView.ResizeToContents
+
+    headerview.setSectionResizeMode(0, QHeaderView.Interactive)
+    assert headerview.sectionResizeMode(0) == QHeaderView.Interactive
+    headerview.setSectionResizeMode(0, QHeaderView.Fixed)
+    assert headerview.sectionResizeMode(0) == QHeaderView.Fixed
+    headerview.setSectionResizeMode(0, QHeaderView.Stretch)
+    assert headerview.sectionResizeMode(0) == QHeaderView.Stretch
+    headerview.setSectionResizeMode(0, QHeaderView.ResizeToContents)
+    assert headerview.sectionResizeMode(0) == QHeaderView.ResizeToContents
+
+    # test that the old methods in Qt4 raise exceptions
+    if PYQT4 or PYSIDE:
+        with pytest.raises(Exception):
+            headerview.isClickable()
+        with pytest.raises(Exception):
+            headerview.isMovable()
+        with pytest.raises(Exception):
+            headerview.resizeMode(0)
+        with pytest.raises(Exception):
+            headerview.setClickable(True)
+        with pytest.raises(Exception):
+            headerview.setMovableClickable(True)
+        with pytest.raises(Exception):
+            headerview.setResizeMode(0, QHeaderView.Interactive)
+
+
diff --git a/qtpy/tests/test_qtmultimedia.py b/qtpy/tests/test_qtmultimedia.py
new file mode 100644
index 0000000..a718d18
--- /dev/null
+++ b/qtpy/tests/test_qtmultimedia.py
@@ -0,0 +1,12 @@
+from __future__ import absolute_import
+
+from qtpy import QtMultimedia
+
+
+def test_qtmultimedia():
+    """Test the qtpy.QtMultimedia namespace"""
+    assert QtMultimedia.QAbstractVideoBuffer is not None
+    assert QtMultimedia.QAudio is not None
+    assert QtMultimedia.QAudioDeviceInfo is not None
+    assert QtMultimedia.QAudioInput is not None
+    assert QtMultimedia.QSound is not None
diff --git a/qtpy/tests/test_uic.py b/qtpy/tests/test_uic.py
index 07e3f77..6e732bb 100644
--- a/qtpy/tests/test_uic.py
+++ b/qtpy/tests/test_uic.py
@@ -4,6 +4,7 @@ import contextlib
 
 from qtpy import QtWidgets
 from qtpy.QtWidgets import QComboBox
+from qtpy import uic
 from qtpy.uic import loadUi
 
 
@@ -66,3 +67,15 @@ def test_load_ui_custom_auto(tmpdir):
 
     assert isinstance(ui.pushButton, QtWidgets.QPushButton)
     assert isinstance(ui.comboBox, _QComboBoxSubclass)
+
+
+def test_load_full_uic():
+    """Test that we load the full uic objects for PyQt5 and PyQt4."""
+    QT_API = os.environ.get('QT_API', '').lower()
+    if QT_API == 'pyside':
+        assert hasattr(uic, 'loadUi')
+        assert not hasattr(uic, 'loadUiType')
+    else:
+        objects = ['compileUi', 'compileUiDir', 'loadUi', 'loadUiType',
+                   'widgetPluginPath']
+        assert all([hasattr(uic, o) for o in objects])
diff --git a/qtpy/uic.py b/qtpy/uic.py
index ff049ff..b3d9324 100644
--- a/qtpy/uic.py
+++ b/qtpy/uic.py
@@ -1,20 +1,21 @@
 import os
 
-from qtpy import PYSIDE, PYQT4, PYQT5
-from qtpy.QtWidgets import QComboBox
+from . import PYSIDE, PYQT4, PYQT5
+from .QtWidgets import QComboBox
 
-__all__ = ['loadUi']
 
 if PYQT5:
 
-    from PyQt5.uic import loadUi
+    from PyQt5.uic import *
 
 elif PYQT4:
 
-    from PyQt4.uic import loadUi
+    from PyQt4.uic import *
 
 elif PYSIDE:
 
+    __all__ = ['loadUi']
+
     # In PySide, loadUi does not exist, so we define it using QUiLoader, and
     # then make sure we expose that function. This is adapted from qt-helpers
     # which was released under a 3-clause BSD license:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-qtpy.git



More information about the Python-modules-commits mailing list