From c08c3570ff7243ea95bbbdd7caad389836f1765f Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 17 Jan 2020 16:03:04 +0100 Subject: [PATCH 1/2] Add a script for comparing planemo list_repos output with a toolset planemo list_repos is a new command added in https://github.com/galaxyproject/planemo/pull/982 --- scripts/check_for_new_repos.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 scripts/check_for_new_repos.py diff --git a/scripts/check_for_new_repos.py b/scripts/check_for_new_repos.py new file mode 100644 index 00000000..be266e2d --- /dev/null +++ b/scripts/check_for_new_repos.py @@ -0,0 +1,34 @@ +import argparse +import glob +import os +from collections import defaultdict + +import yaml + + +ROOT_DIR = os.path.join(os.path.dirname(__file__), os.pardir) +IGNORE_REPOS = ('package_', 'suite_') + + +def list_repos_to_install(infile, toolset, outfile): + toolset_dir = os.path.join(ROOT_DIR, toolset) + repos = defaultdict(set) + for subset in glob.glob("{toolset_dir}/*.yml".format(toolset_dir=toolset_dir)): + with open(subset) as s: + loaded_repos = yaml.safe_load(s.read())['tools'] + for repo in loaded_repos: + repos[repo['owner']].add(repo['name']) + with open(infile) as i: + new_repos = yaml.safe_load(i.read()) + new_repos = [r for r in new_repos if not r['name'] in repos.get(r['owner'], {}) and not r['name'].startswith(IGNORE_REPOS)] + with open(outfile, 'w') as out: + out.write(yaml.safe_dump(new_repos)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Takes a yaml file produced by planemo list_repos and lists new repos in toolset") + parser.add_argument("-i", "--infile", help="A list of potentially new repos to compare with list of usegalaxy.* repos") + parser.add_argument("-t", "--toolset", help="Tool collection to compare input with") + parser.add_argument("-o", "--outfile", help="Write new tools to this file") + args = parser.parse_args() + list_repos_to_install(args.infile, args.toolset, args.outfile) From b7845412d1857adba18fa3885c3bfc5089faf594 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 17 Jan 2020 16:18:33 +0100 Subject: [PATCH 2/2] Allow yaml and yml in glob --- scripts/check_for_new_repos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_for_new_repos.py b/scripts/check_for_new_repos.py index be266e2d..dccd1df3 100644 --- a/scripts/check_for_new_repos.py +++ b/scripts/check_for_new_repos.py @@ -13,7 +13,7 @@ def list_repos_to_install(infile, toolset, outfile): toolset_dir = os.path.join(ROOT_DIR, toolset) repos = defaultdict(set) - for subset in glob.glob("{toolset_dir}/*.yml".format(toolset_dir=toolset_dir)): + for subset in glob.glob("{toolset_dir}/*.y*ml".format(toolset_dir=toolset_dir)): with open(subset) as s: loaded_repos = yaml.safe_load(s.read())['tools'] for repo in loaded_repos: