..
  SPDX-License-Identifier: CC-BY-4.0
  Copyright Contributors to the OpenColorIO Project.
  Do not edit! This file was automatically generated by share/docs/frozendoc.py.

.. py:class:: Context
   :module: PyOpenColorIO

   :ref:`Context`

   A context defines some overrides to a :ref:`Config`. For example, it can override the search path or change the value of a context variable.

   .. note::
      Only some :ref:`Config::getProcessor` methods accept a custom context; otherwise, the default context instance is used (see Config::getCurrentContext).

   :ref:`Context` Variables

   The context variables allow changes at runtime using environment variables. For example, a color space name (such as src & dst for the :ref:`ColorSpaceTransform`) or a file name (such as LUT file name for the :ref:`FileTransform`) could be defined by context variables. The color transformation is then customized based on some environment variables.

   In a config the context variables support three syntaxes (i.e. ${VAR}, $VAR and VAR%) and the parsing starts from longest to shortest. So, the resolve works like '$TEST_$TESTING_$TE' expands in this order '2 1 3'.

   :ref:`Config` authors are recommended to include the "environment" section in their configs. This improves performance as well as making the config more readable. When present, this section must declare all context variables used in the config. It may also provide a default value, in case the variable is not present in the user's environment.

   A context variable may only be used in the following places:
   - the `:ref:`ColorSpaceTransform`` to define the source and the destination color space names,
   - the `:ref:`FileTransform`` to define the source file name (e.g. a LUT file name),
   - the search_path,
   - the cccid of the `:ref:`FileTransform`` to only extract one specific transform from the CDL & CCC files.

   Some specific restrictions are worth calling out:
   - they cannot be used as either the name or value of a role,
   - the context variable characters $ and % are prohibited in a color space name.


   .. py:method:: Context.__init__(*args, **kwargs)
      :module: PyOpenColorIO

      Overloaded function.

      1. __init__(self: PyOpenColorIO.Context) -> None

      2. __init__(self: PyOpenColorIO.Context, workingDir: str = '', searchPaths: List[str] = [], stringVars: Dict[str, str] = {}, environmentMode: PyOpenColorIO.EnvironmentMode = <EnvironmentMode.ENV_ENVIRONMENT_LOAD_PREDEFINED: 1>) -> None


   .. py:method:: Context.addSearchPath(self: PyOpenColorIO.Context, path: str) -> None
      :module: PyOpenColorIO


   .. py:method:: Context.clearSearchPaths(self: PyOpenColorIO.Context) -> None
      :module: PyOpenColorIO


   .. py:method:: Context.clearStringVars(self: PyOpenColorIO.Context) -> None
      :module: PyOpenColorIO


   .. py:method:: Context.getCacheID(self: PyOpenColorIO.Context) -> str
      :module: PyOpenColorIO


   .. py:method:: Context.getEnvironmentMode(self: PyOpenColorIO.Context) -> PyOpenColorIO.EnvironmentMode
      :module: PyOpenColorIO


   .. py:method:: Context.getSearchPath(self: PyOpenColorIO.Context) -> str
      :module: PyOpenColorIO


   .. py:method:: Context.getSearchPaths(self: PyOpenColorIO.Context) -> PyOpenColorIO.Context.SearchPathIterator
      :module: PyOpenColorIO


   .. py:method:: Context.getStringVars(self: PyOpenColorIO.Context) -> PyOpenColorIO.Context.StringVarIterator
      :module: PyOpenColorIO


   .. py:method:: Context.getWorkingDir(self: PyOpenColorIO.Context) -> str
      :module: PyOpenColorIO


   .. py:method:: Context.loadEnvironment(self: PyOpenColorIO.Context) -> None
      :module: PyOpenColorIO

      Seed all string vars with the current environment.


   .. py:method:: Context.resolveFileLocation(*args, **kwargs)
      :module: PyOpenColorIO

      Overloaded function.

      1. resolveFileLocation(self: PyOpenColorIO.Context, filename: str) -> str

      Build the resolved and expanded filepath using the search_path when needed, and check if the filepath exists. If it cannot be resolved or found, an exception will be thrown. The method argument is directly from the config file so it can be an absolute or relative file path or a file name.

      .. note::
         The filepath existence check could add a performance hit.

      .. note::
         The context variable resolution is performed using :cpp:func:`resolveStringVar`.

      2. resolveFileLocation(self: PyOpenColorIO.Context, filename: str, usedContextVars: PyOpenColorIO.Context) -> str

      Build the resolved and expanded filepath and return all the context variables used to resolve the filename (empty if no context variables were used).


   .. py:method:: Context.resolveStringVar(*args, **kwargs)
      :module: PyOpenColorIO

      Overloaded function.

      1. resolveStringVar(self: PyOpenColorIO.Context, string: str) -> str

      Resolve all the context variables from the string. It could be color space names or file names. Note that it recursively applies the context variable resolution. Returns the string unchanged if it does not contain any context variable.

      2. resolveStringVar(self: PyOpenColorIO.Context, string: str, usedContextVars: PyOpenColorIO.Context) -> str

      Resolve all the context variables from the string and return all the context variables used to resolve the string (empty if no context variables were used).


   .. py:method:: Context.setEnvironmentMode(self: PyOpenColorIO.Context, mode: PyOpenColorIO.EnvironmentMode) -> None
      :module: PyOpenColorIO


   .. py:method:: Context.setSearchPath(self: PyOpenColorIO.Context, path: str) -> None
      :module: PyOpenColorIO


   .. py:method:: Context.setWorkingDir(self: PyOpenColorIO.Context, dirName: str) -> None
      :module: PyOpenColorIO


