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

Bump to cherrypy 17.4.2 and Kodi 18/19 compatibility #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 25 additions & 7 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.cherrypy"
name="CherryPy Kodi module"
version="11.0.1"
provider-name="marcelveldt, CherryPy Team">
version="17.4.2-3"
provider-name="marcelveldt, CherryPy Team, wuff">
<requires>
<import addon="xbmc.python" version="2.24.0"/>
<!-- <import addon="xbmc.python" version="2.24.0"/> -->
<import addon="script.module.six" version="1.9.0"/>
</requires>
<extension point="xbmc.python.module" library="lib" />
<extension point="xbmc.addon.metadata">
<summary>CherryPy webserver packaged as Kodi module</summary>
<description>CherryPy is a pythonic, object-oriented web framework
CherryPy allows developers to build web applications in much the same way they would build any other object-oriented Python program. This results in smaller source code developed in less time.
CherryPy is now more than ten years old and it is has proven to be very fast and stable. It is being used in production by many sites, from the simplest to the most demanding.
</description>
<description>CherryPy is a pythonic, object-oriented web framework.[CR]CherryPy allows developers to build web applications in much the same way they would build any other object-oriented Python program. This results in smaller source code developed in less time.[CR]CherryPy is now more than ten years old and it is has proven to be very fast and stable. It is being used in production by many sites, from the simplest to the most demanding.</description>
<license>BSD</license>
<source>https://github.com/marcelveldt/script.module.cherrypy</source>
<platform>all</platform>
<assets>
<icon>icon.png</icon>
</assets>
<news>
v17.4.2-3:
- removed pkg_resource dependency (from TheTimeWalker 17.4.0 fork)
- added backports.functools_lru_cache 1.5
v17.4.2-2:
- add selectors2 2.0.2 dependency
v17.4.2-1:
- add pkg_resources dependency from setuptools 39.2.0
v17.4.2:
- update CherryPy to last Py2/3 compatible version 17.4.2
- update cheroot to version 8.4.5
- add more-itertools-5.0.0 dependency
- add contextlib2-0.6.0.post1 dependency
- add zc.lockfile-2.0 dependency
- add jaraco.functools-2.0 dependency
v11.0.2:
- Remove Python requirement for Kodi18/19 compatibility
</news>
</extension>
</addon>
1 change: 1 addition & 0 deletions lib/backports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
184 changes: 184 additions & 0 deletions lib/backports/functools_lru_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
from __future__ import absolute_import

import functools
from collections import namedtuple
from threading import RLock

_CacheInfo = namedtuple("CacheInfo", ["hits", "misses", "maxsize", "currsize"])


@functools.wraps(functools.update_wrapper)
def update_wrapper(wrapper,
wrapped,
assigned = functools.WRAPPER_ASSIGNMENTS,
updated = functools.WRAPPER_UPDATES):
"""
Patch two bugs in functools.update_wrapper.
"""
# workaround for http://bugs.python.org/issue3445
assigned = tuple(attr for attr in assigned if hasattr(wrapped, attr))
wrapper = functools.update_wrapper(wrapper, wrapped, assigned, updated)
# workaround for https://bugs.python.org/issue17482
wrapper.__wrapped__ = wrapped
return wrapper


class _HashedSeq(list):
__slots__ = 'hashvalue'

def __init__(self, tup, hash=hash):
self[:] = tup
self.hashvalue = hash(tup)

def __hash__(self):
return self.hashvalue


def _make_key(args, kwds, typed,
kwd_mark=(object(),),
fasttypes=set([int, str, frozenset, type(None)]),
sorted=sorted, tuple=tuple, type=type, len=len):
'Make a cache key from optionally typed positional and keyword arguments'
key = args
if kwds:
sorted_items = sorted(kwds.items())
key += kwd_mark
for item in sorted_items:
key += item
if typed:
key += tuple(type(v) for v in args)
if kwds:
key += tuple(type(v) for k, v in sorted_items)
elif len(key) == 1 and type(key[0]) in fasttypes:
return key[0]
return _HashedSeq(key)


def lru_cache(maxsize=100, typed=False):
"""Least-recently-used cache decorator.

If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.

If *typed* is True, arguments of different types will be cached separately.
For example, f(3.0) and f(3) will be treated as distinct calls with
distinct results.

Arguments to the cached function must be hashable.

View the cache statistics named tuple (hits, misses, maxsize, currsize) with
f.cache_info(). Clear the cache and statistics with f.cache_clear().
Access the underlying function with f.__wrapped__.

See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used

"""

# Users should only access the lru_cache through its public API:
# cache_info, cache_clear, and f.__wrapped__
# The internals of the lru_cache are encapsulated for thread safety and
# to allow the implementation to change (including a possible C version).

