9710: dbapi pylint issues, adjustment
This commit is contained in:
parent
ae06d046c5
commit
9e5f899bbd
@ -443,16 +443,22 @@ class DBAPI(DbGeneric):
|
|||||||
txn.last = None
|
txn.last = None
|
||||||
self._after_commit(txn)
|
self._after_commit(txn)
|
||||||
|
|
||||||
def get_metadata(self, key, default=None):
|
def get_metadata(self, key, default=[]):
|
||||||
"""
|
"""
|
||||||
Get an item from the database.
|
Get an item from the database.
|
||||||
|
|
||||||
|
Default is an empty list, which is a mutable and
|
||||||
|
thus a bad default (pylint will complain).
|
||||||
|
|
||||||
|
However, it is just used as a value, and not altered, so
|
||||||
|
its use here is ok.
|
||||||
"""
|
"""
|
||||||
self.dbapi.execute(
|
self.dbapi.execute(
|
||||||
"SELECT value FROM metadata WHERE setting = ?;", [key])
|
"SELECT value FROM metadata WHERE setting = ?;", [key])
|
||||||
row = self.dbapi.fetchone()
|
row = self.dbapi.fetchone()
|
||||||
if row:
|
if row:
|
||||||
return pickle.loads(row[0])
|
return pickle.loads(row[0])
|
||||||
elif default == None:
|
elif default == []:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
return default
|
return default
|
||||||
|
Loading…
Reference in New Issue
Block a user