Skip to content

Commit 4d376b9

Browse files
authored
Revert "API Changes"
1 parent 51aefaf commit 4d376b9

32 files changed

+165
-996
lines changed

Test_utils.py

Lines changed: 0 additions & 140 deletions
This file was deleted.

__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ def icon():
3232
def qgisMinimumVersion():
3333
return "1.7"
3434
def classFactory(iface):
35-
from pgRoutingLayer import pgRoutingLayer
36-
return pgRoutingLayer(iface)
35+
from pgRoutingLayer import PgRoutingLayer
36+
return PgRoutingLayer(iface)

connectors/postgis.py

100755100644
Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
System information functions:
1616
http://www.postgresql.org/docs/8.0/static/functions-info.html
1717
"""
18-
from __future__ import print_function
19-
from builtins import str
20-
from builtins import map
21-
from qgis.core import QgsDataSourceUri
22-
from qgis.PyQt.QtCore import QSettings
23-
from qgis.PyQt.QtGui import QIcon
24-
from qgis.PyQt.QtWidgets import QInputDialog
2518

19+
from PyQt4.QtCore import *
20+
from PyQt4.QtGui import *
2621

22+
import qgis.core
2723

2824
import psycopg2
2925
import psycopg2.extensions # for isolation levels
@@ -47,7 +43,7 @@ class TableConstraint(DbConn.TableConstraint):
4743

4844
def __init__(self, row):
4945
self.name, con_type, self.is_defferable, self.is_deffered, keys = row[:5]
50-
self.keys = list(map(int, keys.split(' ')))
46+
self.keys = map(int, keys.split(' '))
5147
self.con_type = TableConstraint.types[con_type] # convert to enum
5248
if self.con_type == TableConstraint.TypeCheck:
5349
self.check_src = row[5]
@@ -62,7 +58,7 @@ def __init__(self, row):
6258
class TableIndex(DbConn.TableIndex):
6359
def __init__(self, row):
6460
self.name, columns = row
65-
self.columns = list(map(int, columns.split(' ')))
61+
self.columns = map(int, columns.split(' '))
6662

6763

6864
class TableTrigger(DbConn.TableTrigger):
@@ -78,12 +74,12 @@ def __init__(self, row):
7874
class DbError(DbConn.DbError):
7975
def __init__(self, error, query=None):
8076
# save error. funny that the variables are in utf8, not
81-
msg = str( error.args[0], 'utf-8')
77+
msg = unicode( error.args[0], 'utf-8')
8278
if query == None:
8379
if hasattr(error, "cursor") and hasattr(error.cursor, "query"):
84-
query = str(error.cursor.query, 'utf-8')
80+
query = unicode(error.cursor.query, 'utf-8')
8581
else:
86-
query = str(query)
82+
query = unicode(query)
8783
DbConn.DbError.__init__(self, msg, query)
8884

8985

@@ -122,8 +118,8 @@ def connect(self, selected, parent=None):
122118
if not settings.contains( "database" ): # non-existent entry?
123119
raise DbError( 'there is no defined database connection "%s".' % selected )
124120

125-
get_value_str = lambda x: str(settings.value(x) if Utils.isSIPv2() else settings.value(x).toString())
126-
service, host, port, database, username, password = list(map(get_value_str, ["service", "host", "port", "database", "username", "password"]))
121+
get_value_str = lambda x: unicode(settings.value(x) if Utils.isSIPv2() else settings.value(x).toString())
122+
service, host, port, database, username, password = map(get_value_str, ["service", "host", "port", "database", "username", "password"])
127123

128124
# qgis1.5 use 'savePassword' instead of 'save' setting
129125
isSave = settings.value("save") if Utils.isSIPv2() else settings.value("save").toBool()
@@ -134,7 +130,7 @@ def connect(self, selected, parent=None):
134130

135131
settings.endGroup()
136132

137-
uri = qgis.core.QgsDataSourceUri()
133+
uri = qgis.core.QgsDataSourceURI()
138134
if service:
139135
uri.setConnection(service, database, username, password)
140136
else:
@@ -155,7 +151,7 @@ def __init__(self, uri):
155151

156152
try:
157153
self.con = psycopg2.connect(self.con_info())
158-
except psycopg2.OperationalError as e:
154+
except psycopg2.OperationalError, e:
159155
raise DbError(e)
160156

161157
if not self.dbname:
@@ -726,7 +722,7 @@ def sr_info_for_srid(self, srid):
726722
if x is not None:
727723
srtext = x.group()
728724
return srtext
729-
except DbError as e:
725+
except DbError, e:
730726
return "Unknown"
731727

732728
def insert_table_row(self, table, values, schema=None, cursor=None):
@@ -792,7 +788,7 @@ def get_named_cursor(self, table=None):
792788
def _exec_sql(self, cursor, sql):
793789
try:
794790
cursor.execute(sql)
795-
except psycopg2.Error as e:
791+
except psycopg2.Error, e:
796792
# do the rollback to avoid a "current transaction aborted, commands ignored" errors
797793
self.con.rollback()
798794
raise DbError(e)
@@ -808,12 +804,12 @@ def _exec_sql_and_commit(self, sql):
808804
# raise
809805

810806
def _quote(self, identifier):
811-
identifier = str(identifier) # make sure it's python unicode string
807+
identifier = unicode(identifier) # make sure it's python unicode string
812808
return u'"%s"' % identifier.replace('"', '""')
813809

814810
def _quote_str(self, txt):
815811
""" make the string safe - replace ' with '' """
816-
txt = str(txt) # make sure it's python unicode string
812+
txt = unicode(txt) # make sure it's python unicode string
817813
return txt.replace("'", "''")
818814

819815
def _table_name(self, schema, table):
@@ -828,34 +824,25 @@ def _table_name(self, schema, table):
828824

829825
db = GeoDB(host='localhost',dbname='gis',user='gisak',passwd='g')
830826

831-
# fix_print_with_import
832-
print(db.list_schemas())
833-
# fix_print_with_import
834-
print('==========')
827+
print db.list_schemas()
828+
print '=========='
835829

836830
for row in db.list_geotables():
837-
# fix_print_with_import
838-
print(row)
831+
print row
839832

840-
# fix_print_with_import
841-
print('==========')
833+
print '=========='
842834

843835
for row in db.get_table_indexes('trencin'):
844-
# fix_print_with_import
845-
print(row)
836+
print row
846837

847-
# fix_print_with_import
848-
print('==========')
838+
print '=========='
849839

850840
for row in db.get_table_constraints('trencin'):
851-
# fix_print_with_import
852-
print(row)
841+
print row
853842

854-
# fix_print_with_import
855-
print('==========')
843+
print '=========='
856844

857-
# fix_print_with_import
858-
print(db.get_table_rows('trencin'))
845+
print db.get_table_rows('trencin')
859846

860847
#for fld in db.get_table_metadata('trencin'):
861848
# print fld

0 commit comments

Comments
 (0)