Example #1
0
def get_class_name(cls):
    """Return the name of the class on the C++ side.

    A ValueError is raised if the class was not exposed by Source.Python.
    """
    for name, possible_cls in EXPOSED_CLASSES.items():
        if cls is possible_cls:
            return name

    raise ValueError('Given class was not exposed.')
Example #2
0
def get_class_name(cls):
    """Return the name of a class or class object on the C++ side.

    :param cls: A class or class object.
    :raise ValueError: Raised if the class was not exposed by Source.Python.
    """
    if not inspect.isclass(cls):
        cls = cls.__class__

    for name, possible_cls in EXPOSED_CLASSES.items():
        if cls is possible_cls:
            return name

    for base_class in cls.__bases__:
        try:
            class_name = get_class_name(base_class)
        except ValueError:
            continue
        else:
            return class_name

    raise ValueError('Given class was not exposed.')