From f93e0c728513ebf54ed3a51ca92e61b4a74b026e Mon Sep 17 00:00:00 2001 From: peterjc Date: Wed, 6 May 2015 15:40:36 +0100 Subject: [PATCH] Allow include source to be a list of filenames/patterns. This allows nesting within the include setting of .shed.yml for example if you have a batch of files with the same strip_components setting. See GitHub issue #180. --- planemo/shed/__init__.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/planemo/shed/__init__.py b/planemo/shed/__init__.py index fbd13da8a..9b00e769c 100644 --- a/planemo/shed/__init__.py +++ b/planemo/shed/__init__.py @@ -802,12 +802,20 @@ 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"]: + 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): @@ -872,6 +880,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: