summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <javier.jardon@codethink.co.uk>2015-02-27 15:23:09 (GMT)
committerJavier Jardón <jjardon@gnome.org>2015-03-04 19:14:41 (GMT)
commit8221465890030d95fd7d32e9de2353d8801daf54 (patch)
treed0cc89db80a8cb44765b73e0fec120671520d3c8
parent774d708f969553a7f571b734c21642c19605385a (diff)
downloadmorph-8221465890030d95fd7d32e9de2353d8801daf54.tar.gz
morphlib/sourceresolver.py: Add _get_file_contents_from_repo()
And make _get_morphology_from_repo() use it
-rw-r--r--morphlib/sourceresolver.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py
index 22e643d..6347861 100644
--- a/morphlib/sourceresolver.py
+++ b/morphlib/sourceresolver.py
@@ -219,7 +219,8 @@ class SourceResolver(object):
else:
return None
- def _get_morphology_from_repo(self, loader, reponame, sha1, filename):
+ def _get_file_contents_from_repo(self, reponame,
+ sha1, filename): # pragma: no cover
if self.lrc.has_repo(reponame):
self.status(msg="Looking for %(reponame)s:%(filename)s in the "
"local repo cache.",
@@ -227,21 +228,26 @@ class SourceResolver(object):
try:
repo = self.lrc.get_repo(reponame)
text = repo.read_file(filename, sha1)
- morph = loader.load_from_string(text)
except IOError:
- morph = None
+ text = None
elif self.rrc is not None:
self.status(msg="Looking for %(reponame)s:%(filename)s in the "
"remote repo cache.",
reponame=reponame, filename=filename, chatty=True)
try:
text = self.rrc.cat_file(reponame, sha1, filename)
- morph = loader.load_from_string(text)
except morphlib.remoterepocache.CatFileError:
- morph = None
+ text = None
else: # pragma: no cover
repo = self.cache_repo_locally(reponame)
text = repo.read_file(filename, sha1)
+
+ return text
+
+ def _get_morphology_from_repo(self, loader, reponame, sha1, filename):
+ text = self._get_file_contents_from_repo(self, reponame, sha1, filename)
+
+ if file not None:
morph = loader.load_from_string(text)
return morph