Skip to content

Commit b5ab654

Browse files
authored
Don't generate json for hal. (#170)
1 parent c022f56 commit b5ab654

File tree

3 files changed

+53149
-67410
lines changed

3 files changed

+53149
-67410
lines changed

python_tools/generate_json.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
from absl import logging
2525

2626
# robotpy
27-
import hal
28-
import hal.simulation
2927
import ntcore
3028
import pyfrc
3129
import wpilib
@@ -87,8 +85,6 @@ def main(argv):
8785
pathlib.Path(f'{FLAGS.output_directory}/generated/').mkdir(parents=True, exist_ok=True)
8886

8987
robotpy_modules = [
90-
hal,
91-
hal.simulation,
9288
ntcore,
9389
wpilib,
9490
wpilib.counter,

python_tools/json_util.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
import python_util
2626

2727

28+
_LIST_MODULE_NAME_PREFIXES_TO_IGNORE = [
29+
'hal',
30+
'ntcore',
31+
'wpinet',
32+
'wpiutil',
33+
]
34+
2835
_KEY_MODULES = 'modules'
2936
_KEY_CLASSES = 'classes'
3037
_KEY_MODULE_NAME = 'moduleName'
@@ -103,6 +110,13 @@ def getModuleName(m) -> str:
103110
return _DICT_FULL_MODULE_NAME_TO_MODULE_NAME.get(module_name, module_name)
104111

105112

113+
def ignoreModule(module_name: str) -> bool:
114+
for prefix in _LIST_MODULE_NAME_PREFIXES_TO_IGNORE:
115+
if module_name.startswith(prefix):
116+
return True
117+
return False
118+
119+
106120
def getClassName(c, containing_class_name: str = None) -> str:
107121
if inspect.isclass(c):
108122
full_class_name = python_util.getFullClassName(c)
@@ -250,11 +264,7 @@ def _processModules(self):
250264
set_of_modules.add(module)
251265
for module in set_of_modules:
252266
module_name = getModuleName(module)
253-
if module_name.startswith('ntcore'):
254-
continue
255-
if module_name.startswith('wpinet'):
256-
continue
257-
if module_name.startswith('wpiutil'):
267+
if ignoreModule(module_name):
258268
continue
259269
#if not hasattr(module, '__all__'):
260270
# print(f'Skipping module {getModuleName(module)}')
@@ -464,11 +474,7 @@ def _processClasses(self):
464474
if python_util.isEnum(cls):
465475
continue
466476
module_name = getModuleName(cls.__module__)
467-
if module_name.startswith('ntcore'):
468-
continue
469-
if module_name.startswith('wpinet'):
470-
continue
471-
if module_name.startswith('wpiutil'):
477+
if ignoreModule(module_name):
472478
continue
473479
#module = python_util.getModule(module_name)
474480
#if not hasattr(module, '__all__'):

0 commit comments

Comments
 (0)