From 0f95063acf9f23ae70e89e209828922af9820365 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 26 Apr 2008 20:26:22 +0300 Subject: Changed Application.find_file_by_name to return file component, not tuple of its parts. --- obnam/app.py | 11 +++-------- obnam/appTests.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'obnam') diff --git a/obnam/app.py b/obnam/app.py index 0d517462..60838202 100644 --- a/obnam/app.py +++ b/obnam/app.py @@ -192,20 +192,15 @@ class Application: def find_file_by_name(self, filename): """Find a backed up file given its filename. - Return tuple (STAT, CONTREF, SIGREF, DELTAREF), where the - references may be None, or None instead of the entire tuple - if no file with the given name could be found. + Return FILE component, or None if no file with the given name + could be found. """ if self._filelist: fc = self._filelist.find(filename) if fc != None: - stat = fc.first_by_kind(obnam.cmp.STAT) - cont = fc.first_string_by_kind(obnam.cmp.CONTREF) - sig = fc.first_string_by_kind(obnam.cmp.SIGREF) - d = fc.first_string_by_kind(obnam.cmp.DELTAREF) - return obnam.cmp.parse_stat_component(stat), cont, sig, d + return fc return None diff --git a/obnam/appTests.py b/obnam/appTests.py index 7a52b362..ecac4ca6 100644 --- a/obnam/appTests.py +++ b/obnam/appTests.py @@ -551,8 +551,17 @@ class ApplicationFindFileByNameTests(unittest.TestCase): filelist = obnam.filelist.Filelist() filelist.add_file_component("pink", fc) self.app.set_prevgen_filelist(filelist) - self.failUnlessEqual(self.app.find_file_by_name("pink"), - (stat, "contref", "sigref", "deltaref")) + file = self.app.find_file_by_name("pink") + self.failUnlessEqual( + obnam.cmp.parse_stat_component( + file.first_by_kind(obnam.cmp.STAT)), + stat) + self.failUnlessEqual(file.first_string_by_kind(obnam.cmp.CONTREF), + "contref") + self.failUnlessEqual(file.first_string_by_kind(obnam.cmp.SIGREF), + "sigref") + self.failUnlessEqual(file.first_string_by_kind(obnam.cmp.DELTAREF), + "deltaref") def testFindsNoFileInfoInFilelistForNonexistingFile(self): filelist = obnam.filelist.Filelist() -- cgit v1.2.1