From 2c3405619980f6431f3b4af8df952d92b1aaf5fd Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 17 Oct 2024 13:32:59 +1000 Subject: [PATCH] pyqt5_to_pyqt6.py run --- python/plugins/MetaSearch/plugin.py | 6 ++-- python/plugins/MetaSearch/search_backend.py | 34 +++++++++---------- python/plugins/MetaSearch/util.py | 2 +- .../processing/algs/gdal/fillnodata.py | 2 +- .../algs/qgis/StatisticsByCategories.py | 2 +- tests/src/python/test_provider_hana.py | 2 +- .../python/test_qgsannotationrecttextitem.py | 2 +- tests/src/python/test_qgsrelation.py | 2 +- tests/src/python/test_qgsserver_wms.py | 2 +- tests/src/python/test_qgsvariantutils.py | 34 +++++++++---------- 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/python/plugins/MetaSearch/plugin.py b/python/plugins/MetaSearch/plugin.py index 6f2b778c7a9..d131c4b7cc9 100644 --- a/python/plugins/MetaSearch/plugin.py +++ b/python/plugins/MetaSearch/plugin.py @@ -50,7 +50,7 @@ class MetaSearchPlugin: """startup""" # run - log_message('Initializing plugin', Qgis.Info) + log_message('Initializing plugin', Qgis.MessageLevel.Info) run_icon = QIcon('{}/{}'.format(self.context.ppath, 'images/MetaSearch.svg')) self.action_run = QAction(run_icon, 'MetaSearch', @@ -82,7 +82,7 @@ class MetaSearchPlugin: def unload(self): """teardown""" - log_message('Unloading plugin', Qgis.Info) + log_message('Unloading plugin', Qgis.MessageLevel.Info) # remove the plugin menu item and icon self.iface.removePluginWebMenu(self.web_menu, self.action_run) @@ -92,7 +92,7 @@ class MetaSearchPlugin: def run(self): """open MetaSearch""" - log_message('Running plugin', Qgis.Info) + log_message('Running plugin', Qgis.MessageLevel.Info) self.dialog.exec() diff --git a/python/plugins/MetaSearch/search_backend.py b/python/plugins/MetaSearch/search_backend.py index 73fbbb4566f..1b461fec19b 100644 --- a/python/plugins/MetaSearch/search_backend.py +++ b/python/plugins/MetaSearch/search_backend.py @@ -88,7 +88,7 @@ class CSW202Search(SearchBase): self.record_info_template = 'record_metadata_dc.html' self.constraints = [] - log_message(f'Connecting to CSW: {self.url}', Qgis.Info) + log_message(f'Connecting to CSW: {self.url}', Qgis.MessageLevel.Info) self.conn = CatalogueServiceWeb(self.url, # spellok timeout=self.timeout, username=self.username, @@ -106,7 +106,7 @@ class CSW202Search(SearchBase): # even for a global bbox, if a spatial filter is applied, then # the CSW server will skip records without a bbox if bbox and bbox != ['-180', '-90', '180', '90']: - log_message(f'Setting bbox filter ({bbox})', Qgis.Info) + log_message(f'Setting bbox filter ({bbox})', Qgis.MessageLevel.Info) minx, miny, maxx, maxy = bbox self.constraints.append(BBox([miny, minx, maxy, maxx], crs='urn:ogc:def:crs:EPSG::4326')) @@ -114,20 +114,20 @@ class CSW202Search(SearchBase): # keywords if keywords: # TODO: handle multiple word searches - log_message(f'Setting csw:AnyText filter {keywords}', Qgis.Info) + log_message(f'Setting csw:AnyText filter {keywords}', Qgis.MessageLevel.Info) self.constraints.append(PropertyIsLike('csw:AnyText', keywords)) if len(self.constraints) > 1: # exclusive search (a && b) self.constraints = [self.constraints] - log_message('Searching CSW: {self.url}', Qgis.Info) + log_message('Searching CSW: {self.url}', Qgis.MessageLevel.Info) self.conn.getrecords2(constraints=self.constraints, maxrecords=limit, startposition=offset, esn='full') self.matches = self.conn.results['matches'] self.returned = self.conn.results['returned'] - log_message(f'Matches: {self.matches}', Qgis.Info) - log_message(f'Returned: {self.returned}', Qgis.Info) + log_message(f'Matches: {self.matches}', Qgis.MessageLevel.Info) + log_message(f'Returned: {self.returned}', Qgis.MessageLevel.Info) self.request = self.conn.request self.response = self.conn.response @@ -161,7 +161,7 @@ class CSW202Search(SearchBase): return recs def get_record(self, identifier): - log_message(f'Searching CSW for record: {identifier}', Qgis.Info) + log_message(f'Searching CSW for record: {identifier}', Qgis.MessageLevel.Info) self.conn.getrecordbyid([identifier]) return self.conn.records[identifier] @@ -185,7 +185,7 @@ class OARecSearch(SearchBase): self.record_collection = None if '/collections/' in self.url: # catalog is a collection - log_message('OARec endpoint is a collection', Qgis.Info) + log_message('OARec endpoint is a collection', Qgis.MessageLevel.Info) self.base_url, self.record_collection = self.url.split('/collections/') # noqa self.conn = Records( self.base_url, timeout=self.timeout, auth=self.auth) @@ -198,7 +198,7 @@ class OARecSearch(SearchBase): pass self.request = self.conn.request else: - log_message('OARec endpoint is not a collection', Qgis.Info) + log_message('OARec endpoint is not a collection', Qgis.MessageLevel.Info) self.conn = Records(self.url, timeout=self.timeout, auth=self.auth) self.request = None @@ -216,21 +216,21 @@ class OARecSearch(SearchBase): } if keywords: - log_message(f'Setting keyword search {keywords}', Qgis.Info) + log_message(f'Setting keyword search {keywords}', Qgis.MessageLevel.Info) params['q'] = keywords if bbox and bbox != ['-180', '-90', '180', '90']: - log_message(f'Setting bbox search {bbox}', Qgis.Info) + log_message(f'Setting bbox search {bbox}', Qgis.MessageLevel.Info) params['bbox'] = bbox - log_message(f'Searching OARec: {self.url}', Qgis.Info) + log_message(f'Searching OARec: {self.url}', Qgis.MessageLevel.Info) self.response = self.conn.collection_items(**params) self.matches = self.response.get('numberMatched', 0) self.returned = self.response.get('numberReturned', 0) self.request = self.conn.request - log_message(f'Matches: {self.matches}', Qgis.Info) - log_message(f'Returned: {self.returned}', Qgis.Info) + log_message(f'Matches: {self.matches}', Qgis.MessageLevel.Info) + log_message(f'Returned: {self.returned}', Qgis.MessageLevel.Info) def records(self): recs = [] @@ -260,7 +260,7 @@ class OARecSearch(SearchBase): def get_record(self, identifier): log_message(f'Searching OARec endpoint for item {identifier}', - Qgis.Info) + Qgis.MessageLevel.Info) return self.conn.collection_item(self.record_collection, identifier) def parse_link(self, link): @@ -279,10 +279,10 @@ class OARecSearch(SearchBase): def get_catalog_service(url, catalog_type, timeout, username, password, auth=None): if catalog_type in [None, CATALOG_TYPES[0]]: - log_message('CSW endpoint detected', Qgis.Info) + log_message('CSW endpoint detected', Qgis.MessageLevel.Info) return CSW202Search(url, timeout, username, password, auth) elif catalog_type == CATALOG_TYPES[1]: - log_message('OARec endpoint detected', Qgis.Info) + log_message('OARec endpoint detected', Qgis.MessageLevel.Info) if not OWSLIB_OAREC_SUPPORTED: raise ValueError("OGC API - Records requires OWSLib 0.25 or above") return OARecSearch(url, timeout, auth) diff --git a/python/plugins/MetaSearch/util.py b/python/plugins/MetaSearch/util.py index d7f08ef84d9..7f6345baf06 100644 --- a/python/plugins/MetaSearch/util.py +++ b/python/plugins/MetaSearch/util.py @@ -168,7 +168,7 @@ def clean_ows_url(url): return url.toString() -def log_message(message, level=Qgis.Info): +def log_message(message, level=Qgis.MessageLevel.Info): """helper function to emit logging messages""" LOGGER.logMessage(message, 'MetaSearch', level) diff --git a/python/plugins/processing/algs/gdal/fillnodata.py b/python/plugins/processing/algs/gdal/fillnodata.py index 2dbf65ad887..b313c0294c6 100644 --- a/python/plugins/processing/algs/gdal/fillnodata.py +++ b/python/plugins/processing/algs/gdal/fillnodata.py @@ -75,7 +75,7 @@ class fillnodata(GdalAlgorithm): self.tr('Do not use the default validity mask for the input band'), defaultValue=False, optional=True) - nomask_param.setFlags(nomask_param.flags() | QgsProcessingParameterDefinition.FlagHidden) + nomask_param.setFlags(nomask_param.flags() | QgsProcessingParameterDefinition.Flag.FlagHidden) self.addParameter(nomask_param) self.addParameter(QgsProcessingParameterRasterLayer(self.MASK_LAYER, diff --git a/python/plugins/processing/algs/qgis/StatisticsByCategories.py b/python/plugins/processing/algs/qgis/StatisticsByCategories.py index bec65a5a485..f7b6f12c124 100644 --- a/python/plugins/processing/algs/qgis/StatisticsByCategories.py +++ b/python/plugins/processing/algs/qgis/StatisticsByCategories.py @@ -140,7 +140,7 @@ class StatisticsByCategories(QgisAlgorithm): fields.append(QgsField('q1', QMetaType.Type.Double)) fields.append(QgsField('q3', QMetaType.Type.Double)) fields.append(QgsField('iqr', QMetaType.Type.Double)) - elif value_field.type() in (QMetaType.Type.QDate, QMetaType.QTime, QMetaType.QDateTime): + elif value_field.type() in (QMetaType.Type.QDate, QMetaType.Type.QTime, QMetaType.Type.QDateTime): field_type = 'datetime' fields.append(QgsField('count', QMetaType.Type.Int)) fields.append(QgsField('unique', QMetaType.Type.Int)) diff --git a/tests/src/python/test_provider_hana.py b/tests/src/python/test_provider_hana.py index 9ce5fd53b6b..db77e43b389 100644 --- a/tests/src/python/test_provider_hana.py +++ b/tests/src/python/test_provider_hana.py @@ -440,7 +440,7 @@ class TestPyQgsHanaProvider(QgisTestCase, ProviderTestCase): self.assertEqual(fields.at(fields.indexFromName('emb')).length(), 3) values = {feat['id']: feat['emb'] for feat in vl.getFeatures()} - expected = {1: '[0.1,0.2,0.1]', 2: QVariant()} + expected = {1: '[0.1,0.2,0.1]', 2: NULL} self.assertEqual(values, expected) def testRealVectorTypeEdit(self): diff --git a/tests/src/python/test_qgsannotationrecttextitem.py b/tests/src/python/test_qgsannotationrecttextitem.py index 565004d1387..014b14b16bc 100644 --- a/tests/src/python/test_qgsannotationrecttextitem.py +++ b/tests/src/python/test_qgsannotationrecttextitem.py @@ -577,7 +577,7 @@ class TestQgsAnnotationRectangleTextItem(QgisTestCase): format.setSize(20) item.setFormat(format) - item.setAlignment(Qt.AlignRight | Qt.AlignBottom) + item.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignBottom) settings = QgsMapSettings() settings.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4326')) diff --git a/tests/src/python/test_qgsrelation.py b/tests/src/python/test_qgsrelation.py index bb5bbc45b97..af5ca52f365 100644 --- a/tests/src/python/test_qgsrelation.py +++ b/tests/src/python/test_qgsrelation.py @@ -265,7 +265,7 @@ class TestQgsRelation(QgisTestCase): referencingLayer = rel.referencingLayer() # Set Not Null constraint on the field - referencingLayer.setFieldConstraint(referencingLayer.fields().indexFromName('foreignkey'), QgsFieldConstraints.ConstraintNotNull) + referencingLayer.setFieldConstraint(referencingLayer.fields().indexFromName('foreignkey'), QgsFieldConstraints.Constraint.ConstraintNotNull) self.assertFalse(rel.referencingFieldsAllowNull()) diff --git a/tests/src/python/test_qgsserver_wms.py b/tests/src/python/test_qgsserver_wms.py index 9303996540e..4c4d42f066b 100644 --- a/tests/src/python/test_qgsserver_wms.py +++ b/tests/src/python/test_qgsserver_wms.py @@ -440,7 +440,7 @@ class TestQgsServerWMS(TestQgsServerWMSTestBase): project = QgsProject() fields = QgsFields() fields.append(QgsField('int', QVariant.Int)) - layer = QgsMemoryProviderUtils.createMemoryLayer('pointlabel', fields, QgsWkbTypes.Point, QgsCoordinateReferenceSystem(4326)) + layer = QgsMemoryProviderUtils.createMemoryLayer('pointlabel', fields, QgsWkbTypes.Type.Point, QgsCoordinateReferenceSystem(4326)) layer.setLabelsEnabled(True) settings = QgsPalLayerSettings() settings.xOffset = -10 diff --git a/tests/src/python/test_qgsvariantutils.py b/tests/src/python/test_qgsvariantutils.py index 9dd4a493931..df62fe81c36 100644 --- a/tests/src/python/test_qgsvariantutils.py +++ b/tests/src/python/test_qgsvariantutils.py @@ -24,24 +24,24 @@ class TestQgsVariantUtils(unittest.TestCase): def test_is_numeric_type(self): - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Int)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.UInt)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.LongLong)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.ULongLong)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Double)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Float)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Short)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.UShort)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Char)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.UChar)) - self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.SChar)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.Int)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.UInt)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.LongLong)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.ULongLong)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.Double)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.Float)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.Short)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.UShort)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.Char)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.UChar)) + self.assertTrue(QgsVariantUtils.isNumericType(QMetaType.Type.SChar)) - self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.Bool)) - self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.QString)) - self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.QByteArray)) - self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.QDateTime)) - self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.QDate)) - self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.QTime)) + self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.Type.Bool)) + self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.Type.QString)) + self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.Type.QByteArray)) + self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.Type.QDateTime)) + self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.Type.QDate)) + self.assertFalse(QgsVariantUtils.isNumericType(QMetaType.Type.QTime)) if __name__ == '__main__':