Skip to content

Commit

Permalink
Merge pull request #185 from peterjc/source_list
Browse files Browse the repository at this point in the history
Allow include source to be a list of filenames/patterns.
  • Loading branch information
jmchilton committed May 6, 2015
2 parents c870d2a + da7803f commit 7ac2e70
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions planemo/shed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,22 @@ def _realized_files(self, name):
config = self._realize_config(name)
realized_files = []
missing = []
for include in config["include"]:
included = RealizedFile.realized_files_for(self.path, include)
if not included:
missing.append(include)
else:
realized_files.extend(included)
for include_info in config["include"]:
if not isinstance(include_info, dict):
include_info = {"source": include_info}
source_list = include_info.get("source")
if not isinstance(source_list, list):
source_list = [source_list]
# Preprocess any entries with a source list into copies
# with a single source entry:
for source in source_list:
include = include_info.copy()
include["source"] = source
included = RealizedFile.realized_files_for(self.path, include)
if not included:
missing.append(include)
else:
realized_files.extend(included)
return RealizedFiles(realized_files, missing)

def _realize_config(self, name):
Expand Down Expand Up @@ -872,6 +882,10 @@ def realize_to(self, directory):
if os.path.islink(source_path):
source_path = os.path.realpath(source_path)
relative_dest = self.relative_dest
if relative_dest == ".":
# The target folder likely exists,
# but would still want to make symlink...
relative_dest = os.path.split(source_path)[1]
target_path = os.path.join(directory, relative_dest)
target_exists = os.path.exists(target_path)
if not target_exists:
Expand Down

0 comments on commit 7ac2e70

Please sign in to comment.