/usr/lib/python3/dist-packages/postgresql/python/decorlib.py is in python3-postgresql 1.1.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ##
# .python.decorlib
##
"""
common decorators
"""
import os
import types
def propertydoc(ap):
"""
Helper function for extracting an `abstractproperty`'s real documentation.
"""
doc = ""
rstr = ""
if ap.fget:
ret = ap.fget.__annotations__.get('return')
if ret is not None:
rstr = " -> " + repr(ret)
if ap.fget.__doc__:
doc += os.linesep*2 + "GET::" + (os.linesep + ' '*4) + (os.linesep + ' '*4).join(
[x.strip() for x in ap.fget.__doc__.strip().split(os.linesep)]
)
if ap.fset and ap.fset.__doc__:
doc += os.linesep*2 + "SET::" + (os.linesep + ' '*4) + (os.linesep + ' '*4).join(
[x.strip() for x in ap.fset.__doc__.strip().split(os.linesep)]
)
if ap.fdel and ap.fdel.__doc__:
doc += os.linesep*2 + "DELETE::" + (os.linesep + ' '*4) + (os.linesep + ' '*4).join(
[x.strip() for x in ap.fdel.__doc__.strip().split(os.linesep)]
)
ap.__doc__ = "<no documentation>" if not doc else (
"Abstract Property" + rstr + doc
)
return ap
class method(object):
__slots__ = ('callable',)
def __init__(self, callable):
self.callable = callable
def __get__(self, val, typ):
if val is None:
return self.callable
return types.MethodType(self.callable, val)
|