pip/tools/automation/generate.py

48 lines
1.3 KiB
Python
Raw Normal View History

2014-02-26 01:38:24 +01:00
import io
import invoke
@invoke.task
2016-11-06 23:34:10 +01:00
def authors(ctx):
2014-02-26 01:38:24 +01:00
print("[generate.authors] Generating AUTHORS")
# Get our list of authors
print("[generate.authors] Collecting author names")
# Note that it's necessary to use double quotes in the
# --format"=%aN <%aE>" part of the command, as the Windows
# shell doesn't recognise single quotes here.
2018-03-31 20:30:59 +02:00
r = ctx.run('git log --use-mailmap --format"=%aN <%aE>"',
encoding="utf-8", hide=True)
2014-02-26 01:38:24 +01:00
authors = []
seen_authors = set()
for author in r.stdout.splitlines():
author = author.strip()
if author.lower() not in seen_authors:
seen_authors.add(author.lower())
authors.append(author)
# Sort our list of Authors by their case insensitive name
authors = sorted(authors, key=lambda x: x.lower())
# Write our authors to the AUTHORS file
print("[generate.authors] Writing AUTHORS")
with io.open("AUTHORS.txt", "w", encoding="utf8") as fp:
fp.write(u"\n".join(authors))
fp.write(u"\n")
2017-03-19 01:50:01 +01:00
@invoke.task
def news(ctx, draft=False, yes=False):
2017-03-19 01:50:01 +01:00
print("[generate.news] Generating NEWS")
args = []
if draft:
args.append("--draft")
if yes:
args.append("--yes")
2017-03-19 01:50:01 +01:00
ctx.run("towncrier {}".format(" ".join(args)))