Skip to content

Commit

Permalink
Config with pure python template (#13)
Browse files Browse the repository at this point in the history
* Drop support for Python 2.7, 3.5, 3.6.
* Add support for Python 3.11.
  • Loading branch information
Michael Howitz committed Jan 27, 2023
1 parent 61554a6 commit 5551240
Show file tree
Hide file tree
Showing 17 changed files with 266 additions and 230 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/tests.yml
Expand Up @@ -17,31 +17,29 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu
- ["ubuntu", "ubuntu-20.04"]
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["2.7", "py27"]
- ["3.5", "py35"]
- ["3.6", "py36"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["pypy2", "pypy"]
- ["pypy3", "pypy3"]
- ["3.11", "py311"]
- ["pypy-3.9", "pypy3"]
- ["3.9", "coverage"]

runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: ${{ matrix.config[1] }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config[0] }}
- name: Pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
Expand All @@ -57,7 +55,7 @@ jobs:
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
pip install coveralls coverage-python-version
pip install coveralls
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -28,4 +28,5 @@ lib64
log/
parts/
pyvenv.cfg
testing.log
var/
4 changes: 2 additions & 2 deletions .meta.toml
Expand Up @@ -2,14 +2,14 @@
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "fba6d957ba447b6fa369d872e803756bd5176391"
commit-id = "487d9939"

[python]
with-windows = false
with-pypy = true
with-future-python = false
with-legacy-python = true
with-sphinx-doctests = false
with-macos = false

[tox]
use-flake8 = true
Expand Down
6 changes: 4 additions & 2 deletions CHANGES.rst
Expand Up @@ -2,10 +2,12 @@
CHANGES
=======

2.3 (unreleased)
3.0 (unreleased)
----------------

- Nothing changed yet.
- Add support for Python 3.11.

- Drop support for Python 2.7, 3.5, 3.6.


2.2 (2022-02-11)
Expand Down
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,23 @@
<!--
Generated from:
https://github.com/zopefoundation/meta/tree/master/config/pure-python
-->
# Contributing to zopefoundation projects

The projects under the zopefoundation GitHub organization are open source and
welcome contributions in different forms:

* bug reports
* code improvements and bug fixes
* documentation improvements
* pull request reviews

For any changes in the repository besides trivial typo fixes you are required
to sign the contributor agreement. See
https://www.zope.dev/developer/becoming-a-committer.html for details.

Please visit our [Developer
Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to
contribute code changes and our [guidelines for reporting
bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a
bug report.
1 change: 1 addition & 0 deletions MANIFEST.in
@@ -1,5 +1,6 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
include *.md
include *.rst
include *.txt
include buildout.cfg
Expand Down
13 changes: 12 additions & 1 deletion setup.cfg
@@ -1,7 +1,7 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[bdist_wheel]
universal = 1
universal = 0

[flake8]
doctests = 1
Expand All @@ -10,3 +10,14 @@ doctests = 1
ignore =
.editorconfig
.meta.toml

[isort]
force_single_line = True
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
known_third_party = six, docutils, pkg_resources, pytz
known_zope =
known_first_party =
default_section = ZOPE
line_length = 79
lines_after_imports = 2
15 changes: 8 additions & 7 deletions setup.py
Expand Up @@ -14,16 +14,19 @@
"""Setup
"""
import os
from setuptools import setup, find_packages

from setuptools import find_packages
from setuptools import setup


def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()


setup(
name="z3c.table",
version='2.3.dev0',
version='3.0.dev0',
author="Stephan Richter, Roger Ineichen and the Zope Community",
author_email="zope-dev@zope.org",
description="Modular table rendering implementation for Zope3",
Expand Down Expand Up @@ -52,15 +55,12 @@ def read(*rnames):
"Intended Audience :: Developers",
"License :: OSI Approved :: Zope Public License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Natural Language :: English",
Expand All @@ -73,6 +73,7 @@ def read(*rnames):
include_package_data=True,
package_dir={"": "src"},
namespace_packages=["z3c"],
python_requires='>=3.7',
extras_require=dict(
test=[
"zope.container",
Expand Down
22 changes: 9 additions & 13 deletions src/z3c/table/batch.py
Expand Up @@ -11,25 +11,21 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
try:
# Python 2
from urllib import urlencode
except ImportError:
# Python 3
from urllib.parse import urlencode
from urllib.parse import urlencode

import zope.interface
import zope.i18nmessageid
import zope.interface
from z3c.batching.batch import first_neighbours_last
from zope.traversing.browser import absoluteURL

from z3c.table import interfaces
from z3c.batching.batch import first_neighbours_last


_ = zope.i18nmessageid.MessageFactory("z3c")


@zope.interface.implementer(interfaces.IBatchProvider)
class BatchProvider(object):
class BatchProvider:
"""Batch content provider.
A batch provider is responsible for rendering the batch HTML and not for
Expand Down Expand Up @@ -69,7 +65,7 @@ class BatchProvider(object):

prevBatchSize = 3
nextBatchSize = 3
batchSpacer = u"..."
batchSpacer = "..."

_request_args = ["%(prefix)s-sortOn", "%(prefix)s-sortOrder"]

Expand Down Expand Up @@ -102,8 +98,8 @@ def renderBatchLink(self, batch, cssClass=None):
tableURL = absoluteURL(self.table, self.request)
idx = batch.index + 1
css = ' class="%s"' % cssClass
cssClass = cssClass and css or u""
return '<a href="%s?%s"%s>%s</a>' % (tableURL, query, cssClass, idx)
cssClass = cssClass and css or ""
return f'<a href="{tableURL}?{query}"{cssClass}>{idx}</a>'

def update(self):
# 3 is is the placeholder for the first, current and last item.
Expand Down Expand Up @@ -156,4 +152,4 @@ def render(self):
append(self.renderBatchLink(batch, css))
else:
append(self.renderBatchLink(batch))
return u"\n".join(res)
return "\n".join(res)

0 comments on commit 5551240

Please sign in to comment.