def decorating_function(user_function):

cache = dict()
stats = [0, 0] # make statistics updateable non-locally
HITS, MISSES = 0, 1 # names for the stats fields
make_key = _make_key
cache_get = cache.get # bound method to lookup key or return None
_len = len # localize the global len() function
lock = RLock() # because linkedlist updates aren't threadsafe
root = [] # root of the circular doubly linked list
root[:] = [root, root, None, None] # initialize by pointing to self
nonlocal_root = [root] # make updateable non-locally
PREV, NEXT, KEY, RESULT = 0, 1, 2, 3 # names for the link fields

if maxsize == 0:

def wrapper(*args, **kwds):
# no caching, just do a statistics update after a successful call
result = user_function(*args, **kwds)
stats[MISSES] += 1
return result

elif maxsize is None:

def wrapper(*args, **kwds):
# simple caching without ordering or size limit
key = make_key(args, kwds, typed)
result = cache_get(key, root) # root used here as a unique not-found sentinel
if result is not root:
stats[HITS] += 1
return result
result = user_function(*args, **kwds)
cache[key] = result
stats[MISSES] += 1
return result

else:

def wrapper(*args, **kwds):
# size limited caching that tracks accesses by recency
key = make_key(args, kwds, typed) if kwds or typed else args
with lock:
link = cache_get(key)
if link is not None:
# record recent use of the key by moving it to the front of the list
root, = nonlocal_root
link_prev, link_next, key, result = link
link_prev[NEXT] = link_next
link_next[PREV] = link_prev
last = root[PREV]
last[NEXT] = root[PREV] = link
link[PREV] = last
link[NEXT] = root
stats[HITS] += 1
return result
result = user_function(*args, **kwds)
with lock:
root, = nonlocal_root
if key in cache:
# getting here means that this same key was added to the
# cache while the lock was released. since the link
# update is already done, we need only return the
# computed result and update the count of misses.
pass
elif _len(cache) >= maxsize:
# use the old root to store the new key and result
oldroot = root
oldroot[KEY] = key
oldroot[RESULT] = result
# empty the oldest link and make it the new root
root = nonlocal_root[0] = oldroot[NEXT]
oldkey = root[KEY]
root[KEY] = root[RESULT] = None
# now update the cache dictionary for the new links
del cache[oldkey]
cache[key] = oldroot
else:
# put result in a new link at the front of the list
last = root[PREV]
link = [last, root, key, result]
last[NEXT] = root[PREV] = cache[key] = link
stats[MISSES] += 1
return result

def cache_info():
"""Report cache statistics"""
with lock:
return _CacheInfo(stats[HITS], stats[MISSES], maxsize, len(cache))

def cache_clear():
"""Clear the cache and cache statistics"""
with lock:
cache.clear()
root = nonlocal_root[0]
root[:] = [root, root, None, None]
stats[:] = [0, 0]

wrapper.__wrapped__ = user_function
wrapper.cache_info = cache_info
wrapper.cache_clear = cache_clear
return update_wrapper(wrapper, user_function)

return decorating_function
4 changes: 2 additions & 2 deletions lib/cheroot/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**Copyright &copy; 2004-2016, CherryPy Team (team@cherrypy.org)**
Copyright © 2004-2020, CherryPy Team (team@cherrypy.org)

**All rights reserved.**
All rights reserved.

* * *

Expand Down
148 changes: 148 additions & 0 deletions lib/cheroot/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
Metadata-Version: 2.1
Name: cheroot
Version: 8.4.5
Summary: Highly-optimized, pure-python HTTP server
Home-page: https://cheroot.cherrypy.org
Author: CherryPy Team
Author-email: team@cherrypy.org
License: UNKNOWN
Project-URL: CI: AppVeyor, https://ci.appveyor.com/project/cherrypy/cheroot
Project-URL: CI: Circle, https://circleci.com/gh/cherrypy/cheroot
Project-URL: CI: GitHub, https://github.com/cherrypy/cheroot/actions
Project-URL: CI: Travis, https://travis-ci.com/cherrypy/cheroot
Project-URL: Docs: RTD, https://cheroot.cherrypy.org
Project-URL: GitHub: issues, https://github.com/cherrypy/cheroot/issues
Project-URL: GitHub: repo, https://github.com/cherrypy/cheroot
Project-URL: Tidelift: funding, https://tidelift.com/subscription/pkg/pypi-cheroot?utm_source=pypi-cheroot&utm_medium=referral&utm_campaign=pypi
Description: .. image:: https://img.shields.io/pypi/v/cheroot.svg
:target: https://pypi.org/project/cheroot

