From 1f6e648af71fe0649f971c33f3624b1d5a780214 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Thu, 15 Jan 2015 21:00:26 +0100 Subject: [PATCH] Add docstrings skeletons. --- .../python/aces_ocio/createARRIColorSpaces.py | 34 ++- .../python/aces_ocio/createCanonColorSpaces.py | 35 ++- .../python/aces_ocio/createREDColorSpaces.py | 35 ++- .../python/aces_ocio/createSonyColorSpaces.py | 34 ++- aces_1.0.0/python/aces_ocio/create_aces_config.py | 235 +++++++++++++--- aces_1.0.0/python/aces_ocio/generateLUT.py | 163 ++++++++++- aces_1.0.0/python/aces_ocio/process.py | 288 +++++++++++++++++--- .../python/aces_ocio/tests/tests_aces_config.py | 27 +- aces_1.0.0/python/aces_ocio/util.py | 55 +++- 9 files changed, 803 insertions(+), 103 deletions(-) diff --git a/aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py b/aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py index 681e975..d7d195f 100644 --- a/aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py +++ b/aces_1.0.0/python/aces_ocio/createARRIColorSpaces.py @@ -18,15 +18,29 @@ __status__ = 'Production' __all__ = ['createLogC', 'createColorSpaces'] -# -# LogC to ACES -# + def createLogC(gamut, transferFunction, exposureIndex, name, lutDir, lutResolution1d): + """ + Object description. + + LogC to ACES. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + name = "%s (EI%s) - %s" % (transferFunction, exposureIndex, gamut) if transferFunction == "": name = "Linear - %s" % gamut @@ -140,6 +154,20 @@ def createLogC(gamut, def createColorSpaces(lutDir, lutResolution1d): + """ + Generates the colorspace conversions. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + colorspaces = [] transferFunction = "V3 LogC" diff --git a/aces_1.0.0/python/aces_ocio/createCanonColorSpaces.py b/aces_1.0.0/python/aces_ocio/createCanonColorSpaces.py index aa3ee40..9b8d92c 100644 --- a/aces_1.0.0/python/aces_ocio/createCanonColorSpaces.py +++ b/aces_1.0.0/python/aces_ocio/createCanonColorSpaces.py @@ -16,10 +16,24 @@ __status__ = 'Production' __all__ = ['createCanonLog', 'createColorSpaces'] -# -# Canon-Log to ACES -# + def createCanonLog(gamut, transferFunction, name, lutDir, lutResolution1d): + """ + Object description. + + Canon-Log to ACES. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + name = "%s - %s" % (transferFunction, gamut) if transferFunction == "": name = "Linear - %s" % gamut @@ -128,8 +142,21 @@ def createCanonLog(gamut, transferFunction, name, lutDir, lutResolution1d): return cs -# Generate all color spaces conversion def createColorSpaces(lutDir, lutResolution1d): + """ + Generates the colorspace conversions. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + colorspaces = [] # Full conversion diff --git a/aces_1.0.0/python/aces_ocio/createREDColorSpaces.py b/aces_1.0.0/python/aces_ocio/createREDColorSpaces.py index 46cbd7f..74d375f 100644 --- a/aces_1.0.0/python/aces_ocio/createREDColorSpaces.py +++ b/aces_1.0.0/python/aces_ocio/createREDColorSpaces.py @@ -16,10 +16,24 @@ __status__ = 'Production' __all__ = ['createREDlogFilm', 'createColorSpaces'] -# -# RED color spaces to ACES -# + def createREDlogFilm(gamut, transferFunction, name, lutDir, lutResolution1d): + """ + Object description. + + RED colorspaces to ACES. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + name = "%s - %s" % (transferFunction, gamut) if transferFunction == "": name = "Linear - %s" % gamut @@ -112,8 +126,21 @@ def createREDlogFilm(gamut, transferFunction, name, lutDir, lutResolution1d): return cs -# Generate all color spaces conversion def createColorSpaces(lutDir, lutResolution1d): + """ + Generates the colorspace conversions. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + colorspaces = [] # Full conversion diff --git a/aces_1.0.0/python/aces_ocio/createSonyColorSpaces.py b/aces_1.0.0/python/aces_ocio/createSonyColorSpaces.py index 604777c..a7eaef1 100644 --- a/aces_1.0.0/python/aces_ocio/createSonyColorSpaces.py +++ b/aces_1.0.0/python/aces_ocio/createSonyColorSpaces.py @@ -16,10 +16,24 @@ __status__ = 'Production' __all__ = ['createSlog', 'createColorSpaces'] -# -# SLog to ACES -# + def createSlog(gamut, transferFunction, name, lutDir, lutResolution1d): + """ + Object description. + + SLog to ACES. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + name = "%s - %s" % (transferFunction, gamut) if transferFunction == "": name = "Linear - %s" % gamut @@ -190,6 +204,20 @@ def createSlog(gamut, transferFunction, name, lutDir, lutResolution1d): def createColorSpaces(lutDir, lutResolution1d): + """ + Generates the colorspace conversions. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + colorspaces = [] # SLog1 diff --git a/aces_1.0.0/python/aces_ocio/create_aces_config.py b/aces_1.0.0/python/aces_ocio/create_aces_config.py index aa004b2..49943bf 100755 --- a/aces_1.0.0/python/aces_ocio/create_aces_config.py +++ b/aces_1.0.0/python/aces_ocio/create_aces_config.py @@ -2,18 +2,18 @@ # -*- coding: utf-8 -*- """ -usage from python +usage from python: -import sys -sys.path.append("/path/to/script") -import create_aces_config as cac -acesReleaseCTLDir = "/path/to/github/checkout/releases/v0.7.1/transforms/ctl" -configDir = "/path/to/config/dir" -cac.createACESConfig(acesReleaseCTLDir, configDir, 1024, 33, True) +>>> import sys +>>> sys.path.append("/path/to/script") +>>> import create_aces_config as cac +>>> acesReleaseCTLDir = "/path/to/github/checkout/releases/v0.7.1/transforms/ctl" +>>> configDir = "/path/to/config/dir" +>>> cac.createACESConfig(acesReleaseCTLDir, configDir, 1024, 33, True) -usage from command line, from the directory with 'create_aces_config.py' -python create_aces_config.py -a "/path/to/github/checkout/releases/v0.7.1/transforms/ctl" -c "/path/to/config/dir" --lutResolution1d 1024 --lutResolution3d 33 --keepTempImages +usage from command line, from the directory with 'create_aces_config.py': +$ python create_aces_config.py -a "/path/to/github/checkout/releases/v0.7.1/transforms/ctl" -c "/path/to/config/dir" --lutResolution1d 1024 --lutResolution3d 33 --keepTempImages build instructions for osx for needed packages. @@ -86,9 +86,7 @@ __all__ = ['ACES_OCIO_CTL_DIRECTORY_ENVIRON', ACES_OCIO_CTL_DIRECTORY_ENVIRON = 'ACES_OCIO_CTL_DIRECTORY' ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON = 'ACES_OCIO_CONFIGURATION_DIRECTORY' -# -# Utility functions -# + def setConfigDefaultRoles(config, color_picking="", color_timing="", @@ -99,7 +97,38 @@ def setConfigDefaultRoles(config, reference="", scene_linear="", texture_paint=""): - # Add Roles + """ + Sets given *OCIO* configuration default roles. + + Parameters + ---------- + config : config + *OCIO* configuration. + color_picking : str or unicode + Color picking role title. + color_timing : str or unicode + Color timing role title. + compositing_log : str or unicode + Compositing log role title. + data : str or unicode + Data role title. + default : str or unicode + Default role title. + matte_paint : str or unicode + Matte painting role title. + reference : str or unicode + Reference role title. + scene_linear : str or unicode + Scene linear role title. + texture_paint : str or unicode + Texture painting role title. + + Returns + ------- + bool + Definition success. + """ + if color_picking: config.setRole(OCIO.Constants.ROLE_COLOR_PICKING, color_picking) if color_timing: @@ -119,9 +148,24 @@ def setConfigDefaultRoles(config, if texture_paint: config.setRole(OCIO.Constants.ROLE_TEXTURE_PAINT, texture_paint) + return True + -# Write config to disk def writeConfig(config, configPath, sanityCheck=True): + """ + Writes the configuration to given path. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + if sanityCheck: try: config.sanityCheck() @@ -137,6 +181,20 @@ def writeConfig(config, configPath, sanityCheck=True): def generateOCIOTransform(transforms): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # print("Generating transforms") interpolationOptions = { @@ -200,6 +258,20 @@ def generateOCIOTransform(transforms): def createConfig(configData, nuke=False): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # Create the config config = OCIO.Config() @@ -326,13 +398,6 @@ def createConfig(configData, nuke=False): return config -# -# Functions to generate color space definitions and LUTs for transforms for a -# specific ACES release. -# - -# Output is a list of colorspaces and transforms that convert between those -# colorspaces and reference color space, ACES def generateLUTs(odtInfo, lmtInfo, shaperName, @@ -341,6 +406,21 @@ def generateLUTs(odtInfo, lutResolution1d=4096, lutResolution3d=64, cleanup=True): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + dict + Colorspaces and transforms converting between those colorspaces and + the reference colorspace, *ACES*. + """ + print("generateLUTs - begin") configData = {} @@ -1279,6 +1359,20 @@ def generateBakedLUTs(odtInfo, lutResolution1d, lutResolution3d, lutResolutionShaper=1024): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # Add the legal and full variations into this list odtInfoC = dict(odtInfo) for odtCTLName, odtValues in odtInfo.iteritems(): @@ -1369,6 +1463,20 @@ def generateBakedLUTs(odtInfo, def createConfigDir(configDir, bakeSecondaryLUTs): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + dirs = [configDir, "%s/luts" % configDir] if bakeSecondaryLUTs: dirs.extend(["%s/baked" % configDir, @@ -1384,6 +1492,20 @@ def createConfigDir(configDir, bakeSecondaryLUTs): def getTransformInfo(ctlTransform): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + fp = open(ctlTransform, 'rb') # Read lines @@ -1404,8 +1526,23 @@ def getTransformInfo(ctlTransform): return transformID, transformUserName, transformUserNamePrefix -# For versions after WGR9 def getODTInfo(acesCTLReleaseDir): + """ + Object description. + + For versions after WGR9. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # Credit to Alex Fry for the original approach here odtDir = os.path.join(acesCTLReleaseDir, "odt") allodt = [] @@ -1478,8 +1615,23 @@ def getODTInfo(acesCTLReleaseDir): return odts -# For versions after WGR9 def getLMTInfo(acesCTLReleaseDir): + """ + Object description. + + For versions after WGR9. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # Credit to Alex Fry for the original approach here lmtDir = os.path.join(acesCTLReleaseDir, "lmt") alllmt = [] @@ -1553,15 +1705,26 @@ def getLMTInfo(acesCTLReleaseDir): return lmts -# -# Create the ACES config -# def createACESConfig(acesCTLReleaseDir, configDir, lutResolution1d=4096, lutResolution3d=64, bakeSecondaryLUTs=True, cleanup=True): + """ + Creates the ACES configuration. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # Get ODT names and CTL paths odtInfo = getODTInfo(acesCTLReleaseDir) @@ -1613,10 +1776,21 @@ def createACESConfig(acesCTLReleaseDir, return True -# -# Main -# def main(): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + import optparse p = optparse.OptionParser(description='An OCIO config generation script', @@ -1636,7 +1810,7 @@ def main(): # # Get options - # + # acesCTLDir = options.acesCTLDir configDir = options.configDir lutResolution1d = int(options.lutResolution1d) @@ -1670,7 +1844,6 @@ def main(): bakeSecondaryLUTs, cleanupTempImages) -# main if __name__ == '__main__': main() diff --git a/aces_1.0.0/python/aces_ocio/generateLUT.py b/aces_1.0.0/python/aces_ocio/generateLUT.py index e9e7718..8e420aa 100644 --- a/aces_1.0.0/python/aces_ocio/generateLUT.py +++ b/aces_1.0.0/python/aces_ocio/generateLUT.py @@ -52,13 +52,25 @@ __all__ = ['generate1dLUTImage', 'generate3dLUTFromCTL', 'main'] -# -# Functions used to generate LUTs using CTL transforms -# + def generate1dLUTImage(ramp1dPath, resolution=1024, minValue=0.0, maxValue=1.0): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # print("Generate 1d LUT image - %s" % ramp1dPath) # open image @@ -87,9 +99,24 @@ def generate1dLUTImage(ramp1dPath, ramp.close() -# Credit to Alex Fry for the original single channel version of the spi1d -# writer def writeSPI1D(filename, fromMin, fromMax, data, entries, channels): + """ + Object description. + + Credit to *Alex Fry* for the original single channel version of the spi1d + writer. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + f = file(filename, 'w') f.write("Version 1\n") f.write("From %f %f\n" % (fromMin, fromMax)) @@ -109,6 +136,20 @@ def generate1dLUTFromImage(ramp1dPath, outputPath=None, minValue=0.0, maxValue=1.0): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + if outputPath == None: outputPath = ramp1dPath + ".spi1d" @@ -132,6 +173,20 @@ def generate1dLUTFromImage(ramp1dPath, def generate3dLUTImage(ramp3dPath, resolution=32): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + args = ["--generate", "--cubesize", str(resolution), @@ -146,6 +201,20 @@ def generate3dLUTImage(ramp3dPath, resolution=32): def generate3dLUTFromImage(ramp3dPath, outputPath=None, resolution=32): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + if outputPath == None: outputPath = ramp3dPath + ".spi3d" @@ -171,6 +240,20 @@ def applyCTLToImage(inputImage, outputScale=1.0, globalParams={}, acesCTLReleaseDir=None): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + if len(ctlPaths) > 0: ctlenv = os.environ if acesCTLReleaseDir != None: @@ -203,6 +286,20 @@ def applyCTLToImage(inputImage, def convertBitDepth(inputImage, outputImage, depth): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + args = [inputImage, "-d", depth, @@ -225,6 +322,20 @@ def generate1dLUTFromCTL(lutPath, acesCTLReleaseDir=None, minValue=0.0, maxValue=1.0): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # print(lutPath) # print(ctlPaths) @@ -263,6 +374,20 @@ def generate1dLUTFromCTL(lutPath, def correctLUTImage(transformedLUTImage, correctedLUTImage, lutResolution): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # open image transformed = oiio.ImageInput.open(transformedLUTImage) @@ -337,6 +462,20 @@ def generate3dLUTFromCTL(lutPath, globalParams={}, cleanup=True, acesCTLReleaseDir=None): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + # print(lutPath) # print(ctlPaths) @@ -380,6 +519,20 @@ def generate3dLUTFromCTL(lutPath, def main(): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + import optparse p = optparse.OptionParser( diff --git a/aces_1.0.0/python/aces_ocio/process.py b/aces_1.0.0/python/aces_ocio/process.py index 7660c15..1a3506b 100755 --- a/aces_1.0.0/python/aces_ocio/process.py +++ b/aces_1.0.0/python/aces_ocio/process.py @@ -25,6 +25,20 @@ __all__ = ['readText', def readText(textFile): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + if (textFile != ""): fp = open(textFile, 'rb') # Create a text/plain message @@ -33,9 +47,21 @@ def readText(textFile): return text -# readText - def writeText(text, textFile): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + if (textFile != ""): fp = open(textFile, 'wb') # Create a text/plain message @@ -44,11 +70,9 @@ def writeText(text, textFile): return text -# readText - class Process: """ - A process with logged output + A process with logged output. """ def __init__(self, @@ -58,7 +82,20 @@ class Process: cwd=None, env=None, batchWrapper=False): - """Initialize the standard class variables""" + """ + Initialize the standard class variables. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + self.cmd = cmd if not description: self.description = cmd @@ -75,9 +112,21 @@ class Process: self.batchWrapper = batchWrapper self.processKeys = [] - # __init__ - def getElapsedSeconds(self): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + import math if self.end and self.start: @@ -88,10 +137,21 @@ class Process: formatted = None return formatted - # getElapsedtime - def writeKey(self, writeDict, key=None, value=None, startStop=None): - "Write a key, value pair in a supported format" + """ + Writes a key / value pair in a supported format. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + if key != None and (value != None or startStop != None): indent = '\t' * writeDict['indentationLevel'] if writeDict['format'] == 'xml': @@ -107,6 +167,20 @@ class Process: "%s%40s : %s\n" % (indent, key, value)) def writeLogHeader(self, writeDict): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + import platform # Retrieve operating environment information @@ -137,7 +211,8 @@ class Process: self.writeKey(writeDict, 'description', self.description) self.writeKey(writeDict, 'cmd', self.cmd) - if self.args: self.writeKey(writeDict, 'args', ' '.join(self.args)) + if self.args: + self.writeKey(writeDict, 'args', ' '.join(self.args)) self.writeKey(writeDict, 'start', self.start) self.writeKey(writeDict, 'end', self.end) self.writeKey(writeDict, 'elapsed', self.getElapsedSeconds()) @@ -161,17 +236,37 @@ class Process: self.writeKey(writeDict, 'status', self.status) - # writeLogHeader - def writeLogFooter(self, writeDict): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + writeDict['indentationLevel'] -= 1 self.writeKey(writeDict, 'process', None, 'stop') - # writeLogFooter - def writeLog(self, logHandle=sys.stdout, indentationLevel=0, format='xml'): """ - Write logging information to the specified handle + Writes logging information to the specified handle. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. """ writeDict = {} @@ -194,9 +289,21 @@ class Process: self.writeLogFooter(writeDict) - # writeLog - def writeLogToDisk(self, logFilename=None, format='xml', header=None): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + if logFilename: try: # This also doesn't seem like the best structure... @@ -220,21 +327,40 @@ class Process: self.writeLog(logHandle) logHandle.close() - # writeLogToDisk - def logLine(self, line): - "Add a line of text to the log" + """ + Adds a line of text to the log. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + self.log.append(line.rstrip()) if self.echo: print("%s" % line.rstrip()) - # logLine - def execute(self): """ - Execute this process + Executes the current process. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. """ - import re + import datetime import traceback @@ -363,28 +489,48 @@ class Process: self.status = exitCode self.end = datetime.datetime.now() - # execute -# Process - class ProcessList(Process): """ - A list of processes with logged output + A list of processes with logged output. """ def __init__(self, description, blocking=True, cwd=None, env=None): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + Process.__init__(self, description, None, None, cwd, env) "Initialize the standard class variables" self.processes = [] self.blocking = blocking - # __init__ - def generateReport(self, writeDict): """ - Generate a log based on the success of the child processes + Generates a log based on the success of the child processes. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. """ + if self.processes: _status = True indent = '\t' * (writeDict['indentationLevel'] + 1) @@ -417,6 +563,20 @@ class ProcessList(Process): self.status = -1 def writeLogHeader(self, writeDict): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + self.writeKey(writeDict, 'processList', None, 'start') writeDict['indentationLevel'] += 1 @@ -429,17 +589,37 @@ class ProcessList(Process): self.writeKey(writeDict, 'status', self.status) - # writeLogHeader - def writeLogFooter(self, writeDict): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + writeDict['indentationLevel'] -= 1 self.writeKey(writeDict, 'processList', None, 'stop') - # writeLogFooter - def writeLog(self, logHandle=sys.stdout, indentationLevel=0, format='xml'): """ - Write logging information to the specified handle + Writes logging information to the specified handle. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. """ writeDict = {} @@ -464,12 +644,21 @@ class ProcessList(Process): self.writeLogFooter(writeDict) - # writeLog - def execute(self): """ - Execute this list of processes + Executes the list of processes. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. """ + import datetime self.start = datetime.datetime.now() @@ -493,12 +682,23 @@ class ProcessList(Process): break self.end = datetime.datetime.now() - # execute - -# ProcessList def main(): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + import optparse p = optparse.OptionParser(description='A process logging script', diff --git a/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py b/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py index 5d57b90..6925511 100644 --- a/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py +++ b/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- """ -Defines unit tests for the generated *ACES* configuration. +Defines unit tests for *ACES* configuration. """ import hashlib @@ -42,6 +42,7 @@ UNHASHABLE_TEST_PATTERNS = ('\.icc', '\.ocio') class TestACESConfig(unittest.TestCase): """ + Performs tests on the *ACES* configuration. """ def setUp(self): @@ -71,8 +72,28 @@ class TestACESConfig(unittest.TestCase): shutil.rmtree(self.__temporary_directory) @staticmethod - def directory_hashes(directory, filters_in=None, filters_out=None): + def directory_hashes(directory, + filters_in=None, + filters_out=None, + flags=0): """ + Recursively computes the hashes from the file within given directory. + + Parameters + ---------- + directory : str or unicode + Directory to compute the file hashes. + filters_in : array_like + Included patterns. + filters_out : array_like + Excluded patterns. + flags : int + Regex flags. + + Returns + ------- + dict + Directory file hashes. """ hashes = {} @@ -87,6 +108,8 @@ class TestACESConfig(unittest.TestCase): def test_ACES_config(self): """ + Performs tests on the *ACES* configuration by computing hashes on the + generated configuration and comparing them to the existing one. """ self.assertTrue(createACESConfig(self.__aces_ocio_ctl_directory, diff --git a/aces_1.0.0/python/aces_ocio/util.py b/aces_1.0.0/python/aces_ocio/util.py index c1ca5d3..f7b2e23 100644 --- a/aces_1.0.0/python/aces_ocio/util.py +++ b/aces_1.0.0/python/aces_ocio/util.py @@ -39,8 +39,19 @@ class ColorSpace: allocationType=OCIO.Constants.ALLOCATION_UNIFORM, allocationVars=[0.0, 1.0]): """ - Initialize the standard class variables + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. """ + self.name = name self.bitDepth = bitDepth self.description = description @@ -53,17 +64,40 @@ class ColorSpace: self.allocationVars = allocationVars -# Create a 4x4 matrix (list) based on a 3x3 matrix (list) input def mat44FromMat33(mat33): + """ + Creates a 4x4 matrix from given 3x3 matrix. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + return [mat33[0], mat33[1], mat33[2], 0.0, mat33[3], mat33[4], mat33[5], 0.0, mat33[6], mat33[7], mat33[8], 0.0, 0, 0, 0, 1.0] -# TODO: Worth moving to *util.py*. def filter_words(words, filters_in=None, filters_out=None, flags=0): """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. """ filtered_words = [] @@ -91,6 +125,17 @@ def filter_words(words, filters_in=None, filters_out=None, flags=0): def files_walker(directory, filters_in=None, filters_out=None, flags=0): """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. """ for parent_directory, directories, files in os.walk(directory, @@ -103,7 +148,3 @@ def files_walker(directory, filters_in=None, filters_out=None, flags=0): continue yield path - - - - -- 1.7.10.4