Skip to content

Commit

Permalink
Remove references to QPyNullVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 13, 2016
1 parent 89b7a4a commit 25f2e63
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
11 changes: 5 additions & 6 deletions python/plugins/db_manager/db_plugins/oracle/connector.py
Expand Up @@ -23,14 +23,13 @@
***************************************************************************/ ***************************************************************************/
""" """


from qgis.PyQt.QtCore import QPyNullVariant
from qgis.PyQt.QtSql import QSqlDatabase from qgis.PyQt.QtSql import QSqlDatabase


from ..connector import DBConnector from ..connector import DBConnector
from ..plugin import ConnectionError, DbError, Table from ..plugin import ConnectionError, DbError, Table


import os import os
from qgis.core import QGis, QgsApplication from qgis.core import QGis, QgsApplication, NULL
from . import QtSqlDB from . import QtSqlDB
import sqlite3 import sqlite3


Expand Down Expand Up @@ -611,7 +610,7 @@ def getVectorTables(self, schema=None):
for i, tbl in enumerate(lst_tables): for i, tbl in enumerate(lst_tables):
item = list(tbl) item = list(tbl)
detectedSrid = item.pop() detectedSrid = item.pop()
if isinstance(detectedSrid, QPyNullVariant): if detectedSrid == NULL:
detectedSrid = u"-1" detectedSrid = u"-1"
else: else:
detectedSrid = int(detectedSrid) detectedSrid = int(detectedSrid)
Expand Down Expand Up @@ -779,7 +778,7 @@ def getTableGeomTypes(self, table, geomCol):
geomtypes = [] geomtypes = []
srids = [] srids = []
for row in rows: for row in rows:
if isinstance(row[1], QPyNullVariant): if row[1] == NULL:
srids.append(-1) srids.append(-1)
else: else:
srids.append(int(row[1])) srids.append(int(row[1]))
Expand Down Expand Up @@ -831,7 +830,7 @@ def getTableRowEstimation(self, table):
res = self._fetchone(c) res = self._fetchone(c)
c.close() c.close()


if not res or isinstance(res[0], QPyNullVariant): if not res or res[0] == NULL:
return 0 return 0
else: else:
return int(res[0]) return int(res[0])
Expand Down Expand Up @@ -1113,7 +1112,7 @@ def getTableEstimatedExtent(self, table, geom):


if not res_d or len(res_d) < 2: if not res_d or len(res_d) < 2:
return None return None
elif isinstance(res_d[0], QPyNullVariant): elif res_d[0] == NULL:
return None return None
else: else:
res.extend(res_d) res.extend(res_d)
Expand Down
18 changes: 9 additions & 9 deletions python/plugins/db_manager/db_plugins/oracle/plugin.py
Expand Up @@ -26,11 +26,11 @@
# this will disable the dbplugin if the connector raise an ImportError # this will disable the dbplugin if the connector raise an ImportError
from .connector import OracleDBConnector from .connector import OracleDBConnector


from qgis.PyQt.QtCore import Qt, QSettings, QPyNullVariant from qgis.PyQt.QtCore import Qt, QSettings
from qgis.PyQt.QtGui import QIcon, QKeySequence from qgis.PyQt.QtGui import QIcon, QKeySequence
from qgis.PyQt.QtWidgets import QAction, QApplication, QMessageBox from qgis.PyQt.QtWidgets import QAction, QApplication, QMessageBox


from qgis.core import QgsVectorLayer from qgis.core import QgsVectorLayer, NULL


from ..plugin import ConnectionError, InvalidDataException, DBPlugin, \ from ..plugin import ConnectionError, InvalidDataException, DBPlugin, \
Database, Schema, Table, VectorTable, TableField, TableConstraint, \ Database, Schema, Table, VectorTable, TableField, TableConstraint, \
Expand Down Expand Up @@ -487,12 +487,12 @@ def __init__(self, row, table):


self.primaryKey = False self.primaryKey = False
self.num = int(self.num) self.num = int(self.num)
if isinstance(self.charMaxLen, QPyNullVariant): if self.charMaxLen == NULL:
self.charMaxLen = None self.charMaxLen = None
else: else:
self.charMaxLen = int(self.charMaxLen) self.charMaxLen = int(self.charMaxLen)


