summaryrefslogtreecommitdiff
path: root/obnam
diff options
context:
space:
mode:
authorLars Wirzenius <liw@gytha>2008-04-26 20:26:22 +0300
committerLars Wirzenius <liw@gytha>2008-04-26 20:26:22 +0300
commit0f95063acf9f23ae70e89e209828922af9820365 (patch)
tree5420668f140bd2eabf7fe11476526eac29f4308b /obnam
parentf70289eadb0d95f90ee2373ed80d63620d199cf4 (diff)
downloadobnam-0f95063acf9f23ae70e89e209828922af9820365.tar.gz
Changed Application.find_file_by_name to return file component, not tuple of its parts.
Diffstat (limited to 'obnam')
-rw-r--r--obnam/app.py11
-rw-r--r--obnam/appTests.py13
2 files changed, 14 insertions, 10 deletions
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()