From 6daa915fe6b236c1a8b77aecc3c7c76c838b2f56 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Sat, 18 Jan 2020 18:00:01 +0100 Subject: modernize project * use poetry * add a Makefile * add github actions * nose -> pytest --- .editorconfig | 24 ++++++++++++++++++ .flake8 | 4 +++ .github/workflows/pythonapp.yml | 43 +++++++++++++++++++++++++++++++ .gitignore | 4 ++- .noserc | 5 ---- .travis.yml | 16 ++++-------- Makefile | 33 ++++++++++++++++++++++++ pyproject.toml | 56 +++++++++++++++++++++++++++++++++++++++++ pytest.ini | 53 ++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 10 files changed, 222 insertions(+), 18 deletions(-) create mode 100644 .editorconfig create mode 100644 .flake8 create mode 100644 .github/workflows/pythonapp.yml delete mode 100644 .noserc create mode 100644 Makefile create mode 100644 pyproject.toml create mode 100644 pytest.ini diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..40bd47a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,24 @@ +# see http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{html,css,js}] +insert_final_newline = false + +[*.py] +line_length = 119 + +[{Makefile,**.mk}] +indent_style = tab +insert_final_newline = false + +[*.{yml}] +indent_style = space +indent_size = 2 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..40e3b5f --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +exclude = .pytest_cache, python_creole.egg-info +ignore = E402 +max-line-length = 119 diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml new file mode 100644 index 0000000..d1c6fd7 --- /dev/null +++ b/.github/workflows/pythonapp.yml @@ -0,0 +1,43 @@ +name: build + +on: [push] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install package + run: make install + + - name: List installed packages + run: poetry run pip freeze + + - name: Run linters + run: make lint + + test: + needs: lint + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.6, 3.7, 3.8] + steps: + - uses: actions/checkout@v1 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install package + run: make install + + - name: Run unit tests + run: make test diff --git a/.gitignore b/.gitignore index a34c8d5..ff9e6c5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ /dist /build -.idea \ No newline at end of file +.idea +/poetry.lock +/.coverage diff --git a/.noserc b/.noserc deleted file mode 100644 index e5d8b6d..0000000 --- a/.noserc +++ /dev/null @@ -1,5 +0,0 @@ -[nosetests] -verbose=True -verbosity=2 -detailed-errors=1 -with-doctest=1 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 9a9db2a..1b38fc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,26 +3,20 @@ language: python python: - - "2.7" - - "3.5" - "3.6" - "3.7" - "3.8" - - "pypy" - "pypy3" install: - - pip install --upgrade pip - - pip install nose textile docutils pygments coveralls - - pip install . + - make install + - poetry run pip freeze script: - - coverage run ./setup.py nosetests + - make test + - make lint after_success: - coveralls # https://github.com/codecov/codecov-bash - - bash <(curl -s https://codecov.io/bash) - -notifications: - irc: "irc.freenode.org#pylucid" + - bash <(curl -s https://codecov.io/bas diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d16c2a9 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +.PHONY: help install lint fix test release + +VERSION := $$(poetry version | sed -n 's/contxt-sdk //p') + +help: ## List all commands + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z -]+:.*?## / {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +install: + pip install poetry + poetry install + +lint: ## Run code formatters and linter + poetry run isort --check-only --recursive creole + poetry run black --line-length=119 --check creole + poetry run flake8 creole + +fix: ## Fix code formatting + poetry run flynt --line_length=119 creole + poetry run isort --apply --recursive creole + poetry run black --line-length=119 creole + +test: ## Run unit tests + poetry run pytest + +release: ## Release new version [usage: v=rule] + # Update pyproject and changelog + poetry version $(v) + sed -i "" "s/\[Unreleased\]/\[$(VERSION)\] - $(shell date +%F)/" CHANGELOG.md + # Create commit and tag + git commit pyproject.toml CHANGELOG.md -m "Bump version to $(VERSION)" && git tag "v$(VERSION)" + git push && git push --tags + # Publish to pypi + poetry publish --build \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..fab8cc7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,56 @@ +[tool.poetry] +name = 'python-creole' +version = '1.4.0' +description = '' +license = 'GPL-3.0-or-later' +authors = ['Jens Diemer '] +homepage = 'https://github.com/jedie/python-creole/' +keywords=['creole', 'markup', 'creole2html', 'html2creole', 'rest2html', 'html2rest', 'html2textile'] +classifiers = [ + # http://pypi.python.org/pypi?%3Aaction=list_classifiers + 'Development Status :: 5 - Production/Stable', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Operating System :: OS Independent', + 'Topic :: Documentation', + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Text Processing :: Markup', + 'Topic :: Text Processing :: Markup :: HTML', + 'Topic :: Utilities', +] +packages = [ + { include = 'creole' }, +] +include = ['README.creole'] + +[tool.poetry.dependencies] +python = '^3.6' +docutils = "^0.16" + +[tool.poetry.dev-dependencies] +pytest = '^4.6' +pytest-cov = "^2.8.1" +isort = "^4.3.21" +black = "^19.10b0" +flake8 = "^3.7.9" +flynt = "^0.40.1" + +[tool.poetry.scripts] +creole2html = 'creole.cmdline:cli_creole2html' +html2creole = 'creole.cmdline:cli_html2creole' +html2rest = 'creole.cmdline:cli_html2rest' +html2textile = 'creole.cmdline:cli_html2textile' + +[build-system] +requires = ['poetry>=0.12'] +build-backend = 'poetry.masonry.api' + diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..3c40359 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,53 @@ +# +# http://doc.pytest.org/en/latest/customize.html#builtin-configuration-file-options +# https://pytest-django.readthedocs.io/en/latest/ + +[pytest] +testpaths = creole +addopts = + --verbose + + # coverage: + --cov=. + --cov-report term-missing + --no-cov-on-fail + + # Disabling warning capture + #-p no:warnings + + --showlocals + #--trace-config + --doctest-modules + + # Do not cut tracebacks (somethimes helpfull): + #--full-trace + + # exit after 5 failures: + --maxfail=5 + + # per-test capturing method: one of fd|sys|no: + #--capture=no + + # We used logging config in django, so: disable printing caught logs on failed tests. + --no-print-logs + + # run the last failures first: + --failed-first + + # re-run only failures: + #--last-failed + + # run all tests if no tests failed in the last run: + --last-failed-no-failures all + + # sort new tests first: + --new-first + +# coverage +# https://pytest-cov.readthedocs.io/en/latest/config.html +[run] +source = . +branch = True +parallel = True +omit = + */tests/*.py diff --git a/setup.py b/setup.py index 9aaf85e..fdf3d42 100755 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import os import sys -- cgit v1.2.1 From 6e3f14bca5b77f24c86fb7fc4e9eb912432a9cba Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Sat, 18 Jan 2020 18:04:50 +0100 Subject: add tox.ini from #35 https://github.com/jedie/python-creole/pull/35/ --- .gitignore | 2 ++ tox.ini | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index ff9e6c5..3d914c2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ .idea /poetry.lock /.coverage + +.tox diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ea3d002 --- /dev/null +++ b/tox.ini @@ -0,0 +1,19 @@ +[tox] +isolated_build = True +envlist = + py36, + py37, + py38 + +[testenv] +whitelist_externals = make +deps = + pytest + pytest-cov + poetry +commands = + make install + poetry run pip freeze + make test + make lint + -- cgit v1.2.1 From f5bc0d6b695403c5bd3905f85b34f28548513580 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Sat, 18 Jan 2020 19:18:20 +0100 Subject: Update Makefile and use autopep8 instead of black --- .flake8 | 2 +- .github/workflows/pythonapp.yml | 35 ++++++++-------------------- Makefile | 51 ++++++++++++++++++++++++++++++----------- pyproject.toml | 4 +++- setup.cfg | 10 -------- setup.py | 4 ---- tox.ini | 8 ++----- 7 files changed, 54 insertions(+), 60 deletions(-) diff --git a/.flake8 b/.flake8 index 40e3b5f..826c171 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] exclude = .pytest_cache, python_creole.egg-info -ignore = E402 +ignore = E115,E124,E128,E265,E301,E309,E501 max-line-length = 119 diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index d1c6fd7..2480f8a 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -1,9 +1,9 @@ -name: build +name: test on: [push] jobs: - lint: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -13,31 +13,16 @@ jobs: python-version: 3.7 - name: Install package - run: make install + run: | + make install-poetry + source $HOME/.poetry/env + make install - name: List installed packages run: poetry run pip freeze - - name: Run linters - run: make lint - - test: - needs: lint - runs-on: ${{ matrix.platform }} - strategy: - matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.6, 3.7, 3.8] - steps: - - uses: actions/checkout@v1 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: Install package - run: make install +# - name: Run linters +# run: make lint - - name: Run unit tests - run: make test + - name: Run pytest via tox + run: make tox diff --git a/Makefile b/Makefile index d16c2a9..a3988c3 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,47 @@ -.PHONY: help install lint fix test release - -VERSION := $$(poetry version | sed -n 's/contxt-sdk //p') +SHELL := /bin/bash +MAX_LINE_LENGTH := 119 +POETRY_VERSION := $(shell poetry --version 2>/dev/null) help: ## List all commands @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z -]+:.*?## / {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) -install: - pip install poetry +check-poetry: + @if [[ "${POETRY_VERSION}" == *"Poetry"* ]] ; \ + then \ + echo "Found version poetry v${POETRY_VERSION}, ok." ; \ + else \ + echo 'Please install poetry first, with e.g.:' ; \ + echo 'make install-poetry' ; \ + exit 1 ; \ + fi + +install-poetry: ## install or update poetry + @if [[ "${POETRY_VERSION}" == *"Poetry"* ]] ; \ + then \ + echo 'Update poetry v$(POETRY_VERSION)' ; \ + poetry self update ; \ + else \ + echo 'Install poetry' ; \ + curl -sSL "https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py" | python3 ; \ + fi + +install: check-poetry ## install python-creole via poetry poetry install lint: ## Run code formatters and linter - poetry run isort --check-only --recursive creole - poetry run black --line-length=119 --check creole +# poetry run isort --check-only --recursive creole +# poetry run black --line-length=119 --check creole poetry run flake8 creole -fix: ## Fix code formatting - poetry run flynt --line_length=119 creole - poetry run isort --apply --recursive creole - poetry run black --line-length=119 creole +fix-code-style: ## Fix code formatting +# poetry run flynt --line_length=119 creole +# poetry run isort --apply --recursive creole + poetry run autopep8 --ignore-local-config --max-line-length=${MAX_LINE_LENGTH} --aggressive --aggressive --in-place --recursive creole -test: ## Run unit tests +tox: check-poetry ## Run pytest via tox + poetry run tox + +pytest: check-poetry ## Run pytest poetry run pytest release: ## Release new version [usage: v=rule] @@ -30,4 +52,7 @@ release: ## Release new version [usage: v=rule] git commit pyproject.toml CHANGELOG.md -m "Bump version to $(VERSION)" && git tag "v$(VERSION)" git push && git push --tags # Publish to pypi - poetry publish --build \ No newline at end of file + poetry publish --build + + +.PHONY: help install lint fix test release \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index fab8cc7..9e781e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,12 +37,14 @@ python = '^3.6' docutils = "^0.16" [tool.poetry.dev-dependencies] +tox = "^3.14.3" +pygments = "^2.5.2" pytest = '^4.6' pytest-cov = "^2.8.1" isort = "^4.3.21" -black = "^19.10b0" flake8 = "^3.7.9" flynt = "^0.40.1" +autopep8 = "^1.4.4" [tool.poetry.scripts] creole2html = 'creole.cmdline:cli_creole2html' diff --git a/setup.cfg b/setup.cfg index b0a6182..56f4451 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,15 +1,5 @@ -[flake8] -ignore=E115,E124,E128,E265,E301,E309,E501 -max-line-length = 119 - [metadata] license-file = LICENSE [bdist_wheel] universal = 1 - -[nosetests] -verbose=True -verbosity=2 -detailed-errors=1 -with-doctest=1 \ No newline at end of file diff --git a/setup.py b/setup.py index fdf3d42..8ef235d 100755 --- a/setup.py +++ b/setup.py @@ -256,9 +256,6 @@ setup( "html2textile = creole.cmdline:cli_html2textile", ], }, - tests_require=[ - "nose", # https://pypi.python.org/pypi/nose - ], zip_safe=True, # http://packages.python.org/distribute/setuptools.html#setting-the-zip-safe-flag keywords="creole markup creole2html html2creole rest2html html2rest html2textile", classifiers=[ @@ -282,5 +279,4 @@ setup( "Topic :: Text Processing :: Markup :: HTML", "Topic :: Utilities", ], - test_suite="nose.collector", ) diff --git a/tox.ini b/tox.ini index ea3d002..479fc65 100644 --- a/tox.ini +++ b/tox.ini @@ -4,16 +4,12 @@ envlist = py36, py37, py38 +skip_missing_interpreters = True [testenv] whitelist_externals = make -deps = - pytest - pytest-cov - poetry commands = make install - poetry run pip freeze - make test + make pytest make lint -- cgit v1.2.1 From fffd319fa0841bc6d72e82f808b693e03443eff4 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Sat, 18 Jan 2020 19:32:48 +0100 Subject: remove __future__ imports --- creole/__init__.py | 12 ++++---- creole/cmdline.py | 10 +++---- creole/emitter/creol2html_emitter.py | 2 +- creole/emitter/html2creole_emitter.py | 2 +- creole/emitter/html2rest_emitter.py | 2 +- creole/emitter/html2textile_emitter.py | 2 +- creole/exceptions.py | 4 +-- creole/html_tools/deentity.py | 6 ++-- creole/html_tools/strip_html.py | 4 +-- creole/html_tools/text_tools.py | 4 +-- creole/parser/creol2html_parser.py | 2 +- creole/parser/creol2html_rules.py | 10 +++---- creole/parser/html_parser.py | 6 ++-- creole/parser/html_parser_config.py | 4 +-- creole/py3compat.py | 6 ++-- creole/rest_tools/clean_writer.py | 14 ++++----- creole/rest_tools/pypi_rest2html.py | 2 +- creole/setup_utils.py | 2 +- creole/shared/HTMLParsercompat.py | 12 ++++---- creole/shared/base_emitter.py | 2 +- creole/shared/document_tree.py | 4 +-- creole/shared/example_macros.py | 2 +- creole/shared/unknown_tags.py | 14 ++++----- creole/shared/utils.py | 2 +- creole/tests/test_cli.py | 2 +- creole/tests/test_creole2html.py | 2 +- creole/tests/test_cross_compare_all.py | 2 +- creole/tests/test_cross_compare_creole.py | 38 +++++++++++------------ creole/tests/test_cross_compare_rest.py | 2 +- creole/tests/test_cross_compare_textile.py | 2 +- creole/tests/test_html2creole.py | 18 +++++------ creole/tests/test_html2rest.py | 48 +++++++++++++++--------------- creole/tests/test_html2textile.py | 12 ++++---- creole/tests/test_macros.py | 12 ++++---- creole/tests/test_rest2html.py | 28 ++++++++--------- creole/tests/test_setup.py | 2 +- creole/tests/test_setup_utils.py | 2 +- creole/tests/test_subprocess.py | 2 +- creole/tests/test_utils.py | 2 +- creole/tests/utils/base_unittest.py | 4 +-- creole/tests/utils/unittest_subprocess.py | 2 -- creole/tests/utils/utils.py | 2 +- 42 files changed, 155 insertions(+), 157 deletions(-) diff --git a/creole/__init__.py b/creole/__init__.py index 6594f9d..f720b9f 100644 --- a/creole/__init__.py +++ b/creole/__init__.py @@ -7,10 +7,10 @@ :homepage: http://code.google.com/p/python-creole/ - + :sourcecode: http://github.com/jedie/python-creole - + :PyPi: http://pypi.python.org/pypi/python-creole/ @@ -18,7 +18,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import warnings @@ -49,7 +49,7 @@ def creole2html(markup_string, debug=False, >>> creole2html('This is **creole //markup//**!') '