.. image:: https://tidelift.com/badges/package/pypi/cheroot
:target: https://tidelift.com/subscription/pkg/pypi-cheroot?utm_source=pypi-cheroot&utm_medium=readme
:alt: Cheroot is available as part of the Tidelift Subscription

.. image:: https://img.shields.io/travis/com/cherrypy/cheroot/master.svg?logo=travis&label=Linux%20build%20%40%20Travis%20CI
:target: https://travis-ci.com/cherrypy/cheroot

.. image:: https://circleci.com/gh/cherrypy/cheroot/tree/master.svg?style=svg
:target: https://circleci.com/gh/cherrypy/cheroot/tree/master

.. image:: https://img.shields.io/appveyor/ci/cherrypy/cheroot/master.svg?label=Windows%20build%20%40%20Appveyor
:target: https://ci.appveyor.com/project/cherrypy/cheroot/branch/master

.. image:: https://github.com/cherrypy/cheroot/workflows/Test%20suite/badge.svg
:target: https://github.com/cherrypy/cheroot/actions?query=workflow%3A%22Test+suite%22+branch%3Amaster
:alt: GitHub Actions Workflow — Test suite

.. image:: https://github.com/cherrypy/cheroot/workflows/Code%20quality/badge.svg
:target: https://github.com/cherrypy/cheroot/actions?query=workflow%3A%22Code+quality%22+branch%3Amaster
:alt: GitHub Actions Workflow — Code quality

.. image:: https://img.shields.io/badge/license-BSD-blue.svg?maxAge=3600
:target: https://pypi.org/project/cheroot

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

.. image:: https://codecov.io/gh/cherrypy/cheroot/branch/master/graph/badge.svg
:target: https://codecov.io/gh/cherrypy/cheroot
:alt: codecov

.. image:: https://readthedocs.org/projects/cheroot/badge/?version=latest
:target: https://cheroot.cherrypy.org/en/latest/?badge=latest

.. image:: https://img.shields.io/badge/StackOverflow-Cheroot-blue.svg
:target: https://stackoverflow.com/questions/tagged/cheroot+or+cherrypy

.. image:: https://img.shields.io/gitter/room/cherrypy/cherrypy.svg
:target: https://gitter.im/cherrypy/cherrypy

.. image:: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
:target: http://makeapullrequest.com/

.. image:: https://app.fossa.io/api/projects/git%2Bgithub.com%2Fcherrypy%2Fcheroot.svg?type=shield
:target: https://app.fossa.io/projects/git%2Bgithub.com%2Fcherrypy%2Fcheroot?ref=badge_shield
:alt: FOSSA Status

Cheroot is the high-performance, pure-Python HTTP server used by CherryPy.

Status
======

The test suite currently relies on pytest. It's being run via Travis CI.

For Enterprise
==============

.. list-table::
:widths: 10 100

* - |tideliftlogo|
- Professional support for Cheroot is available as part of the
`Tidelift Subscription`_. The CherryPy maintainers and the
maintainers of thousands of other packages are working with
Tidelift to deliver one enterprise subscription that covers all
of the open source you use.

Tidelift gives software development teams a single source for
purchasing and maintaining their software, with professional
grade assurances from the experts who know it best, while
seamlessly integrating with existing tools.

`Learn more <Tidelift Subscription_>`_.

.. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-cheroot?utm_source=pypi-cheroot&utm_medium=referral&utm_campaign=readme

.. |tideliftlogo| image:: https://cdn2.hubspot.net/hubfs/4008838/website/logos/logos_for_download/Tidelift_primary-shorthand-logo.png
:target: https://tidelift.com/subscription/pkg/pypi-cheroot?utm_source=pypi-cheroot&utm_medium=readme
:width: 75
:alt: Tidelift

Contribute Cheroot
==================
**Want to add something to upstream?** Feel free to submit a PR or file an issue
if unsure. Please follow `CherryPy's common contribution guidelines
<https://github.com/cherrypy/cherrypy/blob/master/.github/CONTRIBUTING.rst>`_.
Note that PR is more likely to be accepted if it includes tests and detailed
description helping maintainers to understand it better 🎉

Oh, and be pythonic, please 🐍

**Don't know how?** Check out `How to Contribute to Open Source
<https://opensource.guide/how-to-contribute/>`_ article by GitHub 🚀


License
=======
.. image:: https://app.fossa.io/api/projects/git%2Bgithub.com%2Fcherrypy%2Fcheroot.svg?type=large
:target: https://app.fossa.io/projects/git%2Bgithub.com%2Fcherrypy%2Fcheroot?ref=badge_large
:alt: FOSSA Status

Keywords: http,server,ssl,wsgi
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Framework :: CherryPy
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: Jython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Server
Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7
Provides-Extra: docs
Provides-Extra: testing
Loading