1
2
4 """An interface, for so far as Python supports it. To add support for a
5 flipbook this needs to be subclassed and the 3 methods implemented. The
6 default implementation just raises an exception so any sub implementer
7 will soon find out whether his implementation works."""
10
12 """ Return the name of the flipbook.
13 @return: String"""
14 raise NotImplementedError
15
17 """Return the executable path required to run a flipbook.
18 @return: String"""
19 raise NotImplementedError
20
22 """Return the preferred directory for rendering.
23 @return: String"""
24 raise NotImplementedError
25
26 - def run(self, path, frameRanges, views, options):
27 """Execute the flipbook on a path.
28 @param path: The path to run the flipbook on. This will be similar to /path/to/foo%03d.exr
29 @param frameRanges: A FrameRanges object representing the range that should be flipbooked. Note that in 6.2v1-2 this was a FrameRange object.
30 @param views: A list of strings comprising of the views to flipbook. Willnot be more than the maximum supported by the flipbook.
31 @param options: A dictionary of options to use. This may contain the keys pixelAspect, roi, dimensions, audio and lut. These contain a float, a dict with bounding box dimensions, a dict with width and height, a path to audio file and a string indicating the LUT conversion to apply.
32 @return: None"""
33 raise NotImplementedError
34
36 """Return the capabilities of the flipbook application. Currently used are:
37 proxyScale: bool, whether the flipbook supports proxies
38 crop: bool, whether the flipbook supports crops
39 canPreLaunch: bool, whether the flipbook can display a frames that are still being rendered by Nuke.
40 maximumViews: int, the number of views supported by this flipbook, should be 1 or higher.
41 fileTypes: list, the extensions of the file types supported by this format. Must all be lowercase, e.g ["exr", "jpg", ...]
42 @return: dict with the capabilities above."""
43 raise NotImplementedError
44
47 self._flipbookApplications = {}
48
50 """ Return whether a flipbook app with that name has already been registered.
51 @param flipbook: FlipBookApplication object that's tested for.
52 @return: bool"""
53 return self._flipbookApplications.has_key(flipbook.name())
54
55 - def register(self, flipbookApplication):
56 """Register a flipbook app. It will fail if the flipbook app name isn't unique.
57 @param flipbook: FlipBookApplication object to register
58 @return: None"""
59 if not self.isRegistered(flipbookApplication):
60 self._flipbookApplications[flipbookApplication.name()] = flipbookApplication
61 else:
62 raise RuntimeError("Already registered a flipbook application with this name")
63
65 """Returns a list of the names of all available flipbook apps.
66 @return: list"""
67 return self._flipbookApplications.keys()
68
70 """Returns the flipbook app implementation with the given name, raises an exception if none could be found.
71 @param name: The name of a flipbook that was registered.
72 @return: FlipBookApplication"""
73 if self._flipbookApplications.has_key(name):
74 return self._flipbookApplications[name]
75 else:
76 raise RuntimeError("Requested flipbook not registered")
77
79 """A registery of all LUT files against LUTs for each specific flipbook."""
82
84 """Register the given LUT file.
85 @param flipbook: The unique name of the flipbook
86 @param lut: The unique name for the LUT, e.g. 'sRGB' and 'rec709'
87 @param path: Location of the flipbook specific file."""
88 if not self._luts.has_key(flipbook):
89 self._luts[flipbook] = {}
90 self._luts[flipbook][lut] = path
91
93 """Return the path for the given flipbook and lut. May return an empty string if none registered.
94 @param flipbook: The unique name of the flipbook
95 @param lut: The unique name for the LUT, e.g. 'sRGB' and 'rec709'"""
96 return self._luts.get(flipbook, {}).get(lut, "")
97
98
99 gFlipbookFactory = FlipbookFactory()
100
101 gFlipbookLUTPathRegistry = FlipbookLUTPathRegistry()
102
103
105 """Register a flipbook. Convenience function that simple calls register() on the FlipbookFactory."""
106 gFlipbookFactory.register(flipbookApplication)
107
109 """Register a LUT for a specific flipbook. The path should refer to a file that contains the LUT for the given flipbook identified by the name in flipbookApplication. It is up to the flipbook subimplementation to actually use this file and the format may vary.
110 @param flipbook: The unique name of the flipbook
111 @param lut: The unique name for the LUT, e.g. 'sRGB' and 'rec709'
112 @param path: Location of the flipbook specific file."""
113 gFlipbookLUTPathRegistry.registerLUTPathForFlipbook(flipbookApplication, lut, path)
114
116 """Returns a path to a LUT file for the given flipbook. The contents of the file will be different for each flipbook application. Please see the relevant documentation for the specific flipbook applications.
117 @param flipbook: The unique name of the flipbook
118 @param lut: The unique name for the LUT, e.g. 'sRGB' and 'rec709'"""
119 return gFlipbookLUTPathRegistry.getLUTPathForFlipbook(flipbookAppliction, lut)
120