This is creole markup!

' - + Info: parser_kwargs and emitter_kwargs are deprecated """ assert isinstance(markup_string, TEXT_TYPE), "given markup_string must be unicode!" @@ -130,7 +130,7 @@ def html2textile(html_string, debug=False, ): """ convert html code into textile markup - + >>> html2textile('

This is textile markup!

') 'This is *textile __markup__*!' """ @@ -157,7 +157,7 @@ def html2rest(html_string, debug=False, ): """ convert html code into ReStructuredText markup - + >>> html2rest('

This is ReStructuredText markup!

') 'This is **ReStructuredText** *markup*!' """ diff --git a/creole/cmdline.py b/creole/cmdline.py index 82a156e..78f4eb4 100644 --- a/creole/cmdline.py +++ b/creole/cmdline.py @@ -9,7 +9,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import argparse import codecs @@ -36,7 +36,7 @@ class CreoleCLI(object): default="utf-8", help="Codec for read/write file (default encoding: utf-8)" ) - + args = self.parser.parse_args() sourcefile = args.sourcefile @@ -49,7 +49,7 @@ class CreoleCLI(object): print("Convert %r to %r with %s (codec: %s)" % ( sourcefile, destination, self.convert_func.__name__, encoding )) - + with codecs.open(sourcefile, "r", encoding=encoding) as infile: with codecs.open(destination, "w", encoding=encoding) as outfile: content = infile.read() @@ -63,10 +63,10 @@ def cli_creole2html(): def cli_html2creole(): CreoleCLI(html2creole) - + def cli_html2rest(): CreoleCLI(html2rest) - + def cli_html2textile(): CreoleCLI(html2textile) diff --git a/creole/emitter/creol2html_emitter.py b/creole/emitter/creol2html_emitter.py index 2879f4e..d1c6508 100644 --- a/creole/emitter/creol2html_emitter.py +++ b/creole/emitter/creol2html_emitter.py @@ -9,7 +9,7 @@ """ -from __future__ import division, absolute_import, print_function, unicode_literals + import json from xml.sax.saxutils import escape diff --git a/creole/emitter/html2creole_emitter.py b/creole/emitter/html2creole_emitter.py index 2e9c31c..00fd142 100644 --- a/creole/emitter/html2creole_emitter.py +++ b/creole/emitter/html2creole_emitter.py @@ -10,7 +10,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import posixpath from creole.shared.base_emitter import BaseEmitter diff --git a/creole/emitter/html2rest_emitter.py b/creole/emitter/html2rest_emitter.py index 7a32872..41891fe 100644 --- a/creole/emitter/html2rest_emitter.py +++ b/creole/emitter/html2rest_emitter.py @@ -13,7 +13,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import posixpath from creole.shared.base_emitter import BaseEmitter diff --git a/creole/emitter/html2textile_emitter.py b/creole/emitter/html2textile_emitter.py index 2263c12..e43b0df 100644 --- a/creole/emitter/html2textile_emitter.py +++ b/creole/emitter/html2textile_emitter.py @@ -10,7 +10,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import posixpath from creole.shared.base_emitter import BaseEmitter diff --git a/creole/exceptions.py b/creole/exceptions.py index 44cddff..91f9042 100644 --- a/creole/exceptions.py +++ b/creole/exceptions.py @@ -4,12 +4,12 @@ """ python-creole exceptions ~~~~~~~~~~~~~~~~~~~~~~~~ - + :copyleft: 2011 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + class DocutilsImportError(ImportError): pass diff --git a/creole/html_tools/deentity.py b/creole/html_tools/deentity.py index 7a6ff1a..2f6104a 100644 --- a/creole/html_tools/deentity.py +++ b/creole/html_tools/deentity.py @@ -3,14 +3,14 @@ """ python-creole utils - ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ :copyleft: 2008-2011 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import re try: @@ -39,7 +39,7 @@ class Deentity(object): >>> d = Deentity() >>> d.replace_all("-=[ >>>nice<<< ]=-") '-=[ >>>nice<<< ]=-' - + >>> d.replace_all("-=[Mühlheim]=-") # uuml - latin small letter u with diaeresis '-=[M\\xfchlheim]=-' diff --git a/creole/html_tools/strip_html.py b/creole/html_tools/strip_html.py index 20b6788..10534ad 100644 --- a/creole/html_tools/strip_html.py +++ b/creole/html_tools/strip_html.py @@ -4,14 +4,14 @@ """ python-creole utils - ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ :copyleft: 2008-2011 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import re diff --git a/creole/html_tools/text_tools.py b/creole/html_tools/text_tools.py index 28be3c9..5843cf6 100644 --- a/creole/html_tools/text_tools.py +++ b/creole/html_tools/text_tools.py @@ -4,14 +4,14 @@ """ python-creole utils - ~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ :copyleft: 2008-2011 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import re diff --git a/creole/parser/creol2html_parser.py b/creole/parser/creol2html_parser.py index ab09a35..6cec8ee 100644 --- a/creole/parser/creol2html_parser.py +++ b/creole/parser/creol2html_parser.py @@ -22,7 +22,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import re diff --git a/creole/parser/creol2html_rules.py b/creole/parser/creol2html_rules.py index 01bb08e..590661e 100644 --- a/creole/parser/creol2html_rules.py +++ b/creole/parser/creol2html_rules.py @@ -9,7 +9,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import re @@ -160,7 +160,7 @@ class BlockRules(object): def __init__(self, blog_line_breaks=True): if blog_line_breaks: - # use blog style line breaks (every line break would be converted into
) + # use blog style line breaks (every line break would be converted into
) self.text = r'(?P .+ ) (?P (? try to compile it ;) - + >>> _verify_rules(INLINE_RULES, INLINE_FLAGS) Rule test ok. - - >>> block_rules = BlockRules() + + >>> block_rules = BlockRules() >>> _verify_rules(block_rules.rules, block_rules.re_flags) Rule test ok. """ diff --git a/creole/parser/html_parser.py b/creole/parser/html_parser.py index fa60091..4380431 100644 --- a/creole/parser/html_parser.py +++ b/creole/parser/html_parser.py @@ -10,7 +10,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import re import warnings @@ -50,7 +50,7 @@ headline_tag_re = re.compile(r"h(\d)", re.UNICODE) class HtmlParser(HTMLParser): """ parse html code and create a document tree. - + >>> p = HtmlParser() >>> p.feed("

