def initialize_registry(self): self.parent.log.debug("Registering wrappers.") from vapoursynth import VideoNode, VideoFrame from yuuno.vs.clip import VapourSynthClip, VapourSynthFrame from yuuno.vs.clip import VapourSynthAlphaClip # Detected VSScript. wrapperfunc = lambda cls, wrapper=None: cls if self.script_manager is not None and self.vsscript_environment_wrap: wrapperfunc = self.script_manager.env_wrapper_for self.registry = Registry() self.registry.register(wrapperfunc(VapourSynthClip), VideoNode) self.registry.register(wrapperfunc(VapourSynthFrame), VideoFrame) self.registry.register(wrapperfunc(VapourSynthAlphaClip), AlphaOutputClip) if Features.SUPPORT_ALPHA_OUTPUT_TUPLE: # Required so that IPython automatically supports alpha outputs from vapoursynth import AlphaOutputTuple self.registry.register(wrapperfunc(VapourSynthAlphaClip), AlphaOutputTuple) if Features.API4: from vapoursynth import VideoOutputTuple, AudioNode from yuuno.vs.clip import VapourSynthAudio from yuuno.vs.policy.clip import WrappedAudio self.registry.register(wrapperfunc(VapourSynthAlphaClip), VideoOutputTuple) self.registry.register( wrapperfunc(VapourSynthAudio, wrapper=WrappedAudio), AudioNode) self.parent.registry.add_subregistry(self.registry)
def test_006_all_types(self): class TestClip(Clip): pass class T1(object): pass class T2(object): pass class TS1(object): pass class TS2(object): pass sr = Registry() sr.register(TestClip, TS1) sr.register(TestClip, TS2) self.registry.register(TestClip, T1) self.registry.register(TestClip, T2) self.assertEqual(list(self.registry.all_types()), [T1, T2]) self.registry.add_subregistry(sr) self.assertEqual(list(self.registry.all_types()), [T1, T2, TS1, TS2]) self.registry.remove_subregistry(sr) self.assertEqual(list(self.registry.all_types()), [T1, T2])
def test_005_subregistry(self): class TestClip(Clip): pass subreg = Registry() subreg.register(TestClip, list) self.registry.add_subregistry(subreg) self.assertIs(self.registry.get_clip_type_for([]), TestClip) self.registry.remove_subregistry(subreg) self.assertIsNone(self.registry.get_clip_type_for([]))
def setUp(self): self.registry = Registry()