Пример #1
0
def get_sorted_scene_classes(module_name):
    module = get_module(module_name)
    importlib.import_module(module.__name__)
    line_to_scene = {}
    name_scene_list = inspect.getmembers(
        module, lambda obj: is_child_scene(obj, module))
    for name, scene_class in name_scene_list:
        if inspect.getmodule(scene_class).__name__ != module.__name__:
            continue
        lines, line_no = inspect.getsourcelines(scene_class)
        line_to_scene[line_no] = scene_class
    return [line_to_scene[index] for index in sorted(line_to_scene.keys())]
Пример #2
0
def get_sorted_scene_classes(module_name):
    module = get_module(module_name)
    if hasattr(module, "ALL_SCENE_CLASSES"):
        return module.ALL_SCENE_CLASSES
    # Otherwise, deduce from the order in which
    # they're defined in a file
    importlib.import_module(module.__name__)
    line_to_scene = {}
    name_scene_list = inspect.getmembers(
        module, lambda obj: is_child_scene(obj, module))
    for name, scene_class in name_scene_list:
        if inspect.getmodule(scene_class).__name__ != module.__name__:
            continue
        lines, line_no = inspect.getsourcelines(scene_class)
        line_to_scene[line_no] = scene_class
    return [line_to_scene[index] for index in sorted(line_to_scene.keys())]
Пример #3
0
def get_sorted_scene_classes(module_name):
    module = get_module(module_name)
    if hasattr(module, "SCENES_IN_ORDER"):
        return module.SCENES_IN_ORDER
    # Otherwise, deduce from the order in which
    # they're defined in a file
    importlib.import_module(module.__name__)
    line_to_scene = {}
    name_scene_list = inspect.getmembers(
        module,
        lambda obj: is_child_scene(obj, module)
    )
    for name, scene_class in name_scene_list:
        if inspect.getmodule(scene_class).__name__ != module.__name__:
            continue
        lines, line_no = inspect.getsourcelines(scene_class)
        line_to_scene[line_no] = scene_class
    return [
        line_to_scene[index]
        for index in sorted(line_to_scene.keys())
    ]