Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config with pure python #7

Merged
merged 5 commits into from
Feb 10, 2021
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
11 changes: 0 additions & 11 deletions .coveragerc

This file was deleted.

39 changes: 39 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
#
# EditorConfig Configuration file, for more details see:
# http://EditorConfig.org
# EditorConfig is a convention description, that could be interpreted
# by multiple editors to enforce common coding conventions for specific
# file types

# top-most EditorConfig file:
# Will ignore other EditorConfig files in Home directory or upper tree level.
root = true


[*] # For All Files
# Unix-style newlines with a newline ending every file
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
# Set default charset
charset = utf-8
# Indent style default
indent_style = space
# Max Line Length - a hard line wrap, should be disabled
max_line_length = off

[*.{py,cfg,ini}]
# 4 space indentation
indent_size = 4

[*.{yml,zpt,pt,dtml}]
# 2 space indentation
indent_size = 2

[{Makefile,.gitmodules}]
# Tab indentation (no size specified, but view as 4 spaces)
indent_style = tab
indent_size = unset
tab_width = unset
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
name: tests

on:
push:
branches: [ master ]
pull_request:
schedule:
- cron: '0 12 * * 0' # run once a week on Sunday

jobs:
build:
strategy:
matrix:
config:
# [Python version, tox env]
- ["3.8", "lint"]
- ["2.7", "py27"]
- ["3.5", "py35"]
- ["3.6", "py36"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.8", "coverage"]

runs-on: ubuntu-latest
name: ${{ matrix.config[1] }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.config[0] }}
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.config[0] }}-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test
run: tox -e ${{ matrix.config[1] }}
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
pip install coveralls coverage-python-version
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 21 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
*.egg-info/
*.profraw
*.pyc
__pycache__
src/*.egg-info

*.pyo
.coverage
.coverage.*
.eggs/
.installed.cfg
.tox
bin
develop-eggs
parts
.mr.developer.cfg
.tox/
__pycache__/
bin/
build/
coverage.xml
develop-eggs/
dist/
docs/_build
eggs/
lib/
lib64
parts/
pyvenv.cfg
15 changes: 15 additions & 0 deletions .meta.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "ae6fbae62663edb6a8b62d2dbdfe0589f64b8844"

[python]
with-appveyor = false
with-pypy = false
with-legacy-python = true
with-docs = false
with-sphinx-doctests = false

[coverage]
fail-under = 89
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Changes
1.2 (unreleased)
================

- Nothing changed yet.
- Add support for Python 3.8 and 3.9.


1.1 (2018-11-07)
Expand Down
6 changes: 5 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
include *.rst
include *.txt
include .coveragerc
include buildout.cfg
include tox.ini

recursive-include src *.pt
recursive-include src *.py
recursive-include src *.rst
recursive-include src *.txt
recursive-include src *.zcml
24 changes: 0 additions & 24 deletions buildout.cfg

This file was deleted.

10 changes: 10 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[bdist_wheel]
universal = 1

[flake8]
doctests = 1

[check-manifest]
ignore =
.editorconfig
.meta.toml
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def read_file(*args):
with open(path, 'r') as f:
return f.read() + '\n\n'


setup(
name='zc.sourcefactory',
version='1.2.dev0',
Expand Down Expand Up @@ -56,6 +57,8 @@ def read_file(*args):
'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 :: Implementation :: CPython',
'Natural Language :: English',
'Operating System :: OS Independent',
Expand Down
8 changes: 1 addition & 7 deletions src/zc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# This directory is a Python namespace package.
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
1 change: 1 addition & 0 deletions src/zc/sourcefactory/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import zope.component
import zc.sourcefactory.source


@zope.interface.implementer(zope.schema.interfaces.ISourceQueriables)
@zope.component.adapter(zc.sourcefactory.source.FactoredSource)
def getSourceQueriables(factored_source):
Expand Down
1 change: 1 addition & 0 deletions src/zc/sourcefactory/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import zc.sourcefactory.factories
import zc.sourcefactory.policies


class BasicSourceFactory(zc.sourcefactory.factories.BasicSourceFactory,
zc.sourcefactory.policies.BasicSourcePolicy):
"""Basic source factory implementation including a factory and the
Expand Down
7 changes: 3 additions & 4 deletions src/zc/sourcefactory/browser/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
import zc.sourcefactory.mapping


@zope.component.adapter(zc.sourcefactory.mapping.ValueMappingSource,
zope.publisher.interfaces.browser.IBrowserRequest)
@zope.interface.implementer(zope.browser.interfaces.ITerms)
class MappedTerms(object):
"""A terms implementation that knows how to handle a source that was
"""A terms implementation that knows how to handle a source that was
created through a source factory.
"""

zope.component.adapts(zc.sourcefactory.mapping.ValueMappingSource,
zope.publisher.interfaces.browser.IBrowserRequest)

def __init__(self, source, request):
self.base = zope.component.getMultiAdapter(
[source.base, request], zope.browser.interfaces.ITerms)
Expand Down
12 changes: 4 additions & 8 deletions src/zc/sourcefactory/browser/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@
import zc.sourcefactory.source


@zope.component.adapter(zc.sourcefactory.source.FactoredSource,
zope.publisher.interfaces.browser.IBrowserRequest)
@zope.interface.implementer(zope.browser.interfaces.ITerms)
class FactoredTerms(object):
"""A terms implementation that knows how to handle a source that was
created through a source factory.
"""

zope.component.adapts(
zc.sourcefactory.source.FactoredSource,
zope.publisher.interfaces.browser.IBrowserRequest)

def __init__(self, source, request):
self.source = source
self.request = request
Expand All @@ -46,15 +44,13 @@ def getValue(self, token):
return self.source.factory.getValue(self.source, token)


@zope.component.adapter(zc.sourcefactory.source.FactoredContextualSource,
zope.publisher.interfaces.browser.IBrowserRequest)
class FactoredContextualTerms(FactoredTerms):
"""A terms implementation that knows how to handle a source that was
created through a contextual source factory.
"""

zope.component.adapts(
zc.sourcefactory.source.FactoredContextualSource,
zope.publisher.interfaces.browser.IBrowserRequest)

def getTerm(self, value):
title = self.source.factory.getTitle(self.source.context, value)
token = self.source.factory.getToken(self.source.context, value)
Expand Down
15 changes: 8 additions & 7 deletions src/zc/sourcefactory/browser/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

from zc.sourcefactory.tests import setUp, tearDown, checker


def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite(
'token.txt', setUp=setUp, tearDown=tearDown,
checker=checker, optionflags=doctest.ELLIPSIS),
doctest.DocFileSuite(
'README.txt', setUp=setUp, tearDown=tearDown,
checker=checker, optionflags=doctest.ELLIPSIS),
))
doctest.DocFileSuite(
'token.txt', setUp=setUp, tearDown=tearDown,
checker=checker, optionflags=doctest.ELLIPSIS),
doctest.DocFileSuite(
'README.txt', setUp=setUp, tearDown=tearDown,
checker=checker, optionflags=doctest.ELLIPSIS),
))
1 change: 1 addition & 0 deletions src/zc/sourcefactory/browser/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

PY3 = sys.version_info[0] == 3


@zope.component.adapter(bytes)
@zope.interface.implementer(zc.sourcefactory.interfaces.IToken)
def fromString(value):
Expand Down
4 changes: 2 additions & 2 deletions src/zc/sourcefactory/contextual.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@


class BasicContextualSourceFactory(
zc.sourcefactory.factories.ContextualSourceFactory,
zc.sourcefactory.policies.BasicContextualSourcePolicy):
zc.sourcefactory.factories.ContextualSourceFactory,
zc.sourcefactory.policies.BasicContextualSourcePolicy):
"""Abstract base implementation for a basic contextual source factory."""
4 changes: 3 additions & 1 deletion src/zc/sourcefactory/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import zope.interface
import zope.schema.interfaces


class ISourceFactory(zope.interface.Interface):

def __call__():
Expand Down Expand Up @@ -133,10 +134,11 @@ def filterValue(context, value):

# Standard combined policies


class ISourcePolicy(ITokenPolicy, ITermPolicy, IValuePolicy):
pass


class IContextualSourcePolicy(
ITokenPolicy, IContextualTermPolicy, IContextualValuePolicy):
ITokenPolicy, IContextualTermPolicy, IContextualValuePolicy):
pass
Loading