Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a script for comparing planemo list_repos output with a toolset #100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions scripts/check_for_new_repos.py
Original file line number Diff line number Diff line change
@@ -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}/*.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:
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)