Skip to content

Commit

Permalink
v1.3.3: remove yesterday’s new options
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 3, 2015
1 parent 713d288 commit 875a258
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 93 deletions.
5 changes: 3 additions & 2 deletions .pypt/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Python Project Template. INSERT TAGLINE HERE.™
:Author: Chris Warrick <chris@chriswarrick.com>
:Copyright: © 2013-2015, Chris Warrick.
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
:Date: 2015-06-30
:Version: 1.2.1
:Date: 2015-07-03
:Version: 1.3.0

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

Expand Down
105 changes: 72 additions & 33 deletions .pypt/commitlog
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Arguments:
# FILE BASEDIR NEWVERSION

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


import argparse
import re
import sys
from os.path import join as pjoin
from sys import argv
from textwrap import indent

_script, FILE, BASEDIR, NEWVERSION = argv

with open(FILE) as fh:
e = re.findall('#~ C(.*?) MESSAGE START ~#\n(.*?)\n#~ C(.*?) MESSAGE '
'END ~#', fh.read(), flags=re.S)

for i in e:
i = list(i)
if i[0] != i[2]:
print('ERROR: mismatched tags')
exit(1)
else:
i[0] = 'C' + i[0] # regexp hack
if i[0] == 'COMMIT':
with open(FILE + '-commit', 'w') as fh:
fh.write(i[1])
elif i[0] == 'CHANGELOG':
with open(pjoin(BASEDIR, 'docs', 'CHANGELOG.rst')) as fh:
currentfile = fh.read()

# A bit fragile...
currentver = re.search(':Version: (.*)', currentfile).groups()[0]
clog = indent(i[1], 4 * ' ')

with open(pjoin(BASEDIR, 'docs', 'CHANGELOG.rst'), 'w') as fh:
fh.write(currentfile.replace(
'\n' + currentver,
'\n{0}\n{1}\n\n{2}'.format(NEWVERSION, clog, currentver)))


# Stolen from textwrap in Python 3.4.3 with PEP257 fixes
def indent(text, prefix, predicate=None):
"""Add 'prefix' to the beginning of selected lines in 'text'.
If 'predicate' is provided, 'prefix' will only be added to the lines
where 'predicate(line)' is True. If 'predicate' is not provided,
it will default to adding 'prefix' to all non-empty lines that do not
consist solely of whitespace characters.
"""
if predicate is None:
def predicate(line):
return line.strip()

def prefixed_lines():
for line in text.splitlines(True):
yield (prefix + line if predicate(line) else line)
return ''.join(prefixed_lines())


def main():
"""commitlog main function."""
parser = argparse.ArgumentParser(
description="Commit and Changelog Parser "
"(part of Chris Warrick's Python Project Template)")
parser.add_argument('filename', metavar='FILE', nargs=1,
help='File to parse')
parser.add_argument('basedir', metavar='BASEDIR', nargs=1,
help='Project directory')
parser.add_argument('new_version', metavar='NEWVERSION', nargs=1,
help='New version (vX.Y.Z)')
args = parser.parse_args()
# nargs gets you lists, not strings
filename = args.filename[0]
basedir = args.basedir[0]
new_version = args.new_version[0]

with open(filename) as fh:
e = re.findall('#~ C(.*?) MESSAGE START ~#\n(.*?)\n#~ C(.*?) MESSAGE '
'END ~#', fh.read(), flags=re.S)

for i in e:
i = list(i)
if i[0] != i[2]:
print('ERROR: mismatched tags')
return 1
else:
i[0] = 'C' + i[0] # regexp hack
if i[0] == 'COMMIT':
with open(filename + '-commit', 'w') as fh:
fh.write(i[1])
elif i[0] == 'CHANGELOG':
with open(pjoin(basedir, 'docs', 'CHANGELOG.rst')) as fh:
currentfile = fh.read()

# A bit fragile...
currentver = re.search(':Version: (.*)',
currentfile).groups()[0]
clog = indent(i[1], 4 * ' ')

with open(pjoin(basedir, 'docs', 'CHANGELOG.rst'), 'w') as fh:
fh.write(currentfile.replace(
'\n' + currentver,
'\n{0}\n{1}\n\n{2}'.format(
new_version, clog, currentver)))


if __name__ == '__main__':
sys.exit(main())
90 changes: 55 additions & 35 deletions .pypt/ghrel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Kw’s Release Tools/Python Project Template
# GitHub Releases Creator
# GitHub Release Creator
# Copyright © 2013-2015, Chris Warrick.
# All rights reserved.
#
Expand Down Expand Up @@ -33,58 +33,78 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Arguments:
# FILE BASEDIR REPO TAG

"""
Create GitHub releases out of changelogs.
Usage: .pypt/commitlog FILE BASEDIR REPO TAG, where
Usage: .pypt/commitlog FILE BASEDIR REPOSITORY TAG, where
FILE is the path to the file to use, which can be
a plain .md file or a CMFN file,
BASEDIR is the project directory,
REPO is the full GitHub repository name (user/repo),
REPOSITORY is the full GitHub repository name (user/repo),
TAG is the tag to write to.
All paths should be absolute.
"""

import argparse
import json
import re
import requests
import json
import sys
from os.path import join as pjoin
from sys import argv

