From 56e145942a7de07ff3984648310f9dc7ea803be3 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 4 Apr 2022 18:31:15 -0600 Subject: [PATCH] Update generate_object_report() to handle slots --- scripts/wk/debug.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/wk/debug.py b/scripts/wk/debug.py index 437ab0f8..e0fe75bf 100644 --- a/scripts/wk/debug.py +++ b/scripts/wk/debug.py @@ -20,13 +20,20 @@ METHOD_TYPE = type(DEBUG_CLASS.method) def generate_object_report(obj, indent=0): """Generate debug report for obj, returns list.""" report = [] + attr_list = [] + + # Get attribute list + if hasattr(obj, '__slots__'): + attr_list = list(obj.__slots__) + else: + attr_list = [name for name in dir(obj) if not name.startswith('_')] # Dump object data - for name in dir(obj): + for name in attr_list: attr = getattr(obj, name) - # Skip methods and private attributes - if isinstance(attr, METHOD_TYPE) or name.startswith('_'): + # Skip methods + if isinstance(attr, METHOD_TYPE): continue # Add attribute to report (expanded if necessary)