/opt/imh-python/lib/python3.9/site-packages/cherrypy
NameSizeModeActions
lib/-0755rm
process/-0755rm
scaffold/-0755rm
test/-0755rm
tutorial/-0755rm
__pycache__/-0755rm
daemon.py39500644editdlrm
favicon.ico14060644editdlrm
_cpchecker.py145660644editdlrm
_cpcompat.py19920644editdlrm
_cpconfig.py96470644editdlrm
_cpdispatch.py253920644editdlrm
_cperror.py230700644editdlrm
_cplogging.py164020644editdlrm
_cpmodpy.py111410644editdlrm
_cpnative_server.py66770644editdlrm
_cpreqbody.py363820644editdlrm
_cprequest.py343130644editdlrm
_cpserver.py83200644editdlrm
_cptools.py181630644editdlrm
_cptree.py109770644editdlrm
_cpwsgi.py163940644editdlrm
_cpwsgi_server.py41870644editdlrm
_helper.py116530644editdlrm
_json.py4400644editdlrm
__init__.py112850644editdlrm
__main__.py1070644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/cherrypy/_cpcompat.py (1992B)
"""Compatibility code for using CherryPy with various versions of Python. To retain compatibility with older Python versions, this module provides a useful abstraction over the differences between Python versions, sometimes by preferring a newer idiom, sometimes an older one, and sometimes a custom one. In particular, Python 2 uses str and '' for byte strings, while Python 3 uses str and '' for unicode strings. We will call each of these the 'native string' type for each version. Because of this major difference, this module provides two functions: 'ntob', which translates native strings (of type 'str') into byte strings regardless of Python version, and 'ntou', which translates native strings to unicode strings. Try not to use the compatibility functions 'ntob', 'ntou', 'tonative'. They were created with Python 2.3-2.5 compatibility in mind. Instead, use unicode literals (from __future__) and bytes literals and their .encode/.decode methods as needed. """ import http.client def ntob(n, encoding='ISO-8859-1'): """Return the given native string as a byte string in the given encoding. """ assert_native(n) # In Python 3, the native string type is unicode return n.encode(encoding) def ntou(n, encoding='ISO-8859-1'): """Return the given native string as a unicode string with the given encoding. """ assert_native(n) # In Python 3, the native string type is unicode return n def tonative(n, encoding='ISO-8859-1'): """Return the given string as a native string in the given encoding.""" # In Python 3, the native string type is unicode if isinstance(n, bytes): return n.decode(encoding) return n def assert_native(n): if not isinstance(n, str): raise TypeError('n must be a native str (got %s)' % type(n).__name__) # Some platforms don't expose HTTPSConnection, so handle it separately HTTPSConnection = getattr(http.client, 'HTTPSConnection', None) text_or_bytes = str, bytes