Skip to content

Commit 875a258

Browse files
committed
v1.3.3: remove yesterday’s new options
Signed-off-by: Chris Warrick <[email protected]>
1 parent 713d288 commit 875a258

12 files changed

+153
-93
lines changed

.pypt/README.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Python Project Template. INSERT TAGLINE HERE.™
55
:Author: Chris Warrick <[email protected]>
66
:Copyright: © 2013-2015, Chris Warrick.
77
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
8-
:Date: 2015-06-30
9-
:Version: 1.2.1
8+
:Date: 2015-07-03
9+
:Version: 1.3.0
1010

1111
.. index: README
1212
.. image:: https://travis-ci.org/Kwpolska/python-project-template.png?branch=master
@@ -61,6 +61,7 @@ The template contains the following files to get you started:
6161
* copying over ``/docs/README.rst``, ``/docs/CHANGELOG.rst`` and ``/docs/CONTRIBUTING.rst`` to ``/``
6262
* locale generation (via the ``.pypt/localegen`` script)
6363
* running ``import $project`` and the testsuite
64+
* uploading a source distribution and a wheel to PyPI
6465
* committing into git, finishing the ``git flow`` release
6566
* creating a GitHub Releases entry
6667

.pypt/commitlog

+72-33
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
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 NEWVERSION
3836

3937
"""
4038
Parse commits and changelogs for PyPT.
@@ -47,36 +45,77 @@ Usage: .pypt/commitlog FILE BASEDIR NEWVERSION, where
4745
"""
4846

4947

48+
import argparse
5049
import re
50+
import sys
5151
from os.path import join as pjoin
52-
from sys import argv
53-
from textwrap import indent
54-
55-
_script, FILE, BASEDIR, NEWVERSION = argv
56-
57-
with open(FILE) as fh:
58-
e = re.findall('#~ C(.*?) MESSAGE START ~#\n(.*?)\n#~ C(.*?) MESSAGE '
59-
'END ~#', fh.read(), flags=re.S)
60-
61-
for i in e:
62-
i = list(i)
63-
if i[0] != i[2]:
64-
print('ERROR: mismatched tags')
65-
exit(1)
66-
else:
67-
i[0] = 'C' + i[0] # regexp hack
68-
if i[0] == 'COMMIT':
69-
with open(FILE + '-commit', 'w') as fh:
70-
fh.write(i[1])
71-
elif i[0] == 'CHANGELOG':
72-
with open(pjoin(BASEDIR, 'docs', 'CHANGELOG.rst')) as fh:
73-
currentfile = fh.read()
74-
75-
# A bit fragile...
76-
currentver = re.search(':Version: (.*)', currentfile).groups()[0]
77-
clog = indent(i[1], 4 * ' ')
78-
79-
with open(pjoin(BASEDIR, 'docs', 'CHANGELOG.rst'), 'w') as fh:
80-
fh.write(currentfile.replace(
81-
'\n' + currentver,
82-
'\n{0}\n{1}\n\n{2}'.format(NEWVERSION, clog, currentver)))
52+
53+
54+
# Stolen from textwrap in Python 3.4.3 with PEP257 fixes
55+
def indent(text, prefix, predicate=None):
56+
"""Add 'prefix' to the beginning of selected lines in 'text'.
57+
58+
If 'predicate' is provided, 'prefix' will only be added to the lines
59+
where 'predicate(line)' is True. If 'predicate' is not provided,
60+
it will default to adding 'prefix' to all non-empty lines that do not
61+
consist solely of whitespace characters.
62+
"""
63+
if predicate is None:
64+
def predicate(line):
65+
return line.strip()
66+
67+
def prefixed_lines():
68+
for line in text.splitlines(True):
69+
yield (prefix + line if predicate(line) else line)
70+
return ''.join(prefixed_lines())
71+
72+
73+
def main():
74+
"""commitlog main function."""
75+
parser = argparse.ArgumentParser(
76+
description="Commit and Changelog Parser "
77+
"(part of Chris Warrick's Python Project Template)")
78+
parser.add_argument('filename', metavar='FILE', nargs=1,
79+
help='File to parse')
80+
parser.add_argument('basedir', metavar='BASEDIR', nargs=1,
81+
help='Project directory')
82+
parser.add_argument('new_version', metavar='NEWVERSION', nargs=1,
83+
help='New version (vX.Y.Z)')
84+
args = parser.parse_args()
85+
# nargs gets you lists, not strings
86+
filename = args.filename[0]
87+
basedir = args.basedir[0]
88+
new_version = args.new_version[0]
89+
90+
with open(filename) as fh:
91+
e = re.findall('#~ C(.*?) MESSAGE START ~#\n(.*?)\n#~ C(.*?) MESSAGE '
92+
'END ~#', fh.read(), flags=re.S)
93+
94+
for i in e:
95+
i = list(i)
96+
if i[0] != i[2]:
97+
print('ERROR: mismatched tags')
98+
return 1
99+
else:
100+
i[0] = 'C' + i[0] # regexp hack
101+
if i[0] == 'COMMIT':
102+
with open(filename + '-commit', 'w') as fh:
103+
fh.write(i[1])
104+
elif i[0] == 'CHANGELOG':
105+
with open(pjoin(basedir, 'docs', 'CHANGELOG.rst')) as fh:
106+
currentfile = fh.read()
107+
108+
# A bit fragile...
109+
currentver = re.search(':Version: (.*)',
110+
currentfile).groups()[0]
111+
clog = indent(i[1], 4 * ' ')
112+
113+
with open(pjoin(basedir, 'docs', 'CHANGELOG.rst'), 'w') as fh:
114+
fh.write(currentfile.replace(
115+
'\n' + currentver,
116+
'\n{0}\n{1}\n\n{2}'.format(
117+
new_version, clog, currentver)))
118+
119+
120+
if __name__ == '__main__':
121+
sys.exit(main())

