Did some more string format conversions.

Wed, 28 Jul 2010 15:23:22 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 28 Jul 2010 15:23:22 +0200
changeset 426
161992758137
parent 425
ca5e65413fc5
child 427
6af5d12cfecb

Did some more string format conversions.

Preferences/ConfigurationDialog.py file | annotate | diff | comparison | revisions
Preferences/ProgramsDialog.py file | annotate | diff | comparison | revisions
Preferences/ShortcutsDialog.py file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
--- a/Preferences/ConfigurationDialog.py	Wed Jul 28 15:12:20 2010 +0200
+++ b/Preferences/ConfigurationDialog.py	Wed Jul 28 15:23:22 2010 +0200
@@ -413,7 +413,7 @@
         @param name name of the configuration page module (string)
         @return reference to the configuration page module
         """
-        modName = "Preferences.ConfigurationPages.%s" % name
+        modName = "Preferences.ConfigurationPages.{0}".format(name)
         try:
             mod = __import__(modName)
             components = modName.split('.')
--- a/Preferences/ProgramsDialog.py	Wed Jul 28 15:12:20 2010 +0200
+++ b/Preferences/ProgramsDialog.py	Wed Jul 28 15:23:22 2010 +0200
@@ -78,23 +78,23 @@
         # 1. do the Qt4 programs
         # 1a. Translation Converter
         exe = Utilities.isWindowsPlatform() and \
-            "%s.exe" % Utilities.generateQtToolName("lrelease") or \
+            "{0}.exe".format(Utilities.generateQtToolName("lrelease")) or \
             Utilities.generateQtToolName("lrelease")
         version = self.__createProgramEntry(self.trUtf8("Translation Converter (Qt4)"), 
                     exe, '-version', 'lrelease', -1)
         # 1b. Qt4 Designer
         exe = Utilities.isWindowsPlatform() and \
-            "%s.exe" % Utilities.generateQtToolName("designer") or \
+            "{0}.exe".format(Utilities.generateQtToolName("designer")) or \
             Utilities.generateQtToolName("designer")
         self.__createProgramEntry(self.trUtf8("Qt4 Designer"), exe, version = version)
         # 1c. Qt4 Linguist
         exe = Utilities.isWindowsPlatform() and \
-            "%s.exe" % Utilities.generateQtToolName("linguist") or \
+            "{0}.exe".format(Utilities.generateQtToolName("linguist")) or \
             Utilities.generateQtToolName("linguist")
         self.__createProgramEntry(self.trUtf8("Qt4 Linguist"), exe, version = version)
         # 1d. Qt4 Assistant
         exe = Utilities.isWindowsPlatform() and \
-            "%s.exe" % Utilities.generateQtToolName("assistant") or \
+            "{0}.exe".format(Utilities.generateQtToolName("assistant")) or \
             Utilities.generateQtToolName("assistant")
         self.__createProgramEntry(self.trUtf8("Qt4 Assistant"), exe, version = version)
         
@@ -246,7 +246,7 @@
                                     Preferences.getSystem("IOEncoding"), 
                                     'replace')
                         if versionRe is None:
-                            versionRe = "^%s" % re.escape(versionStartsWith)
+                            versionRe = "^{0}".format(re.escape(versionStartsWith))
                         versionRe = re.compile(versionRe, re.UNICODE)
                         for line in output.splitlines():
                             if versionRe.search(line):
--- a/Preferences/ShortcutsDialog.py	Wed Jul 28 15:12:20 2010 +0200
+++ b/Preferences/ShortcutsDialog.py	Wed Jul 28 15:23:22 2010 +0200
@@ -310,7 +310,7 @@
                             continue
                         
                         # step 2: check if shortcut hides an already allocated
-                        if itmseq.startswith("%s+" % keystr):
+                        if itmseq.startswith("{0}+".format(keystr)):
                             res = QMessageBox.warning(None,
                                 self.trUtf8("Edit shortcuts"),
                                 self.trUtf8(\
@@ -328,7 +328,7 @@
                                 return False
                         
                         # step 3: check if shortcut is hidden by an already allocated
-                        if keystr.startswith("%s+" % itmseq):
+                        if keystr.startswith("{0}+".format(itmseq)):
                             res = QMessageBox.warning(None,
                                 self.trUtf8("Edit shortcuts"),
                                 self.trUtf8(\
@@ -458,4 +458,4 @@
         @param checked state of the shortcuts radio button (boolean)
         """
         if checked:
