-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate_readme.py
34 lines (29 loc) · 1.23 KB
/
update_readme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
import yaml
import pathlib
header_md = """
### A collection of bioinformatics tools for use with [Galaxy](https://galaxyproject.org/) written at Quadram Institute
[![Build Status](https://travis-ci.com/quadram-institute-bioscience/galaxy-tools.svg?branch=master)](https://travis-ci.com/quadram-institute-bioscience/galaxy-tools)
"""
def update(path="tools"):
print(path)
shed_files = pathlib.Path(path).glob("*/.shed.yml")
_holder = []
with open("README.md", "w") as fh:
fh.write(header_md)
for shed_file in shed_files:
_shed_content = yaml.load(open(shed_file,'r'))
_holder.append(
{
"name": _shed_content["name"],
"description": _shed_content["description"],
"homepage_url": _shed_content["homepage_url"]
}
)
_sorted_holder = sorted(_holder, key = lambda i: i['name'])
fh.write("\n#### Total: {} tools\n".format(len(_holder)))
for item in _sorted_holder:
_str_line = "- **[{0}]({1})** {2}\n".format(item["name"], item["homepage_url"], item["description"])
fh.write(_str_line)
if __name__ == "__main__":
update()