Skip to content

Commit 7b52f52

Browse files
committedJul 3, 2015
Fix #1859 -- remove gap between linenos and code
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent d015f82 commit 7b52f52

File tree

3 files changed

+58
-39
lines changed

3 files changed

+58
-39
lines changed
 

Diff for: ‎.pypt/ghrel

+55-35
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
33
# Kw’s Release Tools/Python Project Template
4-
# GitHub Releases Creator
4+
# GitHub Release Creator
55
# Copyright © 2013-2015, Chris Warrick.
66
# All rights reserved.
77
#
@@ -33,58 +33,78 @@
3333
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3434
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535

36-
# Arguments:
37-
# FILE BASEDIR REPO TAG
38-
3936
"""
4037
Create GitHub releases out of changelogs.
4138
42-
Usage: .pypt/commitlog FILE BASEDIR REPO TAG, where
39+
Usage: .pypt/commitlog FILE BASEDIR REPOSITORY TAG, where
4340
FILE is the path to the file to use, which can be
4441
a plain .md file or a CMFN file,
4542
BASEDIR is the project directory,
46-
REPO is the full GitHub repository name (user/repo),
43+
REPOSITORY is the full GitHub repository name (user/repo),
4744
TAG is the tag to write to.
4845
All paths should be absolute.
4946
"""
5047

48+
import argparse
49+
import json
5150
import re
5251
import requests
53-
import json
52+
import sys
5453
from os.path import join as pjoin
55-
from sys import argv
5654

57-
_script, FILE, BASEDIR, REPO, TAG = argv
5855

59-
with open(pjoin(BASEDIR, '.pypt', 'gh-token')) as fh:
60-
TOKEN = fh.read().strip()
56+
def main():
57+
"""ghrel main function."""
58+
parser = argparse.ArgumentParser(
59+
description="GitHub Release Creator "
60+
"(part of Chris Warrick's Python Project Template)")
61+
parser.add_argument('filename', metavar='FILE', nargs=1,
62+
help='File to parse (Markdown or commitlog)')
63+
parser.add_argument('basedir', metavar='BASEDIR', nargs=1,
64+
help='Project directory (must contain .pypt/gh-token)')
65+
parser.add_argument('repo', metavar='REPOSITORY', nargs=1,
66+
help='GitHub repository (owner/repo)')
67+
parser.add_argument('tag', metavar='TAG', nargs=1,
68+
help='Tag to create release for (vX.Y.Z)')
69+
args = parser.parse_args()
70+
# nargs gets you lists, not strings
71+
filename = args.filename[0]
72+
basedir = args.basedir[0]
73+
repo = args.repo[0]
74+
tag = args.tag[0]
6175

62-
HEADERS = {
63-
'User-Agent': 'Kwpolska/python-project-template',
64-
'Authorization': 'token ' + TOKEN,
65-
}
76+
with open(pjoin(basedir, '.pypt', 'gh-token')) as fh:
77+
token = fh.read().strip()
6678

67-
with open(FILE) as fh:
68-
fdata = fh.read()
69-
e = re.findall(
70-
'#~ CHANGELOG MESSAGE START ~#\n(.*?)\n#~ CHANGELOG MESSAGE END ~#',
71-
fdata, flags=re.S)
79+
headers = {
80+
'User-Agent': 'Kwpolska/python-project-template',
81+
'Authorization': 'token ' + token,
82+
}
7283

73-
if e:
74-
# parse as a CMFN file, replace backticks (reST->Markdown)
75-
message = e[0].replace('``', '`')
76-
else:
77-
# parse as a plain Markdown file
78-
message = fdata
84+
with open(filename) as fh:
85+
fdata = fh.read()
86+
e = re.findall(
87+
'#~ CHANGELOG MESSAGE START ~#\n(.*?)\n'
88+
'#~ CHANGELOG MESSAGE END ~#',
89+
fdata, flags=re.S)
90+
91+
if e:
92+
# parse as a CMFN file, replace backticks (reST -> Markdown)
93+
message = e[0].replace('``', '`')
94+
else:
95+
# parse as a plain Markdown file
96+
message = fdata
7997

98+
r = requests.post(
99+
'https://api.github.com/repos/{0}/releases'.format(repo),
100+
data=json.dumps({'tag_name': tag, 'body': message}),
101+
headers=headers)
80102

81-
r = requests.post(
82-
'https://api.github.com/repos/{0}/releases'.format(REPO),
83-
data=json.dumps({'tag_name': TAG, 'body': message}),
84-
headers=HEADERS)
103+
if r.status_code == 201:
104+
print("GitHub Release created: {0}".format(r.json()['html_url']))
105+
else:
106+
print("GitHub Release failed: {0}".format(r.text))
107+
return 1
85108

86-
if r.status_code == 201:
87-
print("GitHub Release created: {0}".format(r.json()['html_url']))
88-
else:
89-
print("GitHub Release failed: {0}".format(r.text))
90-
exit(1)
109+
if __name__ == '__main__':
110+
sys.exit(main())

Diff for: ‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Features
77
Bugfixes
88
--------
99

10+
* Remove gap between line numbers and code (Issue #1859)
1011
* Fix spurious warnings about posts published in the future (Issue #1850)
1112

1213
New in v7.6.0

Diff for: ‎nikola/data/themes/base/assets/css/rst.css

+2-4
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,16 @@ pre.address {
248248
margin-top: 0 ;
249249
font: inherit }
250250

251-
pre.literal-block, pre.doctest-block, pre.math, pre.code {
252-
margin-left: 2em ;
253-
margin-right: 2em }
254-
255251
pre.code .ln { color: grey; } /* line numbers */
252+
/*
256253
pre.code, code { background-color: #eeeeee; }
257254
pre.code .comment, code .comment { color: #5C6576 }
258255
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
259256
pre.code .literal.string, code .literal.string { color: #0C5404 }
260257
pre.code .name.builtin, code .name.builtin { color: #352B84 }
261258
pre.code .deleted, code .deleted { background-color: #DEB0A1}
262259
pre.code .inserted, code .inserted { background-color: #A3D289}
260+
*/
263261

264262
span.classifier {
265263
font-family: sans-serif ;

0 commit comments

Comments
 (0)
Please sign in to comment.