1 # Copyright © 2009- The Spyder Development Team
2 # Copyright © 2012- University of North Carolina at Chapel Hill
3 # Luke Campagnola ('luke.campagnola@%s.com' % 'gmail')
4 # Ogi Moore ('ognyan.moore@%s.com' % 'gmail')
5 # KIU Shueng Chuan ('nixchuan@%s.com' % 'gmail')
6 # Licensed under the terms of the MIT License
9 Compatibility functions for scoped and unscoped enum access.
19 def promote_enums(module
):
21 Search enums in the given module and allow unscoped access.
24 https://github.com/pyqtgraph/pyqtgraph/blob/pyqtgraph-0.12.1/pyqtgraph/Qt.py#L331-L377
25 and adapted to also copy enum values aliased under different names.
28 class_names
= [name
for name
in dir(module
) if name
.startswith("Q")]
29 for class_name
in class_names
:
30 klass
= getattr(module
, class_name
)
31 if not isinstance(klass
, sip
.wrappertype
):
33 attrib_names
= [name
for name
in dir(klass
) if name
[0].isupper()]
34 for attrib_name
in attrib_names
:
35 attrib
= getattr(klass
, attrib_name
)
36 if not isinstance(attrib
, enum
.EnumMeta
):
38 for name
, value
in attrib
.__members
__.items():
39 setattr(klass
, name
, value
)