Skip to content

Commit

Permalink
Fix some Python warnings, avoid accidently hiding all deprecation war…
Browse files Browse the repository at this point in the history
…nings

(cherry picked from commit f5a3485)
  • Loading branch information
nyalldawson committed Mar 28, 2019
1 parent fe1be46 commit 7590009
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
1 change: 0 additions & 1 deletion python/plugins/MetaSearch/dialogs/newconnectiondialog.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
# #
############################################################################### ###############################################################################


import warnings
from qgis.core import QgsSettings from qgis.core import QgsSettings
from qgis.PyQt.QtWidgets import QDialog, QMessageBox from qgis.PyQt.QtWidgets import QDialog, QMessageBox


Expand Down
5 changes: 0 additions & 5 deletions python/plugins/MetaSearch/util.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
# #
############################################################################### ###############################################################################


# avoid PendingDeprecationWarning from PyQt4.uic
import warnings
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning)

from gettext import gettext, ngettext from gettext import gettext, ngettext
import logging import logging
import os import os
Expand Down
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/grass7/Grass7Algorithm.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
QgsVectorLayer, QgsVectorLayer,
QgsProviderRegistry) QgsProviderRegistry)
from qgis.utils import iface from qgis.utils import iface
from osgeo import ogr
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from osgeo import ogr


from processing.core.ProcessingConfig import ProcessingConfig from processing.core.ProcessingConfig import ProcessingConfig


Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/help/__init__.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def loadShortHelp():
with codecs.open(filename, encoding='utf-8') as stream: with codecs.open(filename, encoding='utf-8') as stream:
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning) warnings.filterwarnings("ignore", category=DeprecationWarning)
for k, v in yaml.load(stream).items(): for k, v in yaml.load(stream, Loader=yaml.SafeLoader).items():
if v is None: if v is None:
continue continue
h[k] = QCoreApplication.translate("{}Algorithm".format(f[:-5].upper()), v) h[k] = QCoreApplication.translate("{}Algorithm".format(f[:-5].upper()), v)
Expand Down
5 changes: 4 additions & 1 deletion python/plugins/processing/algs/qgis/Datasources2Vrt.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
import codecs import codecs
import xml.sax.saxutils import xml.sax.saxutils


from osgeo import ogr import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
from osgeo import ogr
from qgis.core import (QgsProcessingFeedback, from qgis.core import (QgsProcessingFeedback,
QgsProcessingParameterMultipleLayers, QgsProcessingParameterMultipleLayers,
QgsProcessingParameterBoolean, QgsProcessingParameterBoolean,
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/wrappers.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ def setValue(self, value):


for v in value: for v in value:
for i, opt in enumerate(options): for i, opt in enumerate(options):
match = re.search('(?:\A|[^0-9]){}(?:\Z|[^0-9]|)'.format(v), opt) match = re.search('(?:\\A|[^0-9]){}(?:\\Z|[^0-9]|)'.format(v), opt)
if match: if match:
selected.append(i) selected.append(i)


Expand All @@ -1916,7 +1916,7 @@ def value(self):
if self.parameterDefinition().allowMultiple(): if self.parameterDefinition().allowMultiple():
bands = [] bands = []
for i in self.widget.selectedoptions: for i in self.widget.selectedoptions:
match = re.search('(?:\A|[^0-9])([0-9]+)(?:\Z|[^0-9]|)', self.widget.options[i]) match = re.search('(?:\\A|[^0-9])([0-9]+)(?:\\Z|[^0-9]|)', self.widget.options[i])
if match: if match:
bands.append(match.group(1)) bands.append(match.group(1))
return bands return bands
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/tests/AlgorithmsTestBase.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_algorithms(self):
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
""" """
with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream: with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream:
algorithm_tests = yaml.load(stream) algorithm_tests = yaml.load(stream, Loader=yaml.SafeLoader)


if 'tests' in algorithm_tests and algorithm_tests['tests'] is not None: if 'tests' in algorithm_tests and algorithm_tests['tests'] is not None:
for idx, algtest in enumerate(algorithm_tests['tests']): for idx, algtest in enumerate(algorithm_tests['tests']):
Expand Down

0 comments on commit 7590009

Please sign in to comment.