Skip to content

Commit a5c2f98

Browse files
committed
Added code to python_tools so it will ignore internal classes and modules when generating json.
Mark block_execution and BlockExecution as internal.
1 parent bfffb90 commit a5c2f98

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

python_tools/json_util.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
'wpiutil',
3333
]
3434

35+
_LIST_MODULE_NAMES_INTERNAL = [
36+
'blocks_base_classes.block_execution',
37+
]
38+
39+
_LIST_CLASS_NAMES_INTERNAL = [
40+
'blocks_base_classes.BlockExecution',
41+
]
42+
3543
_KEY_MODULES = 'modules'
3644
_KEY_CLASSES = 'classes'
3745
_KEY_MODULE_NAME = 'moduleName'
@@ -127,7 +135,12 @@ def _getClassName(self, o, containing_class_name: str = None) -> str:
127135
def _getPublicModules(self) -> list[types.ModuleType]:
128136
public_modules = []
129137
for m in self._modules:
130-
if '._' in python_util.getFullModuleName(m):
138+
module_name = python_util.getFullModuleName(m)
139+
if '._' in module_name:
140+
continue
141+
if module_name in _LIST_MODULE_NAMES_INTERNAL:
142+
print(f'HeyLiz: skipping internal module {module_name}',
143+
file=sys.stderr)
131144
continue
132145
public_modules.append(m)
133146
public_modules.sort(key=lambda m: python_util.getFullModuleName(m))
@@ -262,6 +275,10 @@ def _getPublicClasses(self) -> list[type]:
262275
class_name = self._getClassName(cls)
263276
if '._' in class_name:
264277
continue
278+
if class_name in _LIST_CLASS_NAMES_INTERNAL:
279+
print(f'HeyLiz: skipping internal class {class_name}',
280+
file=sys.stderr)
281+
continue
265282
for base_class in inspect.getmro(cls):
266283
if python_util.isBuiltInClass(base_class):
267284
break

0 commit comments

Comments
 (0)