Skip to content
Permalink
Browse files

Fix some Python warnings, avoid accidently hiding all deprecation war…

…nings
  • Loading branch information
nyalldawson committed Mar 28, 2019
1 parent 234c171 commit f5a3485eae9d235721c20f05384e47753805af30
@@ -27,7 +27,6 @@
#
###############################################################################

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

@@ -24,11 +24,6 @@
#
###############################################################################

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

from gettext import gettext, ngettext
import logging
import os
@@ -64,7 +64,11 @@
QgsVectorLayer,
QgsProviderRegistry)
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

@@ -43,7 +43,7 @@ def loadShortHelp():
with codecs.open(filename, encoding='utf-8') as stream:
with warnings.catch_warnings():
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:
continue
h[k] = QCoreApplication.translate("{}Algorithm".format(f[:-5].upper()), v)
@@ -28,7 +28,10 @@
import codecs
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,
QgsProcessingParameterMultipleLayers,
QgsProcessingParameterBoolean,
@@ -1902,7 +1902,7 @@ def setValue(self, value):

for v in value:
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:
selected.append(i)

@@ -1917,7 +1917,7 @@ def value(self):
if self.parameterDefinition().allowMultiple():
bands = []
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:
bands.append(match.group(1))
return bands
@@ -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
"""
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:
for idx, algtest in enumerate(algorithm_tests['tests']):

0 comments on commit f5a3485

Please sign in to comment.
You can’t perform that action at this time.