html code

") @@ -63,7 +63,7 @@ class HtmlParser(HTMLParser): strong data: 'code' ******************************************************************************** - + >>> p = HtmlParser() >>> p.feed("

html1 html2

") diff --git a/creole/parser/html_parser_config.py b/creole/parser/html_parser_config.py index 9790833..ddbda8f 100644 --- a/creole/parser/html_parser_config.py +++ b/creole/parser/html_parser_config.py @@ -4,14 +4,14 @@ """ python-creole ~~~~~~~~~~~~~ - + created by Jens Diemer :copyleft: 2009-2011 by the python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + BLOCK_TAGS = ( "address", "blockquote", "center", "dir", "div", "dl", "fieldset", diff --git a/creole/py3compat.py b/creole/py3compat.py index f48da75..76c55b4 100644 --- a/creole/py3compat.py +++ b/creole/py3compat.py @@ -3,16 +3,16 @@ """ Helper to support Python v2 and v3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + Some ideas borrowed from six - + See also: http://python3porting.com https://bitbucket.org/gutworth/six/src/tip/six.py http://packages.python.org/six/ """ -from __future__ import division, absolute_import, print_function, unicode_literals + import sys import doctest diff --git a/creole/rest_tools/clean_writer.py b/creole/rest_tools/clean_writer.py index 5378bd7..2b6ae66 100644 --- a/creole/rest_tools/clean_writer.py +++ b/creole/rest_tools/clean_writer.py @@ -4,19 +4,19 @@ """ A clean reStructuredText html writer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + It will produce a minimal set of html output. (No extry divs, classes oder ids.) - + Some code stolen from: http://www.arnebrodowski.de/blog/write-your-own-restructuredtext-writer.html https://github.com/alex-morega/docutils-plainhtml/blob/master/plain_html_writer.py - + :copyleft: 2011-2013 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + #import warnings import sys @@ -193,13 +193,13 @@ class CleanHTMLTranslator(html4css1.HTMLTranslator, object): def rest2html(content, enable_exit_status=None, **kwargs): """ Convert reStructuredText markup to clean html code: No extra div, class or ids. - + >>> rest2html("- bullet list") '
    \\n
  • bullet list
  • \\n
\\n' - + >>> rest2html("A ReSt link to `PyLucid CMS `_ :)") '

A ReSt link to PyLucid CMS :)