-            self.on_searchEdit_textChanged(self.searchEdit.text())
\ No newline at end of file
+            self.on_searchEdit_textChanged(self.searchEdit.text())
--- a/Preferences/__init__.py	Wed Jul 28 15:12:20 2010 +0200
+++ b/Preferences/__init__.py	Wed Jul 28 15:23:22 2010 +0200
@@ -757,20 +757,21 @@
     groups = int(prefClass.settings.value("Toolgroups/Groups", 0))
     for groupIndex in range(groups):
         groupName = \
-            prefClass.settings.value("Toolgroups/%02d/Name" % groupIndex)
+            prefClass.settings.value("Toolgroups/{0:02d}/Name".format(groupIndex))
         group = [groupName, []]
-        items = int(prefClass.settings.value("Toolgroups/%02d/Items" % groupIndex, 0))
+        items = int(prefClass.settings.value(
+            "Toolgroups/{0:02d}/Items".format(groupIndex), 0))
         for ind in range(items):
             menutext = prefClass.settings.value(\
-                "Toolgroups/%02d/%02d/Menutext" % (groupIndex, ind))
+                "Toolgroups/{0:02d}/{1:02d}/Menutext".format(groupIndex, ind))
             icon = prefClass.settings.value(\
-                "Toolgroups/%02d/%02d/Icon" % (groupIndex, ind))
+                "Toolgroups/{0:02d}/{1:02d}/Icon".format(groupIndex, ind))
             executable = prefClass.settings.value(\
-                "Toolgroups/%02d/%02d/Executable" % (groupIndex, ind))
+                "Toolgroups/{0:02d}/{1:02d}/Executable".format(groupIndex, ind))
             arguments = prefClass.settings.value(\
-                "Toolgroups/%02d/%02d/Arguments" % (groupIndex, ind))
+                "Toolgroups/{0:02d}/{1:02d}/Arguments".format(groupIndex, ind))
             redirect = prefClass.settings.value(\
-                "Toolgroups/%02d/%02d/Redirect" % (groupIndex, ind))
+                "Toolgroups/{0:02d}/{1:02d}/Redirect".format(groupIndex, ind))
             
             if menutext:
                 if menutext == '--':
@@ -810,20 +811,27 @@
     prefClass.settings.setValue("Toolgroups/Groups", len(toolGroups))
     groupIndex = 0
     for group in toolGroups:
-        prefClass.settings.setValue("Toolgroups/%02d/Name" % groupIndex, group[0])
-        prefClass.settings.setValue("Toolgroups/%02d/Items" % groupIndex, len(group[1]))
+        prefClass.settings.setValue(
+            "Toolgroups/{0:02d}/Name".format(groupIndex), group[0])
+        prefClass.settings.setValue(
+            "Toolgroups/{0:02d}/Items".format(groupIndex), len(group[1]))
         ind = 0
         for tool in group[1]:
             prefClass.settings.setValue(\
-                "Toolgroups/%02d/%02d/Menutext" % (groupIndex, ind), tool['menutext'])
+                "Toolgroups/{0:02d}/{1:02d}/Menutext".format(groupIndex, ind), 
+                tool['menutext'])
             prefClass.settings.setValue(\
-                "Toolgroups/%02d/%02d/Icon" % (groupIndex, ind), tool['icon'])
+                "Toolgroups/{0:02d}/{1:02d}/Icon".format(groupIndex, ind), 
+                tool['icon'])
             prefClass.settings.setValue(\
-                "Toolgroups/%02d/%02d/Executable" % (groupIndex, ind), tool['executable'])
+                "Toolgroups/{0:02d}/{1:02d}/Executable".format(groupIndex, ind), 
+                tool['executable'])
             prefClass.settings.setValue(\
-                "Toolgroups/%02d/%02d/Arguments" % (groupIndex, ind), tool['arguments'])
+                "Toolgroups/{0:02d}/{1:02d}/Arguments".format(groupIndex, ind), 
+                tool['arguments'])
             prefClass.settings.setValue(\
-                "Toolgroups/%02d/%02d/Redirect" % (groupIndex, ind), tool['redirect'])
+                "Toolgroups/{0:02d}/{1:02d}/Redirect".format(groupIndex, ind), 
+                tool['redirect'])
             ind += 1
         groupIndex += 1
     prefClass.settings.setValue("Toolgroups/Current Group", currentGroup)
@@ -985,7 +993,7 @@
             if ext.startswith("."):
                 exts.append(ext)
             else:
-                exts.append(".%s" % ext)
+                exts.append(".{0}".format(ext))
         return exts
 
 def setPython(key, value, prefClass = Prefs):

eric ide

mercurial