From 024eb8680066bd58bc4efd4dc0a525f7653c7775 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Mon, 6 Aug 2012 18:04:54 +0400 Subject: [PATCH] Don't use string.format(), but use interpolation Python 2.5 has no string.format() and interpolation ('%') suits all current needs. MacOS still has python 2.5 sometimes, so I see no point in using format() in all places I had patched. Signed-off-by: Eygene Ryabinkin --- offlineimap/folder/Base.py | 4 ++-- offlineimap/folder/UIDMaps.py | 4 ++-- offlineimap/ui/UIBase.py | 10 +++++----- test/OLItest/TestRunner.py | 8 ++++---- test/tests/test_01_basic.py | 24 ++++++++++++------------ test/tests/test_02_MappedIMAP.py | 4 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index 6f6f364..6ddb710 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -386,8 +386,8 @@ class BaseFolder(object): self.getmessageuidlist()) num_to_copy = len(copylist) if num_to_copy and self.repository.account.dryrun: - self.ui.info("[DRYRUN] Copy {} messages from {}[{}] to {}".format( - num_to_copy, self, self.repository, dstfolder.repository)) + self.ui.info("[DRYRUN] Copy %d messages from %s[%s] to %s" % \ + (num_to_copy, self, self.repository, dstfolder.repository)) return for num, uid in enumerate(copylist): # bail out on CTRL-C or SIGTERM diff --git a/offlineimap/folder/UIDMaps.py b/offlineimap/folder/UIDMaps.py index f1c11e4..0eadfc3 100644 --- a/offlineimap/folder/UIDMaps.py +++ b/offlineimap/folder/UIDMaps.py @@ -85,9 +85,9 @@ class MappedIMAPFolder(IMAPFolder): try: return [mapping[x] for x in items] except KeyError as e: - raise OfflineImapError("Could not find UID for msg '{0}' (f:'{1}'." + raise OfflineImapError("Could not find UID for msg '%s' (f:'%s'." " This is usually a bad thing and should be reported on the ma" - "iling list.".format(e.args[0], self), + "iling list." % (e.args[0], self), OfflineImapError.ERROR.MESSAGE) def cachemessagelist(self): diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index eea929d..5bc4b54 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -301,8 +301,8 @@ class UIBase(object): def makefolder(self, repo, foldername): """Called when a folder is created""" prefix = "[DRYRUN] " if self.dryrun else "" - self.info("{}Creating folder {}[{}]".format( - prefix, foldername, repo)) + self.info("%sCreating folder %s[%s]" % \ + (prefix, foldername, repo)) def syncingfolder(self, srcrepos, srcfolder, destrepos, destfolder): """Called when a folder sync operation is started.""" @@ -346,8 +346,8 @@ class UIBase(object): def deletingmessages(self, uidlist, destlist): ds = self.folderlist(destlist) prefix = "[DRYRUN] " if self.dryrun else "" - self.info("{}Deleting {} messages ({}) in {}".format( - prefix, len(uidlist), + self.info("%sDeleting %d messages (%s) in %s" % \ + (prefix, len(uidlist), offlineimap.imaputil.uid_sequence(uidlist), ds)) def addingflags(self, uidlist, flags, dest): @@ -474,7 +474,7 @@ class UIBase(object): def callhook(self, msg): if self.dryrun: - self.info("[DRYRUN] {}".format(msg)) + self.info("[DRYRUN] " + msg) else: self.info(msg) diff --git a/test/OLItest/TestRunner.py b/test/OLItest/TestRunner.py index 3535b61..1a5117f 100644 --- a/test/OLItest/TestRunner.py +++ b/test/OLItest/TestRunner.py @@ -127,7 +127,7 @@ class OLITestLib(): reponame: All on `reponame` or all IMAP-type repositories if None""" config = cls.get_default_config() if reponame: - sections = ['Repository {}'.format(reponame)] + sections = ['Repository ' + reponame] else: sections = [r for r in config.sections() \ if r.startswith('Repository')] @@ -162,8 +162,8 @@ class OLITestLib(): dirs = [d for d in dirs if d.startswith(b'INBOX.OLItest')] for folder in dirs: res_t, data = imapobj.delete(b'\"'+folder+b'\"') - assert res_t == 'OK', "Folder deletion of {} failed with error"\ - ":\n{} {}".format(folder.decode('utf-8'), res_t, data) + assert res_t == 'OK', "Folder deletion of %s failed with error"\ + ":\n%s %s" % (folder.decode('utf-8'), res_t, data) imapobj.logout() @classmethod @@ -197,7 +197,7 @@ class OLITestLib(): Use some default content if not given""" assert cls.testdir != None while True: # Loop till we found a unique filename - mailfile = '{}:2,'.format(random.randint(0,999999999)) + mailfile = '%s:2,' % (random.randint(0,999999999)) mailfilepath = os.path.join(cls.testdir, 'mail', folder, 'new', mailfile) if not os.path.isfile(mailfilepath): diff --git a/test/tests/test_01_basic.py b/test/tests/test_01_basic.py index 8e45a62..d44fbf5 100644 --- a/test/tests/test_01_basic.py +++ b/test/tests/test_01_basic.py @@ -67,8 +67,8 @@ class TestBasicFunctions(unittest.TestCase): self.assertEqual(res, "") boxes, mails = OLITestLib.count_maildir_mails('') self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0 " - "mails, but sync led to {} folders and {} mails".format( - boxes, mails)) + "mails, but sync led to %d folders and %d mails" % \ + (boxes, mails)) def test_02_createdir(self): """Create local OLItest 1 & OLItest "1" maildir, sync @@ -82,8 +82,8 @@ class TestBasicFunctions(unittest.TestCase): self.assertEqual(res, "") boxes, mails = OLITestLib.count_maildir_mails('') self.assertTrue((boxes, mails)==(2,0), msg="Expected 2 folders and 0 " - "mails, but sync led to {} folders and {} mails".format( - boxes, mails)) + "mails, but sync led to %d folders and %d mails" % \ + (boxes, mails)) def test_03_nametransmismatch(self): """Create mismatching remote and local nametrans rules @@ -100,8 +100,8 @@ class TestBasicFunctions(unittest.TestCase): # We expect an INFINITE FOLDER CREATION WARNING HERE.... mismatch = "ERROR: INFINITE FOLDER CREATION DETECTED!" in res self.assertEqual(mismatch, True, msg="Mismatching nametrans rules did " - "NOT trigger an 'infinite folder generation' error. Output was:\n" - "{}".format(res)) + "NOT trigger an 'infinite folder generation' error. Output was:\n" + \ + res) # Write out default config file again OLITestLib.write_config_file() @@ -121,13 +121,13 @@ class TestBasicFunctions(unittest.TestCase): self.assertEqual(res, "") boxes, mails = OLITestLib.count_maildir_mails('') self.assertTrue((boxes, mails)==(1,1), msg="Expected 1 folders and 1 " - "mails, but sync led to {} folders and {} mails".format( - boxes, mails)) + "mails, but sync led to %d folders and %d mails" % \ + (boxes, mails)) # The local Mail should have been assigned a proper UID now, check! uids = OLITestLib.get_maildir_uids('INBOX.OLItest') self.assertFalse (None in uids, msg = "All mails should have been "+ \ - "assigned the IMAP's UID number, but {} messages had no valid ID "\ - .format(len([None for x in uids if x==None]))) + "assigned the IMAP's UID number, but %d messages had no valid ID " % \ + (len([None for x in uids if x==None]))) def test_05_createfolders(self): """Test if createfolders works as expected @@ -153,5 +153,5 @@ class TestBasicFunctions(unittest.TestCase): code, res = OLITestLib.run_OLI() boxes, mails = OLITestLib.count_maildir_mails('') self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0 " - "mails, but sync led to {} folders and {} mails".format( - boxes, mails)) + "mails, but sync led to %d folders and %d mails" % \ + (boxes, mails)) diff --git a/test/tests/test_02_MappedIMAP.py b/test/tests/test_02_MappedIMAP.py index 05aa394..e7095da 100644 --- a/test/tests/test_02_MappedIMAP.py +++ b/test/tests/test_02_MappedIMAP.py @@ -67,5 +67,5 @@ class TestBasicFunctions(unittest.TestCase): #self.assertEqual(res, "") #boxes, mails = OLITestLib.count_maildir_mails('') #self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0" - # "mails, but sync led to {} folders and {} mails".format( - # boxes, mails)) + # "mails, but sync led to %d folders and %d mails" % \ + # (boxes, mails)) -- 1.7.11.2