summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <javier.jardon@codethink.co.uk>2015-02-27 15:36:49 (GMT)
committerJavier Jardón <jjardon@gnome.org>2015-03-04 19:14:41 (GMT)
commit0ad137344b5712a7a42c54dc744f7367c56a3212 (patch)
treedf5473b2d7c59a66876a64ea85ed68841935c937
parent8221465890030d95fd7d32e9de2353d8801daf54 (diff)
downloadmorph-0ad137344b5712a7a42c54dc744f7367c56a3212.tar.gz
morphlib/sourceresolver.py: Add _get_file_contents_from_definitions()
And make _get_morphology_from_definitions() use it
-rw-r--r--morphlib/sourceresolver.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py
index 6347861..dd02080 100644
--- a/morphlib/sourceresolver.py
+++ b/morphlib/sourceresolver.py
@@ -212,10 +212,19 @@ class SourceResolver(object):
return absref, tree
+ def _get_file_contents_from_definitions(self,
+ filename): # pragma: no cover
+ if os.path.exists(filename):
+ with open(filename) as f:
+ return f.read()
+ else:
+ return None
+
def _get_morphology_from_definitions(self, loader,
filename): # pragma: no cover
if os.path.exists(filename):
- return loader.load_from_file(filename)
+ text = self._get_file_contents_from_definitions(filename)
+ return self.load_from_string(text, filename=filename)
else:
return None