diff --git a/lutLab/ext_1d_lut.py b/lutLab/ext_1d_lut.py index 9b17553..0570bbe 100755 --- a/lutLab/ext_1d_lut.py +++ b/lutLab/ext_1d_lut.py @@ -5,6 +5,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import argparse from utils.ocio_helper import ( OCIO_3D_LUTS_FORMATS, create_ocio_processor, is_3d_lut @@ -14,6 +15,8 @@ from scipy.interpolate import PchipInterpolator import numpy +import sys +from utils import debug_helper class Ext1DLutException(Exception): @@ -136,6 +139,18 @@ def __get_options(): parser.add_argument("-d", "--display", help="Display result using matplotlib", action="store_true") + # version + parser.add_argument('-v', "--version", action='version', + version='{0} - version {1}'.format(description, + __version__)) + # full version + versions = debug_helper.get_imported_modules_versions(sys.modules, + globals()) + versions = '{0} - version {1}\n\n{2}'.format(description, + __version__, + versions) + parser.add_argument('-V', "--full-versions", + action=debug_helper.make_full_version_action(versions)) return parser.parse_args() if __name__ == '__main__': diff --git a/lutLab/lut_to_lut.py b/lutLab/lut_to_lut.py index 937846e..8cab8e2 100755 --- a/lutLab/lut_to_lut.py +++ b/lutLab/lut_to_lut.py @@ -5,6 +5,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import argparse from utils.ocio_helper import OCIO_LUTS_FORMATS, create_ocio_processor from utils.csp_helper import write_2d_csp_lut @@ -14,6 +15,8 @@ from PyOpenColorIO.Constants import ( INTERP_LINEAR, INTERP_TETRAHEDRAL ) +from utils import debug_helper +import sys class LutToLutException(Exception): @@ -121,6 +124,18 @@ def __get_options(): # inverse parser.add_argument("-inv", "--inverse", help="Inverse input LUT", action="store_true") + # version + parser.add_argument('-v', "--version", action='version', + version='{0} - version {1}'.format(description, + __version__)) + # full version + versions = debug_helper.get_imported_modules_versions(sys.modules, + globals()) + versions = '{0} - version {1}\n\n{2}'.format(description, + __version__, + versions) + parser.add_argument('-V', "--full-versions", + action=debug_helper.make_full_version_action(versions)) return parser.parse_args() if __name__ == '__main__': diff --git a/lutLab/rgb_to_xyz_matrix.py b/lutLab/rgb_to_xyz_matrix.py index f81ddcb..6ec1cff 100644 --- a/lutLab/rgb_to_xyz_matrix.py +++ b/lutLab/rgb_to_xyz_matrix.py @@ -1,13 +1,18 @@ +#!/usr/bin/python + """ Display RGB colorspaces to XYZ conversion matrices and their inverses .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" from utils.colors_helper import xy_to_XYZ from utils.colorspaces import COLORSPACES from utils.private_colorspaces import PRIVATE_COLORSPACES import numpy import argparse +import sys +from utils import debug_helper class RGBToXYZMatrixException(Exception): @@ -165,6 +170,18 @@ def __get_options(): type=str, choices=['matrix', 'spimtx', 'simple'], default='matrix') + # version + parser.add_argument('-v', "--version", action='version', + version='{0} - version {1}'.format(description, + __version__)) + # full version + versions = debug_helper.get_imported_modules_versions(sys.modules, + globals()) + versions = '{0} - version {1}\n\n{2}'.format(description, + __version__, + versions) + parser.add_argument('-V', "--full-versions", + action=debug_helper.make_full_version_action(versions)) return parser.parse_args() diff --git a/plotThatLut/plot_that_lut.py b/plotThatLut/plot_that_lut.py index 61592d5..f3b2b93 100755 --- a/plotThatLut/plot_that_lut.py +++ b/plotThatLut/plot_that_lut.py @@ -5,7 +5,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ - +__version__ = "0.1" ## imports import os # OpenColorIO diff --git a/plotThatLut/plot_that_lut_web.py b/plotThatLut/plot_that_lut_web.py index aeb5bac..1820dfc 100755 --- a/plotThatLut/plot_that_lut_web.py +++ b/plotThatLut/plot_that_lut_web.py @@ -5,7 +5,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ - +__version__ = "Prototype" from os import path import ntpath import sys diff --git a/plotThatLut/ptlut.py b/plotThatLut/ptlut.py index 380fdd5..619dd45 100755 --- a/plotThatLut/ptlut.py +++ b/plotThatLut/ptlut.py @@ -5,8 +5,11 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import plot_that_lut import argparse +from utils import debug_helper +import sys def __get_options(): @@ -51,6 +54,18 @@ def __get_options(): "Samples count. Ex : {0} for a curve or {1} for a cube." ).format(plot_that_lut.DEFAULT_SAMPLE, plot_that_lut.DEFAULT_CUBE_SIZE), default=None, type=int) + # version + parser.add_argument('-v', "--version", action='version', + version='{0} - version {1}'.format(description, + __version__)) + # full version + versions = debug_helper.get_imported_modules_versions(sys.modules, + globals()) + versions = '{0} - version {1}\n\n{2}'.format(description, + __version__, + versions) + parser.add_argument('-V', "--full-versions", + action=debug_helper.make_full_version_action(versions)) ## return args return parser.parse_args() diff --git a/utils/clcc_helper.py b/utils/clcc_helper.py index 496c6b5..e80ca37 100644 --- a/utils/clcc_helper.py +++ b/utils/clcc_helper.py @@ -3,6 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import datetime diff --git a/utils/colors_helper.py b/utils/colors_helper.py index 170a311..8a9ddd6 100644 --- a/utils/colors_helper.py +++ b/utils/colors_helper.py @@ -3,6 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import math diff --git a/utils/colorspaces.py b/utils/colorspaces.py index 2eecf4f..6b223ce 100644 --- a/utils/colorspaces.py +++ b/utils/colorspaces.py @@ -3,6 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" from utils import colors_helper from abc import ABCMeta, abstractmethod import math diff --git a/utils/csp_helper.py b/utils/csp_helper.py index fb5a504..7a317c0 100644 --- a/utils/csp_helper.py +++ b/utils/csp_helper.py @@ -3,6 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import itertools from utils.lut_utils import check_arrays_length diff --git a/utils/cube_helper.py b/utils/cube_helper.py index fde02cf..b919c2c 100644 --- a/utils/cube_helper.py +++ b/utils/cube_helper.py @@ -3,6 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import itertools from utils.lut_utils import check_arrays_length diff --git a/utils/debug_helper.py b/utils/debug_helper.py new file mode 100644 index 0000000..b3d6ec9 --- /dev/null +++ b/utils/debug_helper.py @@ -0,0 +1,71 @@ +""" Debug helpers + +.. moduleauthor:: `Marie FETIVEAU `_ + +""" +__version__ = "0.1" +import os +import argparse +import sys + + +def get_imported_modules_versions(modules, glob): + """Return a string containing imported modules versions. + (It isn't intended to be exhautive) + + Args: + modules: sys.modules + glob: globals() + + Returns: + .string + + """ + # Retrieve ColorPipe-tools modules + path = os.path.dirname(os.path.dirname(__file__)) + res = "ColorPipe-tools modules:\n------------------------------" + for name in modules: + if (path in str(modules[name]) + and "debug_helper" not in str(modules[name])): + try: + res = "{0}\n{1} - version {2}".format(res, name, + modules[name].__version__) + except AttributeError: + pass + # Retrieve "interesting" external modules + module_selection = set(modules) & set(glob) + res = "{0}\n\nExternal modules:\n------------------------------".format(res) + for name in module_selection: + if "built-in" not in name and path not in str(modules[name]): + try: + res = "{0}\n{1} - version {2}".format(res, name, + modules[name].__version__) + except AttributeError: + pass + return res + + +def make_full_version_action(version_text): + """Return a multi-lines version action for argparse + + Args: + version_text (str): version text to print + + Returns: + .argparse.Action + + """ + class FullVersionAction(argparse.Action): + def __init__(self, option_strings, dest=None, nargs=0, default=None, + required=False, type=None, metavar=None, + help=("show version number of the program and its " + "dependencies. And then exit")): + super(FullVersionAction, self).__init__( + option_strings=option_strings, + dest=dest, nargs=nargs, default=default, required=required, + metavar=metavar, type=type, help=help) + + def __call__(self, parser, namespace, values, option_string=None): + print(version_text) + sys.exit() + return FullVersionAction diff --git a/utils/lut_utils.py b/utils/lut_utils.py index dbd3c2c..6b9bbdc 100644 --- a/utils/lut_utils.py +++ b/utils/lut_utils.py @@ -3,6 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import os diff --git a/utils/ocio_helper.py b/utils/ocio_helper.py index e9c8f4d..7e0c2bd 100644 --- a/utils/ocio_helper.py +++ b/utils/ocio_helper.py @@ -3,6 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import os # import OpenColorIO from PyOpenColorIO import ( diff --git a/utils/spi_helper.py b/utils/spi_helper.py index 7fcaae1..10f24d3 100644 --- a/utils/spi_helper.py +++ b/utils/spi_helper.py @@ -3,7 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ - +__version__ = "0.1" class SpiHelperException(Exception): pass diff --git a/utils/threedl_helper.py b/utils/threedl_helper.py index 1a06225..8cedae2 100644 --- a/utils/threedl_helper.py +++ b/utils/threedl_helper.py @@ -3,6 +3,7 @@ .. moduleauthor:: `Marie FETIVEAU `_ """ +__version__ = "0.1" import math