From e961fc97b8600ea397485cfca35d3e185d0aa6d6 Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Fri, 29 Apr 2016 22:44:45 +0200 Subject: [PATCH] Improve readability of rowcount and query duration (fixes #19). --- CHANGES | 1 + rsr/cmd.py | 3 +++ rsr/connections/query.py | 12 ++++++++---- rsr/connections/ui.py | 4 +++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 8ac4fac..7bb430d 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Development Version * Use system fonts when possible. * Change shortcuts for changing tabs to Alt+NUMBER (instead of Control+NUMBER, #21). +* Improve readability of rowcount and query duration (#19). Version 0.4.1 (2015-04-30) diff --git a/rsr/cmd.py b/rsr/cmd.py index e8a120d..3245d57 100644 --- a/rsr/cmd.py +++ b/rsr/cmd.py @@ -1,3 +1,4 @@ +import locale import os import signal import sys @@ -21,6 +22,8 @@ # any Oracle connection. os.environ.setdefault('NLS_LANG', '.AL32UTF8') +locale.setlocale(locale.LC_ALL, '.'.join(locale.getlocale())) + def main(): parser.parse_args() diff --git a/rsr/connections/query.py b/rsr/connections/query.py index 3b20ab8..0fb307d 100644 --- a/rsr/connections/query.py +++ b/rsr/connections/query.py @@ -1,3 +1,5 @@ +import locale + from gi.repository import GObject @@ -26,8 +28,10 @@ def get_result_summary(self): if not self.finished: return None if self.result is not None: - return '%i rows, %.3f seconds' % (len(self.result), - self.execution_duration) + return '{} rows, {} seconds'.format( + locale.format('%d', len(self.result), grouping=True), + locale.format('%.3f', self.execution_duration, grouping=True)) else: - return '%i rows affected, %.3f seconds' % (self.rowcount, - self.execution_duration) + return '{} rows affected, {} seconds'.format( + locale.format('%d', self.rowcount, grouping=True), + locale.foramt('%.3f', self.execution_duration, grouping=True)) diff --git a/rsr/connections/ui.py b/rsr/connections/ui.py index b5a5010..8545235 100644 --- a/rsr/connections/ui.py +++ b/rsr/connections/ui.py @@ -1,3 +1,4 @@ +import locale import time from gi.repository import Gtk, GObject, Gio @@ -341,5 +342,6 @@ def on_query_changed(self, editor): GObject.timeout_add(10, self.on_query_changed, self._editor) else: duration = time.time() - query.start_time - self.lbl_query.set_text('Running for %.3f seconds' % duration) + self.lbl_query.set_text('Running for {} seconds'.format( + locale.format('%.3f', duration, grouping=True))) GObject.timeout_add(10, self.on_query_changed, self._editor)