diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2017-12-17 11:13:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-17 11:13:53 -0500 |
| commit | 951489bcf1d0db047d53b303b6b077272a8245d2 (patch) | |
| tree | 2a3dab8ea85a6e0760dbf2a3b83d8902595190b2 /cherrypy | |
| parent | 0056e389c1de55d4096a18826f0804c05d048c53 (diff) | |
| parent | 3b38b61d96d0c65c05637b53b82fe5b81e7175be (diff) | |
| download | cherrypy-git-13.0.1.tar.gz | |
Merge pull request #1671 from benjaoming/bug/internalize-jaraco-classesv13.0.1
Internalize jaraco.classes code to replace dependency
Diffstat (limited to 'cherrypy')
| -rw-r--r-- | cherrypy/_cperror.py | 3 | ||||
| -rw-r--r-- | cherrypy/_helper.py | 31 |
2 files changed, 32 insertions, 2 deletions
diff --git a/cherrypy/_cperror.py b/cherrypy/_cperror.py index ab1cc70f..1e6214c0 100644 --- a/cherrypy/_cperror.py +++ b/cherrypy/_cperror.py @@ -125,12 +125,11 @@ from xml.sax import saxutils import six from six.moves import urllib -from jaraco.classes.properties import classproperty - import cherrypy from cherrypy._cpcompat import escape_html from cherrypy._cpcompat import text_or_bytes, ntob from cherrypy._cpcompat import tonative +from cherrypy._helper import classproperty from cherrypy.lib import httputil as _httputil diff --git a/cherrypy/_helper.py b/cherrypy/_helper.py index 505c4bc9..a0ab68fe 100644 --- a/cherrypy/_helper.py +++ b/cherrypy/_helper.py @@ -308,3 +308,34 @@ def normalize_path(path): newpath = '/' + newpath return newpath + + +#### +# Inlined from jaraco.classes 1.4.3 +# Ref #1673 +class _ClassPropertyDescriptor(object): + """Descript for read-only class-based property. + + Turns a classmethod-decorated func into a read-only property of that class + type (means the value cannot be set). + """ + + def __init__(self, fget, fset=None): + """Instantiated by ``_helper.classproperty``.""" + self.fget = fget + self.fset = fset + + def __get__(self, obj, klass=None): + """Return property value.""" + if klass is None: + klass = type(obj) + return self.fget.__get__(obj, klass)() + + +def classproperty(func): + """Decorator like classmethod to implement a static class property.""" + if not isinstance(func, (classmethod, staticmethod)): + func = classmethod(func) + + return _ClassPropertyDescriptor(func) +#### |
