summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2015-06-01 14:44:35 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2015-06-01 15:32:46 +0000
commit6da4761f784292ee4723c14b4cdd46677847e1b8 (patch)
treea5db8e9c387e35b580cf58e9b824617ebb79d690
parent56c7db5201f548aff7950e778ca0e106709623ae (diff)
downloadmorph-6da4761f784292ee4723c14b4cdd46677847e1b8.tar.gz
Stop assuming that the extensions are in the root of definitions
-rw-r--r--morphlib/extensions.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/morphlib/extensions.py b/morphlib/extensions.py
index aa0622b8..cc390c50 100644
--- a/morphlib/extensions.py
+++ b/morphlib/extensions.py
@@ -60,9 +60,19 @@ def _list_morph_extension_filenames(kind):
def _get_extension_name(filename):
return os.path.basename(filename)
+def _get_repo_extension_relpath(name, kind):
+ repo_dir = _get_root_repo()
+ files = repo_dir.list_files()
+ matching = [f for f in files if os.path.splitext(f)[1] == kind and
+ os.path.basename(os.path.splitext(f)[0]) == name]
+ if matching:
+ return matching[0]
+ return name + kind
+
def _get_repo_extension_contents(name, kind):
repo_dir = _get_root_repo()
- return repo_dir.read_file(name + kind)
+ filepath = _get_repo_extension_relpath(name, kind)
+ return repo_dir.read_file(filepath)
def _get_morph_extension_filename(name, kind):
return os.path.join(_get_morph_extension_directory(), name + kind)