Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events
push:
pull_request:
schedule:
- cron: '0 12 * * 0' # run once a week on Sunday

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
tests:
name: "Python ${{ matrix.python-version }}"
runs-on: "ubuntu-latest"

strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "pypy3"]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade virtualenv tox tox-gh-actions
- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"

- name: "Report to coveralls"
# coverage is only created in the py39 environment
# --service=github is a workaround for bug
# https://github.com/coveralls-clients/coveralls-python/issues/251
if: "matrix.python-version == '3.9'"
run: |
pip install coveralls
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 11 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
repos:
- repo: https://github.com/psf/black
rev: stable
rev: 20.8b1
hooks:
- id: black
args: [--line-length=80]
- repo: https://gitlab.com/pycqa/flake8
rev: "3.8.4"
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
hooks:
- id: pyupgrade
args: [--py36-plus]
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ CHANGES

- Make Python 3.6 the default testing environment.

- Add support for Python 3.9.

- Use GitHub Actios for CI.


0.1 (2016-06-09)
================
Expand Down
17 changes: 16 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
.. image:: https://github.com/morepath/morepath_wiki/workflows/CI/badge.svg?branch=master
:target: https://github.com/morepath/morepath_wiki/actions?workflow=CI
:alt: CI Status

.. image:: https://coveralls.io/repos/github/morepath/morepath_wiki/badge.svg?branch=master
:target: https://coveralls.io/github/morepath/morepath_wiki?branch=master

.. image:: https://img.shields.io/pypi/v/morepath_wiki.svg
:target: https://pypi.org/project/morepath_wiki/

.. image:: https://img.shields.io/pypi/pyversions/morepath_wiki.svg
:target: https://pypi.org/project/morepath_wiki/



Morepath Wiki
=============

Expand Down Expand Up @@ -60,4 +75,4 @@ And to run the test suite::

.. _GitHub: https://github.com/morepath/morepath_wiki

.. _virtual environment: http://www.virtualenv.org/
.. _virtual environment: https://virtualenv.pypa.io/en/latest/
38 changes: 23 additions & 15 deletions morepath_wiki/html.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- encoding: utf8 -*-
#
# $Id: html.py 5409 2011-06-29 07:07:25Z rjones $
# $HeadURL: svn+ssh://svn/svn/trunk/api/eklib/html.py $
Expand Down Expand Up @@ -223,7 +222,6 @@
See the end of the source file for the license of use.
XHTML support was contributed by Michael Haubenwallner.
"""
from __future__ import with_statement

__version__ = "1.16"

Expand All @@ -232,7 +230,7 @@
import unittest


class HTML(object):
class HTML:
"""Easily generate HTML.

>>> print HTML('html', 'some text')
Expand All @@ -254,7 +252,9 @@ class HTML(object):

newline_default_on = set("table ol ul dl".split())

def __init__(self, name=None, text=None, stack=None, newlines=True, escape=True):
def __init__(
self, name=None, text=None, stack=None, newlines=True, escape=True
):
self._name = name
self._content = []
self._attrs = {}
Expand Down Expand Up @@ -311,10 +311,13 @@ def __call__(self, *content, **kw):
if self._name == "read":
if len(content) == 1 and isinstance(content[0], int):
raise TypeError(
"you appear to be calling read(%d) on " "a HTML instance" % content
"you appear to be calling read(%d) on "
"a HTML instance" % content
)
elif len(content) == 0:
raise TypeError("you appear to be calling read() on a " "HTML instance")
raise TypeError(
"you appear to be calling read() on a " "HTML instance"
)

# customising a tag with content or attributes
escape = kw.pop("escape", True)
Expand Down Expand Up @@ -343,7 +346,7 @@ def __exit__(self, exc_type, exc_value, exc_tb):
self._stack.pop()

def __repr__(self):
return "<HTML %s 0x%x>" % (self._name, id(self))
return "<HTML {} 0x{:x}>".format(self._name, id(self))

def _stringify(self, str_type):
# turn me and my content into text
Expand All @@ -352,7 +355,7 @@ def _stringify(self, str_type):
return join.join(map(str_type, self._content))
a = ['%s="%s"' % i for i in self._attrs.items()]
l = [self._name] + a
s = "<%s>%s" % (" ".join(l), join)
s = "<{}>{}".format(" ".join(l), join)
if self._content:
s += join.join(map(str_type, self._content))
s += join + "</%s>" % self._name
Expand Down Expand Up @@ -384,12 +387,12 @@ def _stringify(self, str_type):
return join.join(map(str_type, self._content))
a = ['%s="%s"' % i for i in self._attrs.items()]
l = [self._name] + a
s = "<%s>%s" % (" ".join(l), join)
s = "<{}>{}".format(" ".join(l), join)
if self._content or not (self._name.lower() in self.empty_elements):
s += join.join(map(str_type, self._content))
s += join + "</%s>" % self._name
else:
s = "<%s />%s" % (" ".join(l), join)
s = "<{} />{}".format(" ".join(l), join)
return s


