Commit 512b0d99 authored by Jens Vagelpohl's avatar Jens Vagelpohl Committed by GitHub

Merge pull request #18 from zopefoundation/config-with-pure-python

Update package configuration and lint the code
parents 40aaf1b3 accfe5ea
# 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,zcml}]
# 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
# based on https://github.com/zopefoundation/meta/blob/master/config/default/tests.yml.j2
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
name: tests
on:
......@@ -19,6 +20,7 @@ jobs:
- ubuntu
config:
# [Python version, tox env]
- ["3.8", "lint"]
- ["2.7", "py27"]
- ["3.5", "py35"]
- ["3.6", "py36"]
......@@ -27,6 +29,7 @@ jobs:
- ["3.9", "py39"]
- ["pypy2", "pypy"]
- ["pypy3", "pypy3"]
- ["3.8", "coverage"]
runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.config[1] }}
......@@ -50,3 +53,10 @@ jobs:
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 }}
bin
build
dist
lib
parts
develop-eggs
*.dll
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
*.egg-info/
*.profraw
*.pyc
*.pyo
*.so
.coverage
.coverage.*
.eggs/
.installed.cfg
.tox
*.egg-info
.mr.developer.cfg
.tox/
.vscode/
__pycache__/
bin/
build/
coverage.xml
develop-eggs/
develop/
dist/
docs/_build
eggs/
etc/
lib/
lib64
log/
parts/
pyvenv.cfg
var/
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "2a88c4b047cb9e8df85901519c92d97f469e25de"
[python]
with-windows = false
with-pypy = true
with-future-python = false
with-legacy-python = true
with-sphinx-doctests = false
[tox]
use-flake8 = true
[coverage]
fail-under = 68
[manifest]
additional-rules = [
"recursive-include src *.xml",
]
......@@ -4,6 +4,8 @@ Changelog
5.2 (unreleased)
----------------
- Update package configuration
- Package is now officially undeprecated because the data corruption issue -
that was the reason for its deprecation - has been understood and fixed. See
(`#16 <https://github.com/zopefoundation/tempstorage/issues/16>`_).
......
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
include *.rst
include *.txt
include buildout.cfg
include tox.ini
recursive-include src *.py
recursive-include src *.xml
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[bdist_wheel]
universal = 1
[zest.releaser]
create-wheel = yes
[flake8]
doctests = 1
[check-manifest]
ignore =
.editorconfig
.meta.toml
......@@ -14,28 +14,36 @@
"""Setup for the tempstorage package
"""
from setuptools import setup, find_packages
from setuptools import find_packages
from setuptools import setup
long_description = (open("README.rst").read() + "\n" +
open("CHANGES.rst").read())
version = '5.2.dev0'
__version__ = version
setup(name='tempstorage',
version=__version__,
url='https://github.com/zopefoundation/tempstorage',
project_urls={
'Issue Tracker': ('https://github.com/zopefoundation/'
'tempstorage/issues'),
'Sources': 'https://github.com/zopefoundation/tempstorage',
},
license='ZPL 2.1',
description='A RAM-based storage for ZODB',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
long_description=long_description,
classifiers=[
"Development Status :: 7 - Inactive",
"Development Status :: 6 - Mature",
"Environment :: Web Environment",
"Framework :: ZODB",
"Framework :: Zope",
"Framework :: Zope :: 4",
"Framework :: Zope :: 5",
"Intended Audience :: Developers",
"License :: OSI Approved",
"License :: OSI Approved :: Zope Public License",
......@@ -57,15 +65,16 @@ setup(name='tempstorage',
],
packages=find_packages('src'),
package_dir={'': 'src'},
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
install_requires=[
'setuptools',
'ZODB >= 5.0',
'ZODB >= 5.6',
'zope.testing',
],
extras_require={
'test': [
'mock',
'zope.testrunner'
'zope.testrunner',
'mock ; python_version < "3"',
],
},
include_package_data=True,
......
......@@ -19,7 +19,6 @@ resolution.
This is a ripoff of Jim's Packless bsddb3 storage.
"""
import bisect
import warnings
import time
from ZODB import POSException
......@@ -116,17 +115,17 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
if now > (self._last_cache_gc + self._conflict_cache_gcevery):
# build {} oid -> [](serial, data, t)
byoid = {}
for ((oid,serial), (data,t)) in self._conflict_cache.items():
for ((oid, serial), (data, t)) in self._conflict_cache.items():
hist = byoid.setdefault(oid, [])
hist.append((serial, data, t))
# gc entries but keep latest record for each oid
for oid, hist in byoid.items():
hist.sort(key=lambda _: _[0]) # by serial
hist = hist[:-1] # without latest record
hist.sort(key=lambda _: _[0]) # by serial
hist = hist[:-1] # without latest record
for serial, data, t in hist:
if now > (t + self._conflict_cache_maxage):
del self._conflict_cache[(oid,serial)]
del self._conflict_cache[(oid, serial)]
self._last_cache_gc = now
self._tmp = []
......
......@@ -135,7 +135,7 @@ class TemporaryStorageTests(unittest.TestCase):
r2 = storage.tpc_vote(t)
revid = handle_serials(oid, r1, r2)
storage.tpc_finish(t)
except:
except: # noqa: E722 bare except
storage.tpc_abort(t)
raise
return revid
......@@ -181,7 +181,8 @@ class TemporaryStorageTests(unittest.TestCase):
storage._conflict_cache_gcevery = 1 # second
storage._conflict_cache_maxage = 1 # second
# assertCacheKeys asserts that set(storage._conflict_cache.keys()) == oidrevSet
# assertCacheKeys asserts that
# set(storage._conflict_cache.keys()) == oidrevSet
# storage._conflict_cache is organized as {} (oid,rev) -> (data,t) and
# so is used by loadBefore as data storage. It is important that latest
# revision of an object is not garbage-collected so that loadBefore
......@@ -191,7 +192,8 @@ class TemporaryStorageTests(unittest.TestCase):
self.assertEqual(set(storage._conflict_cache.keys()), oidrevOK)
# make sure that loadBefore actually uses ._conflict_cache data
for (oid, rev) in voidrevOK:
load_data, load_serial, _ = storage.loadBefore(oid, p64(u64(rev)+1))
load_data, load_serial, _ = storage.loadBefore(oid,
p64(u64(rev)+1))
data, t = storage._conflict_cache[(oid, rev)]
self.assertEqual((load_data, load_serial), (data, rev))
......@@ -224,7 +226,10 @@ class TemporaryStorageTests(unittest.TestCase):
rev41 = storage.lastTransaction()
# (oid2, rev21) garbage-collected
assertCacheKeys((oid1, rev12), (oid2, rev22), (oid3, rev31), (oid4, rev41))
assertCacheKeys((oid1, rev12),
(oid2, rev22),
(oid3, rev31),
(oid4, rev41))
def test_have_MVCC_ergo_no_ReadConflict(self):
from ZODB.DB import DB
......
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[tox]
minversion = 3.18
envlist =
py27,py35,py36,py37,py38,py39,pypy,pypy3
lint
py27
py35
py36
py37
py38
py39
pypy
pypy3
coverage
[testenv]
usedevelop = true
deps =
commands =
zope-testrunner --test-path=src {posargs:-vc}
extras =
test
[testenv:lint]
basepython = python3
skip_install = true
deps =
flake8
check-manifest
check-python-versions
commands =
zope-testrunner --test-path=src --auto-color --auto-progress
flake8 src setup.py
check-manifest
check-python-versions
[testenv:coverage]
basepython = python3
allowlist_externals =
mkdir
deps =
coverage
coverage-python-version
commands =
mkdir -p {toxinidir}/parts/htmlcov
coverage run -m zope.testrunner --test-path=src {posargs:-vc}
coverage html
coverage report -m --fail-under=68
[coverage:run]
branch = True
plugins = coverage_python_version
source = tempstorage
[coverage:report]
precision = 2
exclude_lines =
pragma: no cover
pragma: nocover
except ImportError:
raise NotImplementedError
if __name__ == '__main__':
self.fail
raise AssertionError
extras = test
[coverage:html]
directory = parts/htmlcov
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment