コード例 #1
0
def add_version_option(parser, description, version, full_version):
    """ Add version argument

    Args:
        parser (argparse.ArgumentParser): parser on which option will be add

        description (str): tool description

        version (str): version of the module

        full_version (str): versions of dependencies.
        See debug_helper.get_imported_modules_versions

    """
    # version
    parser.add_argument('-v',
                        "--version",
                        action='version',
                        version='{0} - version {1}'.format(description,
                                                           version))
    # full version
    versions = '{0} - version {1}\n\n{2}'.format(description,
                                                 version,
                                                 full_version)
    parser.add_argument('-V',
                        "--full-versions",
                        action=make_full_version_action(versions))
コード例 #2
0
def add_version_option(parser, description, version, full_version):
    """ Add version argument

    Args:
        parser (argparse.ArgumentParser): parser on which option will be add

        description (str): tool description

        version (str): version of the module

        full_version (str): versions of dependencies.
        See debug_helper.get_imported_modules_versions

    """
    # version
    parser.add_argument('-v',
                        "--version",
                        action='version',
                        version='{0} - version {1}'.format(description,
                                                           version))
    # full version
    versions = '{0} - version {1}\n\n{2}'.format(description,
                                                 version,
                                                 full_version)
    parser.add_argument('-V',
                        "--full-versions",
                        action=make_full_version_action(versions))