if isinstance(self.modifier, QPyNullVariant): if self.modifier == NULL:
self.modifier = None self.modifier = None
else: else:
self.modifier = int(self.modifier) self.modifier = int(self.modifier)
Expand All @@ -502,7 +502,7 @@ def __init__(self, row, table):
else: else:
self.notNull = True self.notNull = True


if isinstance(self.comment, QPyNullVariant): if self.comment == NULL:
self.comment = u"" self.comment = u""


# find out whether fields are part of primary key # find out whether fields are part of primary key
Expand Down Expand Up @@ -571,22 +571,22 @@ def __init__(self, row, table):
else: else:
self.type = ORTableConstraint.TypeUnknown self.type = ORTableConstraint.TypeUnknown


if isinstance(row[6], QPyNullVariant): if row[6] == NULL:
self.checkSource = u"" self.checkSource = u""
else: else:
self.checkSource = row[6] self.checkSource = row[6]


if isinstance(row[8], QPyNullVariant): if row[8] == NULL:
self.foreignTable = u"" self.foreignTable = u""
else: else:
self.foreignTable = row[8] self.foreignTable = row[8]


if isinstance(row[7], QPyNullVariant): if row[7] == NULL:
self.foreignOnDelete = u"" self.foreignOnDelete = u""
else: else:
self.foreignOnDelete = row[7] self.foreignOnDelete = row[7]


if isinstance(row[9], QPyNullVariant): if row[9] == NULL:
self.foreignKey = u"" self.foreignKey = u""
else: else:
self.foreignKey = row[9] self.foreignKey = row[9]
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/core/ProcessingConfig.py
Expand Up @@ -27,8 +27,9 @@


import os import os


from qgis.PyQt.QtCore import QPyNullVariant, QCoreApplication, QSettings, QObject, pyqtSignal from qgis.PyQt.QtCore import QCoreApplication, QSettings, QObject, pyqtSignal
from qgis.PyQt.QtGui import QIcon from qgis.PyQt.QtGui import QIcon
from qgis.core import NULL
from processing.tools.system import defaultOutputFolder from processing.tools.system import defaultOutputFolder
import processing.tools.dataobjects import processing.tools.dataobjects


Expand Down Expand Up @@ -196,7 +197,7 @@ def getSetting(name):
if name in ProcessingConfig.settings.keys(): if name in ProcessingConfig.settings.keys():
v = ProcessingConfig.settings[name].value v = ProcessingConfig.settings[name].value
try: try:
if isinstance(v, QPyNullVariant): if v == NULL:
v = None v = None
except: except:
pass pass
Expand Down
12 changes: 7 additions & 5 deletions python/plugins/processing/gui/ConfigDialog.py
Expand Up @@ -29,8 +29,8 @@


from qgis.PyQt import uic from qgis.PyQt import uic
from qgis.PyQt.QtCore import (Qt, from qgis.PyQt.QtCore import (Qt,
QEvent, QEvent
QPyNullVariant) )
from qgis.PyQt.QtWidgets import (QFileDialog, from qgis.PyQt.QtWidgets import (QFileDialog,
QDialog, QDialog,
QStyle, QStyle,
Expand All @@ -45,8 +45,10 @@
QStandardItemModel, QStandardItemModel,
QStandardItem) QStandardItem)


from qgis.gui import QgsDoubleSpinBox from qgis.gui import (QgsDoubleSpinBox,
from qgis.gui import QgsSpinBox QgsSpinBox
)
from qgis.core import NULL


from processing.core.ProcessingConfig import (ProcessingConfig, from processing.core.ProcessingConfig import (ProcessingConfig,
settingsWatcher, settingsWatcher,
Expand Down Expand Up @@ -340,7 +342,7 @@ def eventFilter(self, editor, event):
return QStyledItemDelegate.eventFilter(self, editor, event) return QStyledItemDelegate.eventFilter(self, editor, event)


def convertValue(self, value): def convertValue(self, value):
if value is None or isinstance(value, QPyNullVariant): if value is None or value == NULL:
return "" return ""
try: try:
return int(value) return int(value)
Expand Down

0 comments on commit 25f2e63

Please sign in to comment.