.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())

CHANGELOG.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
Appendix A. Changelog
33
=====================
44

5-
:Version: 1.3.2
5+
:Version: 1.3.3
6+
7+
1.3.3
8+
Remove yesterday’s new options. Please do not use v1.3.2.
69

710
1.3.2
811
* Added two options that should not be used, EVER. Please ignore them.

CONTRIBUTING.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Appendix A. Contribution rules
55
:Author: Chris Warrick <[email protected]>
66
:Copyright: © 2015, Chris Warrick.
77
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
8-
:Date: 2015-07-02
9-
:Version: 1.3.2
8+
:Date: 2015-07-03
9+
:Version: 1.3.3
1010

1111
.. index:: contributing
1212

coil/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929

3030
__all__ = ['__version__']
3131

32-
__version__ = '1.3.2'
32+
__version__ = '1.3.3'

coil/__main__.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
--version Show version.
4040
-b, --browser Open Coil CMS in the browser after starting.
4141
-p <port>, --port=<port> Port to use [default: 8001].
42-
--no-url-fix Don't fix the URL in devserver. DO NOT USE.
43-
--no-debug Don't run devserver in debug mode.
4442
"""
4543

4644
from __future__ import unicode_literals
@@ -83,12 +81,8 @@ def devserver(arguments):
8381
if coil.web.app:
8482
port = int(arguments['--port'])
8583
url = 'http://localhost:{0}/'.format(port)
86-
nourl = arguments['--no-url-fix']
87-
nodebug = arguments['--no-debug']
88-
if not nourl:
89-
coil.web.configure_url(url)
90-
if not nodebug:
91-
coil.web.app.config['DEBUG'] = True
84+
coil.web.configure_url(url)
85+
coil.web.app.config['DEBUG'] = True
9286

9387
if arguments['--browser']:
9488
webbrowser.open(url)

docs/CHANGELOG.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
Appendix A. Changelog
33
=====================
44

5-
:Version: 1.3.2
5+
:Version: 1.3.3
6+
7+
1.3.3
8+
Remove yesterday’s new options. Please do not use v1.3.2.
69

710
1.3.2
811
* Added two options that should not be used, EVER. Please ignore them.

docs/CONTRIBUTING.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Appendix A. Contribution rules
55
:Author: Chris Warrick <[email protected]>
66
:Copyright: © 2015, Chris Warrick.
77
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
8-
:Date: 2015-07-02
9-
:Version: 1.3.2
8+
:Date: 2015-07-03
9+
:Version: 1.3.3
1010

1111
.. index:: contributing
1212

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = '1.3.2'
58+
version = '1.3.3'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '1.3.2'
60+
release = '1.3.3'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.

release

+5-5
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ if [[ $? = 1 ]]; then
168168
exit 1
169169
fi
170170

171-
status 'Running tests...'
172171
if [[ -e tests ]]; then
173-
./setup.py test
172+
status 'Running tests...'
173+
py.test tests/
174174
if [[ $? = 1 ]]; then
175175
error "Tests failed. Fix your code or don't come back."
176176
exit 1
177-
fi
177+
fi
178178
fi
179179

180180
status 'Running pre-sdist.hook...'
@@ -184,8 +184,8 @@ status 'Running pre-sdist.hook...'
184184
status 'This is the last chance to quit. Hit ^C now if you want to.'
185185
read bailout
186186

187-
./setup.py sdist
188-
twine upload -s dist/$PROJECTLC-$version.tar.gz
187+
./setup.py sdist bdist_wheel
188+
twine upload -s dist/$PROJECTLC-$version.tar.gz dist/$PROJECTLC-$version*.whl
189189

190190
status 'Updating AUR PKGBUILDs...'
191191
[[ -e PKGBUILD ]] && md5out=$(md5sum 'dist/'$PROJECTLC'-'$version'.tar.gz'|awk '{print $1}')

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
dependencies = [l.strip() for l in fh]
88

99
setup(name='coil',
10-
version='1.3.2',
10+
version='1.3.3',
1111
description='A user-friendly CMS frontend for Nikola.',
1212
keywords='coil,nikola,cms',
1313
author='Chris Warrick, Roberto Alsina, Henry Hirsch et al.',

0 commit comments

Comments
 (0)