in src/dfcx_scrapi/core/scrapi_base.py [0:0]
def get_api_calls_details(self) -> Dict[str, int]:
"""The number of API calls corresponding to each method.
Returns:
A dictionary with keys as the method names
and values as the number of calls.
"""
this_class_methods, sub_class_apis_dict = {}, {}
for attr_name in dir(self):
attr = getattr(self, attr_name)
if callable(attr) and hasattr(attr, "calls_api"):
this_class_methods[attr_name] = 0
if any(
isinstance(attr, sub_class)
for sub_class in ScrapiBase.__subclasses__()
):
sub_class_apis_dict.update(attr.get_api_calls_details())
if hasattr(self, "api_calls_dict"):
this_class_methods.update(getattr(self, "api_calls_dict"))
return {**this_class_methods, **sub_class_apis_dict}