Skip to content

Commit

Permalink
List comprehensions to generators
Browse files Browse the repository at this point in the history
  • Loading branch information
dericke committed Jan 25, 2021
1 parent 8cd0f92 commit 63e7737
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
10 changes: 4 additions & 6 deletions python/plugins/db_manager/db_plugins/connector.py
Expand Up @@ -188,12 +188,11 @@ def _get_cursor_columns(self, c):
@classmethod
def quoteId(self, identifier):
if hasattr(identifier, '__iter__') and not isinstance(identifier, str):
ids = [
return u'.'.join(
self.quoteId(i)
for i in identifier
if i is not None and i != ""
]
return u'.'.join(ids)
)

identifier = str(
identifier) if identifier is not None else str() # make sure it's python unicode string
Expand All @@ -203,12 +202,11 @@ def quoteId(self, identifier):
def quoteString(self, txt):
""" make the string safe - replace ' with '' """
if hasattr(txt, '__iter__') and not isinstance(txt, str):
txts = [
return u'.'.join(
self.quoteString(i)
for i in txt
if i is not None
]
return u'.'.join(txts)
)

txt = str(txt) if txt is not None else str() # make sure it's python unicode string
return u"'%s'" % txt.replace("'", "''")
Expand Down
12 changes: 4 additions & 8 deletions python/plugins/db_manager/dlg_sql_window.py
Expand Up @@ -442,13 +442,11 @@ def showError(self, error):
def _getSqlLayer(self, _filter):
hasUniqueField = self.uniqueColumnCheck.checkState() == Qt.Checked
if hasUniqueField and self.allowMultiColumnPk:
checkedCols = [
uniqueFieldName = ",".join(
item.data()
for item in self.uniqueModel.findItems("*", Qt.MatchWildcard)
if item.checkState() == Qt.Checked
]

uniqueFieldName = ",".join(checkedCols)
)
elif (
hasUniqueField
and not self.allowMultiColumnPk
Expand Down Expand Up @@ -679,13 +677,11 @@ def uniqueChanged(self):

def uniqueTextChanged(self, text):
# Whenever there is new text displayed in the combobox, check if it is the correct one and if not, display the correct one.
checkedItems = [
label = ", ".join(
item.text()
for item in self.uniqueModel.findItems("*", Qt.MatchWildcard)
if item.checkState() == Qt.Checked
]

label = ", ".join(checkedItems)
)
if text != label:
self.uniqueCombo.setEditText(label)

Expand Down

0 comments on commit 63e7737

Please sign in to comment.