mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed some SonarQube issues.
This commit is contained in:
@@ -188,7 +188,8 @@ class Driver(BaseDriver):
|
||||
"""
|
||||
manager = self.connection_manager(sid)
|
||||
|
||||
return manager.connection(database, conn_id, auto_reconnect)
|
||||
return manager.connection(database=database, conn_id=conn_id,
|
||||
auto_reconnect=auto_reconnect)
|
||||
|
||||
def release_connection(self, sid, database=None, conn_id=None):
|
||||
"""
|
||||
|
||||
@@ -145,11 +145,15 @@ class Connection(BaseConnection):
|
||||
gettext("Cursor could not be found for the async connection.")
|
||||
ARGS_STR = "{0}#{1}"
|
||||
|
||||
def __init__(self, manager, conn_id, db, auto_reconnect=True, async_=0,
|
||||
use_binary_placeholder=False, array_to_string=False):
|
||||
def __init__(self, manager, conn_id, db, **kwargs):
|
||||
assert (manager is not None)
|
||||
assert (conn_id is not None)
|
||||
|
||||
auto_reconnect = kwargs.get('auto_reconnect', True)
|
||||
async_ = kwargs.get('async_', 0)
|
||||
use_binary_placeholder = kwargs.get('use_binary_placeholder', False)
|
||||
array_to_string = kwargs.get('array_to_string', False)
|
||||
|
||||
self.conn_id = conn_id
|
||||
self.manager = manager
|
||||
self.db = db if db is not None else manager.db
|
||||
|
||||
@@ -182,10 +182,15 @@ class ServerManager(object):
|
||||
return int(int(self.sversion / 100) / 100)
|
||||
raise InternalServerError(self._INFORMATION_MSG)
|
||||
|
||||
def connection(
|
||||
self, database=None, conn_id=None, auto_reconnect=True, did=None,
|
||||
async_=None, use_binary_placeholder=False, array_to_string=False
|
||||
):
|
||||
def connection(self, **kwargs):
|
||||
database = kwargs.get('database', None)
|
||||
conn_id = kwargs.get('conn_id', None)
|
||||
auto_reconnect = kwargs.get('auto_reconnect', True)
|
||||
did = kwargs.get('did', None)
|
||||
async_ = kwargs.get('async_', None)
|
||||
use_binary_placeholder = kwargs.get('use_binary_placeholder', False)
|
||||
array_to_string = kwargs.get('array_to_string', False)
|
||||
|
||||
if database is not None:
|
||||
if did is not None and did in self.db_info:
|
||||
self.db_info[did]['datname'] = database
|
||||
@@ -247,7 +252,8 @@ WHERE db.oid = {0}""".format(did))
|
||||
else:
|
||||
async_ = 1 if async_ is True else 0
|
||||
self.connections[my_id] = Connection(
|
||||
self, my_id, database, auto_reconnect, async_,
|
||||
self, my_id, database, auto_reconnect=auto_reconnect,
|
||||
async_=async_,
|
||||
use_binary_placeholder=use_binary_placeholder,
|
||||
array_to_string=array_to_string
|
||||
)
|
||||
|
||||
@@ -475,7 +475,7 @@ class Preferences(object):
|
||||
|
||||
@classmethod
|
||||
def register_preference(
|
||||
cls, module, category, name, label, _type, default, **kwargs
|
||||
cls, module, category, name, label, _type, **kwargs
|
||||
):
|
||||
"""
|
||||
register
|
||||
@@ -489,8 +489,8 @@ class Preferences(object):
|
||||
Allowed type of options are as below:
|
||||
boolean, integer, numeric, date, datetime,
|
||||
options, multiline, switch, node
|
||||
:param default: Default value for the preference/option
|
||||
"""
|
||||
default = kwargs.get('default')
|
||||
min_val = kwargs.get('min_val', None)
|
||||
max_val = kwargs.get('max_val', None)
|
||||
options = kwargs.get('options', None)
|
||||
@@ -498,7 +498,6 @@ class Preferences(object):
|
||||
module_label = kwargs.get('module_label', None)
|
||||
category_label = kwargs.get('category_label', None)
|
||||
|
||||
m = None
|
||||
if module in Preferences.modules:
|
||||
m = Preferences.modules[module]
|
||||
# Update the label (if not defined yet)
|
||||
|
||||
Reference in New Issue
Block a user