\\n' - + >>> rest2html("========", enable_exit_status=1, traceback=False, exit_status_level=2) Traceback (most recent call last): ... diff --git a/creole/rest_tools/pypi_rest2html.py b/creole/rest_tools/pypi_rest2html.py index fd7d16d..c60ae0c 100644 --- a/creole/rest_tools/pypi_rest2html.py +++ b/creole/rest_tools/pypi_rest2html.py @@ -11,7 +11,7 @@ https://bitbucket.org/pypa/pypi/issue/161/rest-formatting-fails-and-there-is-no-way """ -from __future__ import division, absolute_import, print_function + try: # Python 3 diff --git a/creole/setup_utils.py b/creole/setup_utils.py index 977cb73..6f6b651 100644 --- a/creole/setup_utils.py +++ b/creole/setup_utils.py @@ -42,7 +42,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import codecs import os diff --git a/creole/shared/HTMLParsercompat.py b/creole/shared/HTMLParsercompat.py index 67529d8..6f61cc5 100644 --- a/creole/shared/HTMLParsercompat.py +++ b/creole/shared/HTMLParsercompat.py @@ -1,7 +1,7 @@ """ Patched version of the original from: http://hg.python.org/cpython/file/tip/Lib/html/parser.py - + compare: http://hg.python.org/cpython/file/2.7/Lib/HTMLParser.py http://hg.python.org/cpython/file/3.2/Lib/html/parser.py @@ -13,12 +13,12 @@ e.g.: meld HTMLParser.py parser.py Make it compatible with Python 2.x and 3.x - + More info see html_parser.py ! """ # ------------------------------------------------------------------- add start -from __future__ import division, absolute_import, print_function, unicode_literals + from creole.py3compat import PY3 # --------------------------------------------------------------------- add end @@ -556,7 +556,7 @@ class HTMLParser(_markupbase.ParserBase): return self.entitydefs[s] except KeyError: return '&'+s+';' - + return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities, s, flags=re.ASCII) else: @@ -584,6 +584,6 @@ class HTMLParser(_markupbase.ParserBase): return self.entitydefs[s] except KeyError: return '&'+s+';' - + return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities, s) - # -------------------------------------------------------- change end \ No newline at end of file + # -------------------------------------------------------- change end diff --git a/creole/shared/base_emitter.py b/creole/shared/base_emitter.py index 1561083..de6fd2f 100644 --- a/creole/shared/base_emitter.py +++ b/creole/shared/base_emitter.py @@ -10,7 +10,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + from creole.parser.html_parser_config import BLOCK_TAGS from creole.html_tools.deentity import Deentity diff --git a/creole/shared/document_tree.py b/creole/shared/document_tree.py index 527e4f9..4971953 100644 --- a/creole/shared/document_tree.py +++ b/creole/shared/document_tree.py @@ -10,7 +10,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import warnings import inspect @@ -22,7 +22,7 @@ from creole.shared.utils import dict2string class DocNode: """ A node in the document tree for html2creole and creole2html. - + The Document tree would be created in the parser and used in the emitter. """ def __init__(self, kind='', parent=None, content=None, attrs=[], level=None): diff --git a/creole/shared/example_macros.py b/creole/shared/example_macros.py index 2eb85d8..428d5d2 100644 --- a/creole/shared/example_macros.py +++ b/creole/shared/example_macros.py @@ -11,7 +11,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + from xml.sax.saxutils import escape diff --git a/creole/shared/unknown_tags.py b/creole/shared/unknown_tags.py index 4e3e079..fe231f0 100644 --- a/creole/shared/unknown_tags.py +++ b/creole/shared/unknown_tags.py @@ -11,7 +11,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + from xml.sax.saxutils import escape @@ -42,7 +42,7 @@ def _mask_content(emitter, node, mask_tag): def raise_unknown_node(emitter, node): """ unknown_emit callable for Html2CreoleEmitter - + Raise NotImplementedError on unknown tags. """ content = emitter.emit_children(node) @@ -56,7 +56,7 @@ def raise_unknown_node(emitter, node): def use_html_macro(emitter, node): """ unknown_emit callable for Html2CreoleEmitter - + Use the <> macro to mask unknown tags. """ return _mask_content(emitter, node, mask_tag="html") @@ -65,7 +65,7 @@ def use_html_macro(emitter, node): def preformat_unknown_nodes(emitter, node): """ Put unknown tags in a
 area.
