def meta_interface()

in pystemd/base.py [0:0]


def meta_interface(interface):
    class _MetaInterface(type):
        def __new__(metacls, classname, baseclasses, attrs):
            attrs.update(
                {
                    "__xml_dom": interface,
                    "properties": [],
                    "methods": [],
                    "_properties_xml": {},
                    "_methods_xml": {},
                }
            )

            _call_method = attrs["_call_method"]
            _get_property = attrs["_get_property"]
            _set_property = attrs["_set_property"]
            elements = [n for n in interface.getchildren() if etree.iselement(n)]

            for element in elements:
                if element.tag == "property":
                    property_name = element.attrib.get("name")

                    attrs["properties"].append(property_name)
                    attrs["_properties_xml"][property_name] = element
                    attrs[property_name] = property(
                        _wrap_call_with_name(_get_property, property_name),
                        _wrap_call_with_name(_set_property, property_name),
                    )

                elif element.tag == "method":
                    method_name = element.attrib.get("name")
                    attrs["methods"].append(method_name)
                    attrs["_methods_xml"][method_name] = element

                    attrs[method_name] = _wrap_call_with_name(_call_method, method_name)

                    attrs[method_name].__name__ = method_name

            return type.__new__(metacls, classname, baseclasses, attrs)

    return extend_class_def(SDInterface, _MetaInterface)