2017-02-27 23:59:32 +00:00
|
|
|
from yaml import load
|
|
|
|
|
2017-04-20 22:21:42 +00:00
|
|
|
summary = """
|
|
|
|
# Summary
|
2017-02-27 23:59:32 +00:00
|
|
|
|
2017-06-21 00:09:16 +00:00
|
|
|
To date, **{}** apps/tools covered, divided in **{}** categories; **8** related sites reviewed and listed.
|
2017-04-20 22:21:42 +00:00
|
|
|
|
|
|
|
# Index
|
|
|
|
|
|
|
|
{}
|
|
|
|
Some links to [related resources](#resources).
|
|
|
|
|
|
|
|
I'm always interested to new tools, so if you have any suggestion please drop me an email at `toolleeo@gmail.com`.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def fmt_app(app):
|
|
|
|
descr = ''.join(c if c != '\n' else ' ' for c in app["description"])
|
|
|
|
return("#### [{}]({})\n\n{}\n".format(app["name"], app["url"], descr))
|
|
|
|
|
|
|
|
|
|
|
|
def print_apps(cats, apps):
|
|
|
|
for cat_item in cats:
|
|
|
|
category = cat_item["label"]
|
|
|
|
print('## <a name="{}"></a>{}\n'.format(category, cat_item["name"]))
|
|
|
|
for app in apps[category]:
|
|
|
|
print(fmt_app(app))
|
|
|
|
|
|
|
|
|
|
|
|
def fmt_cats(cats):
|
2017-07-09 22:10:28 +00:00
|
|
|
newlist = sorted(cats, key=lambda k: k['name'])
|
2017-04-20 22:21:42 +00:00
|
|
|
st = []
|
2017-07-09 22:10:28 +00:00
|
|
|
for cat_item in newlist:
|
2017-04-20 22:21:42 +00:00
|
|
|
category = cat_item["label"]
|
2017-07-09 22:10:28 +00:00
|
|
|
st.append("[{}](#{})".format(cat_item["name"], cat_item["label"]))
|
|
|
|
return ' | '.join(st)
|
2017-02-27 23:59:32 +00:00
|
|
|
|
|
|
|
|
2017-03-27 20:10:11 +00:00
|
|
|
def count_apps(apps):
|
|
|
|
tot = 0
|
|
|
|
for cat in apps:
|
|
|
|
tot += len(apps[cat])
|
|
|
|
return tot
|
|
|
|
|
2017-04-20 22:21:42 +00:00
|
|
|
|
2017-02-27 23:59:32 +00:00
|
|
|
with open('cli-apps.yaml', 'r') as yf:
|
|
|
|
data = load(yf)
|
|
|
|
# print(data)
|
|
|
|
apps = data["apps"]
|
2017-04-20 22:21:42 +00:00
|
|
|
cats = data["categories"]
|
|
|
|
print(summary.format(count_apps(apps), len(cats), fmt_cats(cats)))
|
|
|
|
print_apps(cats, apps)
|