-    
+
     Usefull for html2textile.emitter.TextileEmitter()
     """
     return _mask_content(emitter, node, mask_tag="pre")
@@ -74,7 +74,7 @@ def preformat_unknown_nodes(emitter, node):
 def escape_unknown_nodes(emitter, node):
     """
     unknown_emit callable for Html2CreoleEmitter
-    
+
     All unknown tags should be escaped.
     """
     attrs = node.get_attrs_as_string()
@@ -99,8 +99,8 @@ def escape_unknown_nodes(emitter, node):
 
 def transparent_unknown_nodes(emitter, node):
     """
-    unknown_emit callable for Html2CreoleEmitter 
-    
+    unknown_emit callable for Html2CreoleEmitter
+
     Remove all unknown html tags and show only
     their child nodes' content.
     """
diff --git a/creole/shared/utils.py b/creole/shared/utils.py
index e150c5f..f1b981d 100644
--- a/creole/shared/utils.py
+++ b/creole/shared/utils.py
@@ -9,7 +9,7 @@
     :license: GNU GPL v3 or above, see LICENSE for more details.
 """
 
-from __future__ import division, absolute_import, print_function, unicode_literals
+
 
 import shlex
 import json
diff --git a/creole/tests/test_cli.py b/creole/tests/test_cli.py
index 5be41d5..dc692fc 100644
--- a/creole/tests/test_cli.py
+++ b/creole/tests/test_cli.py
@@ -9,7 +9,7 @@
     :license: GNU GPL v3 or above, see LICENSE for more details.
 """
 
-from __future__ import division, absolute_import, print_function, unicode_literals
+
 
 import subprocess
 import unittest
diff --git a/creole/tests/test_creole2html.py b/creole/tests/test_creole2html.py
index 4e21e13..b944ee9 100644
--- a/creole/tests/test_creole2html.py
+++ b/creole/tests/test_creole2html.py
@@ -16,7 +16,7 @@
     :license: GNU GPL v3 or above, see LICENSE for more details.
 """
 
