From 2f4868548be8b3821cdbec047892b7d940c04908 Mon Sep 17 00:00:00 2001 From: Ievgenii Meshcheriakov Date: Tue, 6 Jul 2021 09:20:56 +0200 Subject: [PATCH] locale_database: Use super() to call base class methods This is the standard way to call base class methods in Python 3 and it is shorter than the custom one used now. Task-number: QTBUG-83488 Pick-to: 6.2 Change-Id: Ifaff591a46e92148fbf514856109ff794a50c9f7 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Edward Welbourne --- util/locale_database/localetools.py | 9 +++------ util/locale_database/qlocalexml2cpp.py | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/util/locale_database/localetools.py b/util/locale_database/localetools.py index 82691666aab..1f415bbdb3e 100644 --- a/util/locale_database/localetools.py +++ b/util/locale_database/localetools.py @@ -41,9 +41,8 @@ import os import tempfile class Error (Exception): - __upinit = Exception.__init__ def __init__(self, msg, *args): - self.__upinit(msg, *args) + super().__init__(msg, *args) self.message = msg def __str__(self): return self.message @@ -126,7 +125,6 @@ class SourceFileEditor (Transcriber): Callers should call close() on success or cleanup() on failure (to clear away the temporary file); see Transcriber. """ - __upinit = Transcriber.__init__ def __init__(self, path, temp): """Set up the source file editor. @@ -134,13 +132,12 @@ class SourceFileEditor (Transcriber): and, on success, replaced with a new version; and the directory in which to store the temporary file during the rewrite.""" - self.__upinit(path, temp) + super().__init__(path, temp) self.__copyPrelude() - __upclose = Transcriber.close def close(self): self.__copyTail() - self.__upclose() + super().close() # Implementation details: GENERATED_BLOCK_START = '// GENERATED PART STARTS HERE' diff --git a/util/locale_database/qlocalexml2cpp.py b/util/locale_database/qlocalexml2cpp.py index e510a49259d..6ddb1dbd88b 100755 --- a/util/locale_database/qlocalexml2cpp.py +++ b/util/locale_database/qlocalexml2cpp.py @@ -133,9 +133,8 @@ def currencyIsoCodeData(s): return "{0,0,0}" class LocaleSourceEditor (SourceFileEditor): - __upinit = SourceFileEditor.__init__ def __init__(self, path, temp, version): - self.__upinit(path, temp) + super().__init__(path, temp) self.writer.write(""" /* This part of the file was generated on {} from the @@ -447,9 +446,8 @@ class CalendarDataWriter (LocaleSourceEditor): months_data.write(self.writer) class LocaleHeaderWriter (SourceFileEditor): - __upinit = SourceFileEditor.__init__ def __init__(self, path, temp, dupes): - self.__upinit(path, temp) + super().__init__(path, temp) self.__dupes = dupes def languages(self, languages):