コード例 #3
0
def __get_options():
    """ Return ext_1d_lut option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    ## Define parser
    description = 'Extract 1D composante of a 3D LUT'
    parser = argparse.ArgumentParser(description=description)
    # input 3D lut file
    parser.add_argument("inlutfile",
                        help=("path to a 3D LUT.\n{0}").format(
                            str(OCIO_3D_LUTS_FORMATS)),
                        type=str)
    # output lut
    parser.add_argument("-out",
                        "--outlutfile",
                        help=("export path of the extracted (.csp) 1D LUT."),
                        type=str,
                        default=None)
    # out lut size
    parser.add_argument("-os",
                        "--outlut-size",
                        help=("Output lut bit precision. Ex : 10, 16, 32."),
                        default=16,
                        type=int)
    # Smooth
    parser.add_argument("-sm",
                        "--smooth",
                        help="Smooth resulting LUT",
                        action="store_true")
    # out lut size
    parser.add_argument("-sms",
                        "--smooth-size",
                        help=("Smooth sub-sampling size. Ex : 17"),
                        default=17,
                        type=int)
    # Display curves
    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()
コード例 #4
0
ファイル: ptlut.py プロジェクト: mrbonsoir/ColorPipe-tools
def __get_options():
    """ Return ptlut option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    ## Define parser
    description = 'PlotThatLUT command line tool'
    parser = argparse.ArgumentParser(description=description)
    # main lut
    parser.add_argument("lutfiles", help=(
        "path to the main LUT to plot.\n{0}"
    ).format(plot_that_lut.supported_formats()), type=str, nargs='+')
    # inverse
    parser.add_argument("-i", "--inverse", help="inverse main lut",
                        action="store_true")
    # display markers
    parser.add_argument("-m", "--markers",
                        help="display markers on curves (useless on cubes)",
                        action="store_true")
    # pre lut
    parser.add_argument("-pre", "--prelutfile", help=(
        "path to a pre LUT.{0}"
    ).format(plot_that_lut.supported_formats()), type=str, default=None)
    # post lut
    parser.add_argument("-post", "--postlutfile", help=(
        "path to a post LUT.\n{0}"
    ).format(plot_that_lut.supported_formats()), type=str, default=None)
    # type
    parser.add_argument("-t", "--plot-type",
                        help=("Plot type. By default, a curve for a 1D/2D LUT "
                        "and a cube for a 3D LUT."),
                        type=str,
                        choices=['auto', 'curve', 'red_curve', 'blue_curve',
                                 'green_curve', 'cube'],
                        default='auto')
    # samples count
    parser.add_argument("-s", "--samples-count", help=(
        "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()
コード例 #5
0
def __get_options():
    """ Return rgb_to_xyz option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    # Define parser
    description = 'Print RGB -> RGB matrix'
    parser = argparse.ArgumentParser(description=description)
    # RGB colorspace
    colorspaces = sorted(
        list(COLORSPACES.keys()) + list(PRIVATE_COLORSPACES.keys()) +
        [XYZ_colorspace])
    parser.add_argument("-in",
                        "--in-colorspace",
                        help=("Input RGB Colorspace."),
                        type=str,
                        choices=colorspaces,
                        required=True)
    parser.add_argument("-out",
                        "--out-colorspace",
                        help=("Output RGB Colorspace."),
                        type=str,
                        choices=colorspaces,
                        required=True)
    # Get primarie matrix only
    parser.add_argument(
        "-po",
        "--primaries-only",
        help="Primaries matrix only, doesn't include white point.",
        action="store_true")
    # Output format
    parser.add_argument("-f",
                        "--format",
                        help=("Output formatting."),
                        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()
コード例 #6
0
def __get_options():
    """Return curve_to_lut option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    ## Define parser
    description = 'Create lut file corresponding to a colorspace gradation'
    parser = argparse.ArgumentParser(description=description)
    # RGB colorspace
    parser.add_argument("colorspace",
                        help=("Input RGB Colorspace."),
                        type=str,
                        choices=sorted(COLORSPACES.keys() +
                                        PRIVATE_COLORSPACES.keys()))
    # output lut
    parser.add_argument("outlutpath", help=("path to the output LUT."
                                                      " Can be a file or a "
                                                      "directory."
                                                      ), type=str)
    # type
    parser.add_argument("-t", "--out-type", help=("Output LUT type."),
                        type=str, choices=['1D_CSP', '1D_CUBE', '1D_SPI'],
                        default='1D_CUBE')
    # in range
    parser.add_argument("-ir", "--in-range", help=("In range value."),
                        type=float, default=0.0)
    # out range
    parser.add_argument("-or", "--out-range", help=("Out range value."),
                        type=float, default=1.0)
    # out lut size
    parser.add_argument("-os", "--out-lut-size", help=(
        "Output lut bit precision. Ex : 10, 16, 32."
    ), default=16, type=int)
    # direction
    parser.add_argument("-d", "--direction", help=("Direction : "
                                                   "encode or decode."),
                        type=str, choices=[Direction.ENCODE, Direction.DECODE],
                        default=Direction.ENCODE)
    # 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()
コード例 #7
0
def __get_options():
    """ Return lut_to_lut option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    ## Define parser
    description = 'Convert a LUT into another format'
    parser = argparse.ArgumentParser(description=description)
    # input lut
    parser.add_argument("inlutfile", help=(
        "path to a LUT.\n{0}"
    ).format(str(OCIO_LUTS_FORMATS)), type=str)
    # output lut
    parser.add_argument("-out", "--outlutfile", help=(
        "path to the output LUT"
    ), type=str, default=None)
    # type
    parser.add_argument("-t", "--out-type",
                        help=("Output LUT type."),
                        type=str,
                        choices=['1D_CSP', '1D_CUBE', '3D_CUBE', '3D_CLCC',
                                 '3D_JSON'],
                        default='1D_CUBE')
    # out lut size
    parser.add_argument("-os", "--out-lut-size", help=(
        "Output lut bit precision. Ex : 10, 16, 32."
    ), default=16, type=int)
    # out cube size
    parser.add_argument("-ocs", "--out-cube-size", help=(
        "Output cube size (3D only). Ex : 17, 32."
    ), default=17, type=int)
    # 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()
コード例 #8
0
def __get_options():
    """ Return ext_1d_lut option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    ## Define parser
    description = 'Extract 1D composante of a 3D LUT'
    parser = argparse.ArgumentParser(description=description)
    # input 3D lut file
    parser.add_argument("inlutfile", help=(
        "path to a 3D LUT.\n{0}"
    ).format(str(OCIO_3D_LUTS_FORMATS)), type=str)
    # output lut
    parser.add_argument("-out", "--outlutfile", help=(
        "export path of the extracted (.csp) 1D LUT."
    ), type=str, default=None)
    # out lut size
    parser.add_argument("-os", "--outlut-size", help=(
        "Output lut bit precision. Ex : 10, 16, 32."
    ), default=16, type=int)
    # Smooth
    parser.add_argument("-sm", "--smooth", help="Smooth resulting LUT",
                        action="store_true")
    # out lut size
    parser.add_argument("-sms", "--smooth-size", help=(
        "Smooth sub-sampling size. Ex : 17"
    ), default=17, type=int)
    # Display curves
    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()
コード例 #9
0
def __get_options():
    """ Return rgb_to_xyz option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    # Define parser
    description = 'Print RGB -> RGB matrix'
    parser = argparse.ArgumentParser(description=description)
    # RGB colorspace
    colorspaces = sorted(COLORSPACES.keys() + PRIVATE_COLORSPACES.keys() + [XYZ_colorspace])
    parser.add_argument("-in", "--in-colorspace",
                        help=("Input RGB Colorspace."),
                        type=str,
                        choices=colorspaces,
                        required=True)
    parser.add_argument("-out", "--out-colorspace",
                        help=("Output RGB Colorspace."),
                        type=str,
                        choices=colorspaces,
                        required=True)
    # Get primarie matrix only
    parser.add_argument("-po", "--primaries-only",
                        help="Primaries matrix only, doesn't include white point.",
                        action="store_true")
    # Output format
    parser.add_argument("-f", "--format",
                        help=("Output formatting."),
                        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()
コード例 #10
0
def __get_options():
    """ Return rgb_to_xyz option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    # Define parser
    description = 'Print RGB -> XYZ matrix'
    parser = argparse.ArgumentParser(description=description)
    # RGB colorspace
    parser.add_argument("-c",
                        "--colorspace",
                        help=("Input RGB Colorspace."),
                        type=str,
                        choices=sorted(COLORSPACES.keys() +
                                       PRIVATE_COLORSPACES.keys()),
                        default='Rec709')
    # Output format
    parser.add_argument("-f",
                        "--format",
                        help=("Output formatting."),
                        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()
コード例 #11
0
def __get_options():
    """ Return rgb_to_xyz option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    # Define parser
    description = 'Print RGB -> XYZ matrix'
    parser = argparse.ArgumentParser(description=description)
    # RGB colorspace
    parser.add_argument("-c", "--colorspace",
                        help=("Input RGB Colorspace."),
                        type=str,
                        choices=sorted(COLORSPACES.keys() +
                                       PRIVATE_COLORSPACES.keys()),
                        default='Rec709')
    # Output format
    parser.add_argument("-f", "--format",
                        help=("Output formatting."),
                        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()
コード例 #12
0
def __get_options():
    """Return curve_to_lut option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    ## Define parser
    description = 'Create lut file corresponding to a colorspace gradation'
    parser = argparse.ArgumentParser(description=description)
    # RGB colorspace
    parser.add_argument("colorspace",
                        help=("Input RGB Colorspace."),
                        type=str,
                        choices=sorted(COLORSPACES.keys() +
                                       PRIVATE_COLORSPACES.keys()))
    # output lut
    parser.add_argument("outlutpath",
                        help=("path to the output LUT."
                              " Can be a file or a "
                              "directory."),
                        type=str)
    # type
    parser.add_argument("-t",
                        "--out-type",
                        help=("Output LUT type."),
                        type=str,
                        choices=['1D_CSP', '1D_CUBE', '1D_SPI'],
                        default='1D_CUBE')
    # in range
    parser.add_argument("-ir",
                        "--in-range",
                        help=("In range value."),
                        type=float,
                        default=0.0)
    # out range
    parser.add_argument("-or",
                        "--out-range",
                        help=("Out range value."),
                        type=float,
                        default=1.0)
    # out lut size
    parser.add_argument("-os",
                        "--out-lut-size",
                        help=("Output lut bit precision. Ex : 10, 16, 32."),
                        default=16,
                        type=int)
    # direction
    parser.add_argument("-d",
                        "--direction",
                        help=("Direction : "
                              "encode or decode."),
                        type=str,
                        choices=[Direction.ENCODE, Direction.DECODE],
                        default=Direction.ENCODE)
    # 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()
コード例 #13
0
def __get_options():
    """ Return lut_to_lut option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    ## Define parser
    description = 'Convert a LUT into another format'
    parser = argparse.ArgumentParser(description=description)
    # input lut
    parser.add_argument("inlutfile",
                        help=("path to a LUT.\n{0}").format(
                            str(OCIO_LUTS_FORMATS)),
                        type=str)
    # output lut
    parser.add_argument("-out",
                        "--outlutfile",
                        help=("path to the output LUT"),
                        type=str,
                        default=None)
    # type
    parser.add_argument(
        "-t",
        "--out-type",
        help=("Output LUT type."),
        type=str,
        choices=['1D_CSP', '1D_CUBE', '3D_CUBE', '3D_CLCC', '3D_JSON'],
        default='1D_CUBE')
    # out lut size
    parser.add_argument("-os",
                        "--out-lut-size",
                        help=("Output lut bit precision. Ex : 10, 16, 32."),
                        default=16,
                        type=int)
    # out cube size
    parser.add_argument("-ocs",
                        "--out-cube-size",
                        help=("Output cube size (3D only). Ex : 17, 32."),
                        default=17,
                        type=int)
    # 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()
コード例 #14
0
def __get_options():
    """ Return ptlut option parser

    Returns:
        .argparse.ArgumentParser.args

    """
    # Define parser
    description = 'PlotThatLUT command line tool'
    parser = argparse.ArgumentParser(description=description)
    # main lut
    parser.add_argument("lutfiles",
                        help=("path to the main LUT to plot.\n{0}").format(
                            plot_that_lut.supported_formats()),
                        type=str,
                        nargs='+')
    # inverse
    parser.add_argument("-i",
                        "--inverse",
                        help="inverse main lut",
                        action="store_true")
    # display markers
    parser.add_argument("-m",
                        "--markers",
                        help="display markers on curves (useless on cubes)",
                        action="store_true")
    # pre lut
    parser.add_argument("-pre",
                        "--prelutfile",
                        help=("path to a pre LUT.{0}").format(
                            plot_that_lut.supported_formats()),
                        type=str,
                        default=None)
    # post lut
    parser.add_argument("-post",
                        "--postlutfile",
                        help=("path to a post LUT.\n{0}").format(
                            plot_that_lut.supported_formats()),
                        type=str,
                        default=None)
    # type
    parser.add_argument("-t",
                        "--plot-type",
                        help=("Plot type. By default, a curve for a 1D/2D LUT "
                              "and a cube for a 3D LUT."),
                        type=str,
                        choices=[
                            'auto', 'curve', 'red_curve', 'blue_curve',
                            'green_curve', 'cube'
                        ],
                        default='auto')
    # samples count
    parser.add_argument(
        "-s",
        "--samples-count",
        help=("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()