Skip to content

Commit c43b9e0

Browse files
committed
Failed attempt to adapt this script to latest pyside
1 parent 993b322 commit c43b9e0

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

scripts/collect_public_variables.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66

77
JSON_OUTPUT_FNAME = pathlib.Path(__file__).parent / 'public-variables.json'
88

9-
RESERVED_KEYWORDS = ['from']
9+
RESERVED_KEYWORDS = [
10+
'from',
11+
'QRhiResource',
12+
'QRhiTexture',
13+
'QRhiBuffer',
14+
'QRhiSampler',
15+
'QRhiShaderResourceBinding',
16+
'QTimeZone',
17+
]
1018

1119
def collect_public_variables_for_module(module_name: str, d: Dict[str, str]) -> None:
1220
'''Load module, inspect all attribute types and fill dict with information'''
@@ -21,24 +29,29 @@ def collect_public_variables_for_module(module_name: str, d: Dict[str, str]) ->
2129
# platform-specific modules can not be imported for example on other platforms
2230
return
2331

24-
for class_name, class_type in m.__dict__.items():
32+
module_attributes = set(dir(m)) | set(m.__dict__.keys())
33+
for class_name in module_attributes:
2534
if class_name.startswith('_'):
2635
continue
2736

2837
if class_name in RESERVED_KEYWORDS:
2938
continue
3039

40+
class_type = getattr(m, class_name)
41+
print(f'collecting {module_name}.{class_name}')
3142
collect_public_variables_for_class(f'{module_name}.{class_name}', class_type, d)
3243

3344

3445
def collect_public_variables_for_class(class_fqn: str, class_type: Type, d: Dict[str, str]) -> None:
3546
# we only care about classes
47+
#print(f'trying to access {class_fqn}.__dict__ for {type(class_type)}')
3648
try:
3749
class_members = class_type.__dict__.items()
3850
except AttributeError:
3951
# this is not a class
4052
return
4153

54+
#print(f'Iterating class members of {class_fqn}')
4255
instance = None
4356
for class_attr_name, class_attr_value in class_members:
4457
if class_attr_name.startswith('_'):
@@ -47,7 +60,7 @@ def collect_public_variables_for_class(class_fqn: str, class_type: Type, d: Dict
4760
if class_attr_name in RESERVED_KEYWORDS:
4861
continue
4962

50-
if class_attr_value.__class__.__name__ == 'getset_descriptor':
63+
if class_attr_value.__class__.__name__ in ('getset_descriptor', 'method_descriptor'):
5164

5265
# create the instance on-demand
5366
if instance is None:
@@ -79,7 +92,7 @@ def collect_public_variables_for_class(class_fqn: str, class_type: Type, d: Dict
7992
def main():
8093
application = QApplication(['-platform', 'minimal']) # needed for instancing QWidgets
8194
d = {}
82-
for fpath in (pathlib.Path(__file__).parent.parent / 'PySide6-stubs').glob('*.pyi'):
95+
for fpath in (pathlib.Path(__file__).parent.parent / 'PySide6-stubs').glob('QtNfc.pyi'):
8396
module_name = fpath.stem
8497
collect_public_variables_for_module(module_name, d)
8598

0 commit comments

Comments
 (0)