Skip to content

Commit 57b1618

Browse files
committed
[processing] move spatialite and postgis utils into tools package
1 parent 6e13020 commit 57b1618

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

python/plugins/processing/algs/qgis/ImportIntoPostGIS.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
from processing.core.parameters import ParameterString
3636
from processing.core.parameters import ParameterSelection
3737
from processing.core.parameters import ParameterTableField
38-
from processing.tools import dataobjects
39-
from processing.algs.qgis import postgis_utils
38+
from processing.tools import dataobjects, postgis
4039

4140

4241
class ImportIntoPostGIS(GeoAlgorithm):
@@ -117,9 +116,9 @@ def processAlgorithm(self, progress):
117116
providerName = 'postgres'
118117

119118
try:
120-
db = postgis_utils.GeoDB(host=host, port=port, dbname=database,
119+
db = postgis.GeoDB(host=host, port=port, dbname=database,
121120
user=username, passwd=password)
122-
except postgis_utils.DbError as e:
121+
except postgis.DbError as e:
123122
raise GeoAlgorithmExecutionException(
124123
self.tr("Couldn't connect to database:\n%s") % unicode(e))
125124

python/plugins/processing/algs/qgis/PostGISExecuteSQL.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from processing.core.GeoAlgorithm import GeoAlgorithm
3131
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
3232
from processing.core.parameters import ParameterString
33-
from processing.algs.qgis import postgis_utils
33+
from processing.tools import postgis
3434

3535

3636
class PostGISExecuteSQL(GeoAlgorithm):
@@ -58,15 +58,15 @@ def processAlgorithm(self, progress):
5858
raise GeoAlgorithmExecutionException(
5959
self.tr('Wrong database connection name: %s' % connection))
6060
try:
61-
self.db = postgis_utils.GeoDB(host=host, port=port,
61+
self.db = postgis.GeoDB(host=host, port=port,
6262
dbname=database, user=username, passwd=password)
63-
except postgis_utils.DbError as e:
63+
except postgis.DbError as e:
6464
raise GeoAlgorithmExecutionException(
6565
self.tr("Couldn't connect to database:\n%s") % unicode(e))
6666

6767
sql = self.getParameterValue(self.SQL).replace('\n', ' ')
6868
try:
6969
self.db._exec_sql_and_commit(unicode(sql))
70-
except postgis_utils.DbError as e:
70+
except postgis.DbError as e:
7171
raise GeoAlgorithmExecutionException(
7272
self.tr('Error executing SQL:\n%s') % unicode(e))

python/plugins/processing/gui/PostgisTableSelector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from qgis.PyQt.QtGui import QIcon
3232
from qgis.PyQt.QtWidgets import QTreeWidgetItem, QMessageBox
3333
from qgis.PyQt import uic
34-
from processing.algs.qgis.postgis_utils import GeoDB
3534
from qgis.core import QgsDataSourceURI, QgsCredentials
35+
from processing.tools.postgis import GeoDB
3636

3737
pluginPath = os.path.split(os.path.dirname(__file__))[0]
3838
WIDGET, BASE = uic.loadUiType(

python/plugins/processing/algs/qgis/postgis_utils.py renamed to python/plugins/processing/tools/postgis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
***************************************************************************
5-
postgis_utils.py
5+
postgis.py
66
---------------------
77
Date : November 2012
88
Copyright : (C) 2012 by Martin Dobias

python/plugins/processing/algs/qgis/spatialite_utils.py renamed to python/plugins/processing/tools/spatialite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
***************************************************************************
5-
spatialite_utils.py
5+
spatialite.py
66
---------------------
77
Date : November 2015
88
Copyright : (C) 2015 by René-Luc Dhont

python/plugins/processing/tools/vector.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* *
1717
***************************************************************************
1818
"""
19-
from processing.algs.qgis import postgis_utils
20-
from processing.algs.qgis import spatialite_utils
2119

2220
__author__ = 'Victor Olaya'
2321
__date__ = 'February 2013'
@@ -43,7 +41,7 @@
4341

4442
from processing.core.ProcessingConfig import ProcessingConfig
4543
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
46-
from processing.tools import dataobjects
44+
from processing.tools import dataobjects, spatialite, postgis
4745

4846

4947
GEOM_TYPE_MAP = {
@@ -581,16 +579,16 @@ def __init__(self, destination, encoding, fields, geometryType,
581579
raise GeoAlgorithmExecutionException("Couldn't connect to database")
582580
print uri.uri()
583581
try:
584-
db = postgis_utils.GeoDB(host=uri.host(), port=int(uri.port()),
582+
db = postgis.GeoDB(host=uri.host(), port=int(uri.port()),
585583
dbname=uri.database(), user=user, passwd=passwd)
586-
except postgis_utils.DbError as e:
584+
except postgis.DbError as e:
587585
raise GeoAlgorithmExecutionException(
588586
"Couldn't connect to database:\n%s" % e.message)
589587

590588
def _runSQL(sql):
591589
try:
592590
db._exec_sql_and_commit(unicode(sql))
593-
except postgis_utils.DbError as e:
591+
except postgis.DbError as e:
594592
raise GeoAlgorithmExecutionException(
595593
'Error creating output PostGIS table:\n%s' % e.message)
596594

@@ -612,15 +610,15 @@ def _runSQL(sql):
612610
uri = QgsDataSourceURI(self.destination[len(self.SPATIALITE_LAYER_PREFIX):])
613611
print uri.uri()
614612
try:
615-
db = spatialite_utils.GeoDB(uri=uri)
616-
except spatialite_utils.DbError as e:
613+
db = spatialite.GeoDB(uri=uri)
614+
except spatialite.DbError as e:
617615
raise GeoAlgorithmExecutionException(
618616
"Couldn't connect to database:\n%s" % e.message)
619617

620618
def _runSQL(sql):
621619
try:
622620
db._exec_sql_and_commit(unicode(sql))
623-
except spatialite_utils.DbError as e:
621+
except spatialite.DbError as e:
624622
raise GeoAlgorithmExecutionException(
625623
'Error creating output Spatialite table:\n%s' % unicode(e))
626624

0 commit comments

Comments
 (0)