-from __future__ import division, absolute_import, print_function, unicode_literals
+
 
 import sys
 import unittest
diff --git a/creole/tests/test_cross_compare_all.py b/creole/tests/test_cross_compare_all.py
index 58259d1..b10f59a 100644
--- a/creole/tests/test_cross_compare_all.py
+++ b/creole/tests/test_cross_compare_all.py
@@ -18,7 +18,7 @@
     :license: GNU GPL v3 or above, see LICENSE for more details.
 """
 
-from __future__ import division, absolute_import, print_function, unicode_literals
+
 
 import unittest
 
diff --git a/creole/tests/test_cross_compare_creole.py b/creole/tests/test_cross_compare_creole.py
index 6431fc0..ea48603 100644
--- a/creole/tests/test_cross_compare_creole.py
+++ b/creole/tests/test_cross_compare_creole.py
@@ -4,7 +4,7 @@
 """
     cross compare creole unittest
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    
+
     Compare all similarities between:
         * creole2html
         * html2creole
@@ -16,7 +16,7 @@
     :license: GNU GPL v3 or above, see LICENSE for more details.
 """
 
-from __future__ import division, absolute_import, print_function, unicode_literals
+
 
 import unittest
 
@@ -33,13 +33,13 @@ class CrossCompareCreoleTests(BaseCreoleTest):
                 **//bold italics//**
                 //**bold italics**//
                 //This is **also** good.//
-    
+
                 Creole 1.0 optional:
                 This is ##monospace## text.
                 This is ^^superscripted^^ text.
                 This is ,,subscripted,, text.
                 This is __underlined__ text.
-    
+
                 own additions:
                 This is --small-- and this ~~strikeout~~ ;)
             """,
