From d9f344fcef6bec04a787f9ea9f4ea94f15eaa26c Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 4 Jan 2021 21:03:22 +0100 Subject: sources: migration from format() to f-strings This should be the last patch related the usage of f-strings from the 'sources' directory. Pick-to: 6.0 Change-Id: I0288d720dc4930dee088ca3396a66d1b3ba18f76 Reviewed-by: Friedemann Kleint --- sources/pyside6/doc/tutorials/qmlsqlintegration/main.py | 3 ++- sources/pyside6/doc/tutorials/qmlsqlintegration/sqlDialog.py | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sources/pyside6/doc/tutorials/qmlsqlintegration') diff --git a/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py b/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py index 50a3d43fe..03050ff32 100644 --- a/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py +++ b/sources/pyside6/doc/tutorials/qmlsqlintegration/main.py @@ -62,7 +62,8 @@ def connectToDatabase(): logger.error("Failed to create writable directory") # Ensure that we have a writable location on all devices. - filename = "{}/chat-database.sqlite3".format(write_dir.absolutePath()) + abs_path = write_dir.absolutePath() + filename = f"{abs_path}/chat-database.sqlite3" # When using the SQLite driver, open() will create the SQLite # database if it doesn't exist. diff --git a/sources/pyside6/doc/tutorials/qmlsqlintegration/sqlDialog.py b/sources/pyside6/doc/tutorials/qmlsqlintegration/sqlDialog.py index a9745051b..2b62c578b 100644 --- a/sources/pyside6/doc/tutorials/qmlsqlintegration/sqlDialog.py +++ b/sources/pyside6/doc/tutorials/qmlsqlintegration/sqlDialog.py @@ -96,9 +96,8 @@ class SqlConversationModel(QSqlTableModel): self.recipient = recipient - filter_str = ( - "(recipient = '{}' AND author = 'Me') OR " "(recipient = 'Me' AND author='{}')" - ).format(self.recipient) + filter_str = (f"(recipient = '{self.recipient}' AND author = 'Me') OR " + f"(recipient = 'Me' AND author='{self.recipient}')") self.setFilter(filter_str) self.select() @@ -136,10 +135,10 @@ class SqlConversationModel(QSqlTableModel): new_record.setValue("timestamp", str(timestamp)) new_record.setValue("message", message) - logging.debug('Message: "{}" \n Received by: "{}"'.format(message, recipient)) + logging.debug(f'Message: "{message}" \n Received by: "{recipient}"') if not self.insertRecord(self.rowCount(), new_record): - logging.error("Failed to send message: {}".format(self.lastError().text())) + logging.error("Failed to send message: {self.lastError().text()}") return self.submitAll() -- cgit v1.2.3