.. py:class:: StringVarNameIterator
   :module: PyOpenColorIO.Context


   .. py:method:: StringVarNameIterator.__getitem__(self: PyOpenColorIO.Context.StringVarNameIterator, arg0: int) -> str
      :module: PyOpenColorIO.Context


   .. py:method:: StringVarNameIterator.__iter__(self: PyOpenColorIO.Context.StringVarNameIterator) -> PyOpenColorIO.Context.StringVarNameIterator
      :module: PyOpenColorIO.Context


   .. py:method:: StringVarNameIterator.__len__(self: PyOpenColorIO.Context.StringVarNameIterator) -> int
      :module: PyOpenColorIO.Context


   .. py:method:: StringVarNameIterator.__next__(self: PyOpenColorIO.Context.StringVarNameIterator) -> str
      :module: PyOpenColorIO.Context


.. py:class:: StringVarIterator
   :module: PyOpenColorIO.Context


   .. py:method:: StringVarIterator.__getitem__(self: PyOpenColorIO.Context.StringVarIterator, arg0: int) -> tuple
      :module: PyOpenColorIO.Context


   .. py:method:: StringVarIterator.__iter__(self: PyOpenColorIO.Context.StringVarIterator) -> PyOpenColorIO.Context.StringVarIterator
      :module: PyOpenColorIO.Context


   .. py:method:: StringVarIterator.__len__(self: PyOpenColorIO.Context.StringVarIterator) -> int
      :module: PyOpenColorIO.Context


   .. py:method:: StringVarIterator.__next__(self: PyOpenColorIO.Context.StringVarIterator) -> tuple
      :module: PyOpenColorIO.Context


.. py:class:: SearchPathIterator
   :module: PyOpenColorIO.Context


   .. py:method:: SearchPathIterator.__getitem__(self: PyOpenColorIO.Context.SearchPathIterator, arg0: int) -> str
      :module: PyOpenColorIO.Context


   .. py:method:: SearchPathIterator.__iter__(self: PyOpenColorIO.Context.SearchPathIterator) -> PyOpenColorIO.Context.SearchPathIterator
      :module: PyOpenColorIO.Context


   .. py:method:: SearchPathIterator.__len__(self: PyOpenColorIO.Context.SearchPathIterator) -> int
      :module: PyOpenColorIO.Context


   .. py:method:: SearchPathIterator.__next__(self: PyOpenColorIO.Context.SearchPathIterator) -> str
      :module: PyOpenColorIO.Context