Expand All @@ -409,12 +412,12 @@ def _stringify(self, str_type):
return join.join(map(str_type, self._content))
a = ['%s="%s"' % i for i in self._attrs.items()]
l = [self._name] + a
s = "<%s>%s" % (" ".join(l), join)
s = "<{}>{}".format(" ".join(l), join)
if self._content:
s += join.join(map(str_type, self._content))
s += join + "</%s>" % self._name
else:
s = "<%s />%s" % (" ".join(l), join)
s = "<{} />{}".format(" ".join(l), join)
return s


Expand Down Expand Up @@ -443,7 +446,8 @@ def test_iadd_tag(self):
h += XML("some-tag", "spam", newlines=False)
h += XML("text", "spam", newlines=False)
self.assertEquals(
str(h), "<xml>\n<some-tag>spam</some-tag>\n<text>spam</text>\n</xml>"
str(h),
"<xml>\n<some-tag>spam</some-tag>\n<text>spam</text>\n</xml>",
)

def test_iadd_text(self):
Expand Down Expand Up @@ -523,15 +527,19 @@ def test_subtag_direct(self):
l = h.ol
l.li("foo")
l.li.b("bar")
self.assertEquals(str(h), "<ol>\n<li>foo</li>\n<li><b>bar</b></li>\n</ol>")
self.assertEquals(
str(h), "<ol>\n<li>foo</li>\n<li><b>bar</b></li>\n</ol>"
)

def test_subtag_direct_context(self):
'generation of sub-tags directly on the parent tag in "with" context'
h = HTML()
with h.ol as l:
l.li("foo")
l.li.b("bar")
self.assertEquals(str(h), "<ol>\n<li>foo</li>\n<li><b>bar</b></li>\n</ol>")
self.assertEquals(
str(h), "<ol>\n<li>foo</li>\n<li><b>bar</b></li>\n</ol>"
)

def test_subtag_no_newlines(self):
"prevent generation of newlines against default"
Expand Down
4 changes: 2 additions & 2 deletions morepath_wiki/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Root(object):
class Root:
pass


class Page(object):
class Page:
def __init__(self, name):
self.name = name
2 changes: 1 addition & 1 deletion morepath_wiki/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def wikify(text):
return wikiname_re.sub(r'<a href="/\1">\1</a>', py_html.escape(text))


class Storage(object):
class Storage:
def __init__(self, directory):
self.directory = directory

Expand Down
16 changes: 0 additions & 16 deletions pyproject.toml

This file was deleted.

9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-

import io
from setuptools import setup, find_packages


Expand All @@ -12,9 +9,9 @@
"web micro-framework battle by Richard Jones"
),
long_description=(
io.open("README.rst", encoding="utf-8").read()
open("README.rst", encoding="utf-8").read()
+ "\n\n"
+ io.open("CHANGES.rst", encoding="utf-8").read()
+ open("CHANGES.rst", encoding="utf-8").read()
),
author="Morepath developers",
author_email="morepath@googlegroups.com",
Expand All @@ -30,7 +27,6 @@
],
extras_require=dict(
test=["pytest >= 2.9.0", "webtest", "pytest-remove-stale-bytecode"],
pep8=["flake8", "black"],
coverage=["pytest-cov"],
),
entry_points={
Expand All @@ -44,5 +40,6 @@
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
)
25 changes: 16 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[tox]
envlist = py36, py37, py38, pypy3, coverage, pep8
skipsdist = True
envlist = py36, py37, py38, py39, pypy3, coverage, pre-commit
skip_missing_interpreters = True

[testenv]
Expand All @@ -9,19 +8,27 @@ extras = test

commands = pytest {posargs}

[testenv:pep8]
basepython = python3.8
extras = pep8

commands = flake8 morepath_wiki setup.py
black --check morepath_wiki setup.py
[testenv:pre-commit]
deps = pre-commit
commands = pre-commit run --all-files

[testenv:coverage]
basepython = python3.8
basepython = python3
extras = test
coverage

commands = pytest --cov morepath_wiki --cov-fail-under=100 {posargs}

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39, pre-commit, mypy, coverage

[flake8]
max-line-length = 88
ignore =
E231 # clashes with black
W503
exclude = morepath_wiki/html.py