Changeset View
Changeset View
Standalone View
Standalone View
swh/core/api/__init__.py
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | def __new__(cls, name, bases, attributes): | ||||
if backend_class: | if backend_class: | ||||
for (meth_name, meth) in backend_class.__dict__.items(): | for (meth_name, meth) in backend_class.__dict__.items(): | ||||
if hasattr(meth, '_endpoint_path'): | if hasattr(meth, '_endpoint_path'): | ||||
cls.__add_endpoint(meth_name, meth, attributes) | cls.__add_endpoint(meth_name, meth, attributes) | ||||
return super().__new__(cls, name, bases, attributes) | return super().__new__(cls, name, bases, attributes) | ||||
@staticmethod | @staticmethod | ||||
def __add_endpoint(meth_name, meth, attributes): | def __add_endpoint(meth_name, meth, attributes): | ||||
if meth_name in attributes: | |||||
# Overridden by the class | |||||
return | |||||
wrapped_meth = inspect.unwrap(meth) | wrapped_meth = inspect.unwrap(meth) | ||||
@functools.wraps(meth) # Copy signature and doc | @functools.wraps(meth) # Copy signature and doc | ||||
def meth_(*args, **kwargs): | def meth_(*args, **kwargs): | ||||
# Match arguments and parameters | # Match arguments and parameters | ||||
post_data = inspect.getcallargs( | post_data = inspect.getcallargs( | ||||
wrapped_meth, *args, **kwargs) | wrapped_meth, *args, **kwargs) | ||||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |