/
FONTLOG.py
63 lines (48 loc) · 1.36 KB
/
FONTLOG.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
The FONTLOG is SIL’s concept of a chancelog for a font. When doing a release,
we generate one automatically based on AUTHORS.txt, README.txt and the
repository history.
An example of a FONTLOG:
http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=OFL-FAQ_web#11bc4f28
(pretty url’s wouldn’t hurt the SIL)
We use a line-width of 82 because I manually wrapped my commit messages to 78,
and git indents them with 4 spaces. These lines stay like they are, and
unwrapped commit messages get wrapped to the same width.
"""
from textwrap import fill, TextWrapper
from subprocess import Popen, PIPE
import sys
# Get the data
try:
README = open('README.txt')
except IOError:
README = open('../README.txt')
try:
AUTHORS = open('AUTHORS.txt')
except IOError:
AUTHORS = open('../AUTHORS.txt')
LOG = Popen(['git','log','--reverse'], stdout=PIPE)
# Setup TextWrap instances
wrapper = TextWrapper(width=82)
commit_msg_wrapper = TextWrapper(subsequent_indent=' ', width=82)
# Print FONTLOG to stdout
for line in README:
print wrapper.fill(line)
print ""
print "____"
print ""
print "Designers:"
print ""
print AUTHORS.read()
print ""
print "____"
print ""
print "Changelog:"
print ""
for line in LOG.stdout:
if len(line) > 82:
print commit_msg_wrapper.fill(line)
else:
print line,