_script, FILE, BASEDIR, REPO, TAG = argv

with open(pjoin(BASEDIR, '.pypt', 'gh-token')) as fh:
TOKEN = fh.read().strip()
def main():
"""ghrel main function."""
parser = argparse.ArgumentParser(
description="GitHub Release Creator "
"(part of Chris Warrick's Python Project Template)")
parser.add_argument('filename', metavar='FILE', nargs=1,
help='File to parse (Markdown or commitlog)')
parser.add_argument('basedir', metavar='BASEDIR', nargs=1,
help='Project directory (must contain .pypt/gh-token)')
parser.add_argument('repo', metavar='REPOSITORY', nargs=1,
help='GitHub repository (owner/repo)')
parser.add_argument('tag', metavar='TAG', nargs=1,
help='Tag to create release for (vX.Y.Z)')
args = parser.parse_args()
# nargs gets you lists, not strings
filename = args.filename[0]
basedir = args.basedir[0]
repo = args.repo[0]
tag = args.tag[0]

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

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

if e:
# parse as a CMFN file, replace backticks (reST->Markdown)
message = e[0].replace('``', '`')
else:
# parse as a plain Markdown file
message = fdata
with open(filename) as fh:
fdata = fh.read()
e = re.findall(
'#~ CHANGELOG MESSAGE START ~#\n(.*?)\n'
'#~ CHANGELOG MESSAGE END ~#',
fdata, flags=re.S)

if e:
# parse as a CMFN file, replace backticks (reST -> Markdown)
message = e[0].replace('``', '`')
else:
# parse as a plain Markdown file
message = fdata

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

r = requests.post(
'https://api.github.com/repos/{0}/releases'.format(REPO),
data=json.dumps({'tag_name': TAG, 'body': message}),
headers=HEADERS)
if r.status_code == 201:
print("GitHub Release created: {0}".format(r.json()['html_url']))
else:
print("GitHub Release failed: {0}".format(r.text))
return 1

if r.status_code == 201:
print("GitHub Release created: {0}".format(r.json()['html_url']))
else:
print("GitHub Release failed: {0}".format(r.text))
exit(1)
if __name__ == '__main__':
sys.exit(main())
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
Appendix A. Changelog
=====================

:Version: 1.3.2
:Version: 1.3.3

1.3.3
Remove yesterday’s new options. Please do not use v1.3.2.

1.3.2
* Added two options that should not be used, EVER. Please ignore them.
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Appendix A. Contribution rules
:Author: Chris Warrick <chris@chriswarrick.com>
:Copyright: © 2015, Chris Warrick.
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
:Date: 2015-07-02
:Version: 1.3.2
:Date: 2015-07-03
:Version: 1.3.3

.. index:: contributing

Expand Down
2 changes: 1 addition & 1 deletion coil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@

__all__ = ['__version__']

__version__ = '1.3.2'
__version__ = '1.3.3'
10 changes: 2 additions & 8 deletions coil/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
--version Show version.
-b, --browser Open Coil CMS in the browser after starting.
-p <port>, --port=<port> Port to use [default: 8001].
--no-url-fix Don't fix the URL in devserver. DO NOT USE.
--no-debug Don't run devserver in debug mode.
"""

from __future__ import unicode_literals
Expand Down Expand Up @@ -83,12 +81,8 @@ def devserver(arguments):
if coil.web.app:
port = int(arguments['--port'])
url = 'http://localhost:{0}/'.format(port)
nourl = arguments['--no-url-fix']
nodebug = arguments['--no-debug']
if not nourl:
coil.web.configure_url(url)
if not nodebug:
coil.web.app.config['DEBUG'] = True
coil.web.configure_url(url)
coil.web.app.config['DEBUG'] = True

if arguments['--browser']:
webbrowser.open(url)
Expand Down
5 changes: 4 additions & 1 deletion docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
Appendix A. Changelog
=====================

:Version: 1.3.2
:Version: 1.3.3

1.3.3
Remove yesterday’s new options. Please do not use v1.3.2.

1.3.2
* Added two options that should not be used, EVER. Please ignore them.
Expand Down
4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Appendix A. Contribution rules
:Author: Chris Warrick <chris@chriswarrick.com>
:Copyright: © 2015, Chris Warrick.
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
:Date: 2015-07-02
:Version: 1.3.2
:Date: 2015-07-03
:Version: 1.3.3

.. index:: contributing

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
version = '1.3.2'
version = '1.3.3'
# The full version, including alpha/beta/rc tags.
release = '1.3.2'
release = '1.3.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
10 changes: 5 additions & 5 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ if [[ $? = 1 ]]; then
exit 1
fi

status 'Running tests...'
if [[ -e tests ]]; then
./setup.py test
status 'Running tests...'
py.test tests/
if [[ $? = 1 ]]; then
error "Tests failed. Fix your code or don't come back."
exit 1
fi
fi
fi

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

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

status 'Updating AUR PKGBUILDs...'
[[ -e PKGBUILD ]] && md5out=$(md5sum 'dist/'$PROJECTLC'-'$version'.tar.gz'|awk '{print $1}')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
dependencies = [l.strip() for l in fh]

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

0 comments on commit 875a258

Please sign in to comment.