@@ -48,13 +48,13 @@ class CrossCompareCreoleTests(BaseCreoleTest):
                 bold italics
bold italics
This is also good.

- +

Creole 1.0 optional:
This is monospace text.
This is superscripted text.
This is subscripted text.
This is underlined text.

- +

own additions:
This is small and this strikeout ;)

""" @@ -132,7 +132,7 @@ class CrossCompareCreoleTests(BaseCreoleTest): self.cross_compare_creole( creole_string=r""" === Closing braces in nowiki: - + {{{ if (x != NULL) { for (i = 0; i < size; i++) { @@ -143,7 +143,7 @@ class CrossCompareCreoleTests(BaseCreoleTest): """, html_string="""

Closing braces in nowiki:

- +
                 if (x != NULL) {
                   for (i = 0; i < size; i++) {
@@ -156,14 +156,14 @@ class CrossCompareCreoleTests(BaseCreoleTest):
     def test_pre2(self):
         self.cross_compare_creole(r"""
             111
-            
+
             {{{
             //This// does **not** get [[formatted]]
             }}}
             222
 
             one
-            
+
             {{{
             foo
 
@@ -172,14 +172,14 @@ class CrossCompareCreoleTests(BaseCreoleTest):
             two
         """, """
             

111

- +
             //This// does **not** get [[formatted]]
             

222

- +

one

- +
             foo
 
@@ -191,7 +191,7 @@ class CrossCompareCreoleTests(BaseCreoleTest):
     def test_pre(self):
         self.cross_compare_creole(r"""
             start
-            
+
             {{{
             * no list
             
@@ -199,7 +199,7 @@ class CrossCompareCreoleTests(BaseCreoleTest):
             end
         """, """
             

start

- +
             * no list
             <html escaped>
@@ -219,16 +219,16 @@ class CrossCompareCreoleTests(BaseCreoleTest):
         self.cross_compare_creole(
             creole_string=r"""
                 = Headline
-                
+
                 === **not** //parsed//
-                
+
                 No == headline == or?
             """,
             html_string="""
                 

Headline

- +

**not** //parsed//

- +

No == headline == or?

""" ) diff --git a/creole/tests/test_cross_compare_rest.py b/creole/tests/test_cross_compare_rest.py index c40e924..454d6e5 100644 --- a/creole/tests/test_cross_compare_rest.py +++ b/creole/tests/test_cross_compare_rest.py @@ -13,7 +13,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import unittest diff --git a/creole/tests/test_cross_compare_textile.py b/creole/tests/test_cross_compare_textile.py index 2a0681a..fbbd871 100644 --- a/creole/tests/test_cross_compare_textile.py +++ b/creole/tests/test_cross_compare_textile.py @@ -16,7 +16,7 @@ :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import unittest diff --git a/creole/tests/test_html2creole.py b/creole/tests/test_html2creole.py index 58a20ef..df7c951 100644 --- a/creole/tests/test_html2creole.py +++ b/creole/tests/test_html2creole.py @@ -5,15 +5,15 @@ """ html2creole tests ~~~~~~~~~~~~~~~~~ - + special html to creole convert tests, witch can't tests in "cross compare" - + :copyleft: 2008-2011 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ -from __future__ import division, absolute_import, print_function, unicode_literals + import unittest @@ -136,7 +136,7 @@ class TestHtml2CreoleMarkup(BaseCreoleTest): ) def test_transparent_unknown_nodes2(self): - """ + """ HTMLParser has problems with