code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def remove_context(cls, name): """Remove a context. Similar to the ``docker context rm`` command. Args: name (str): The name of the context Raises: :py:class:`docker.errors.MissingContextParameter` If a context name is not provided. :py:class...
Remove a context. Similar to the ``docker context rm`` command. Args: name (str): The name of the context Raises: :py:class:`docker.errors.MissingContextParameter` If a context name is not provided. :py:class:`docker.errors.ContextNotFound` ...
remove_context
python
docker/docker-py
docker/context/api.py
https://github.com/docker/docker-py/blob/master/docker/context/api.py
Apache-2.0
def inspect_context(cls, name="default"): """Remove a context. Similar to the ``docker context inspect`` command. Args: name (str): The name of the context Raises: :py:class:`docker.errors.MissingContextParameter` If a context name is not provided. ...
Remove a context. Similar to the ``docker context inspect`` command. Args: name (str): The name of the context Raises: :py:class:`docker.errors.MissingContextParameter` If a context name is not provided. :py:class:`docker.errors.ContextNotFound` ...
inspect_context
python
docker/docker-py
docker/context/api.py
https://github.com/docker/docker-py/blob/master/docker/context/api.py
Apache-2.0
def __init__(self, program, environment=None): """ Create a store object that acts as an interface to perform the basic operations for storing, retrieving and erasing credentials using `program`. """ self.program = constants.PROGRAM_PREFIX + program self.exe = shu...
Create a store object that acts as an interface to perform the basic operations for storing, retrieving and erasing credentials using `program`.
__init__
python
docker/docker-py
docker/credentials/store.py
https://github.com/docker/docker-py/blob/master/docker/credentials/store.py
Apache-2.0
def get(self, server): """ Retrieve credentials for `server`. If no credentials are found, a `StoreError` will be raised. """ if not isinstance(server, bytes): server = server.encode('utf-8') data = self._execute('get', server) result = json.loads(data.dec...
Retrieve credentials for `server`. If no credentials are found, a `StoreError` will be raised.
get
python
docker/docker-py
docker/credentials/store.py
https://github.com/docker/docker-py/blob/master/docker/credentials/store.py
Apache-2.0
def store(self, server, username, secret): """ Store credentials for `server`. Raises a `StoreError` if an error occurs. """ data_input = json.dumps({ 'ServerURL': server, 'Username': username, 'Secret': secret }).encode('utf-8') re...
Store credentials for `server`. Raises a `StoreError` if an error occurs.
store
python
docker/docker-py
docker/credentials/store.py
https://github.com/docker/docker-py/blob/master/docker/credentials/store.py
Apache-2.0
def erase(self, server): """ Erase credentials for `server`. Raises a `StoreError` if an error occurs. """ if not isinstance(server, bytes): server = server.encode('utf-8') self._execute('erase', server)
Erase credentials for `server`. Raises a `StoreError` if an error occurs.
erase
python
docker/docker-py
docker/credentials/store.py
https://github.com/docker/docker-py/blob/master/docker/credentials/store.py
Apache-2.0
def create_environment_dict(overrides): """ Create and return a copy of os.environ with the specified overrides """ result = os.environ.copy() result.update(overrides or {}) return result
Create and return a copy of os.environ with the specified overrides
create_environment_dict
python
docker/docker-py
docker/credentials/utils.py
https://github.com/docker/docker-py/blob/master/docker/credentials/utils.py
Apache-2.0
def list(self, **kwargs): """ List configs. Similar to the ``docker config ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Config`): The configs. Raises: :py:class:`docker.errors.APIError`...
List configs. Similar to the ``docker config ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Config`): The configs. Raises: :py:class:`docker.errors.APIError` If the server return...
list
python
docker/docker-py
docker/models/configs.py
https://github.com/docker/docker-py/blob/master/docker/models/configs.py
Apache-2.0
def labels(self): """ The labels of a container as dictionary. """ try: result = self.attrs['Config'].get('Labels') return result or {} except KeyError as ke: raise DockerException( 'Label data is not available for sparse object...
The labels of a container as dictionary.
labels
python
docker/docker-py
docker/models/containers.py
https://github.com/docker/docker-py/blob/master/docker/models/containers.py
Apache-2.0
def status(self): """ The status of the container. For example, ``running``, or ``exited``. """ if isinstance(self.attrs['State'], dict): return self.attrs['State']['Status'] return self.attrs['State']
The status of the container. For example, ``running``, or ``exited``.
status
python
docker/docker-py
docker/models/containers.py
https://github.com/docker/docker-py/blob/master/docker/models/containers.py
Apache-2.0
def exec_run(self, cmd, stdout=True, stderr=True, stdin=False, tty=False, privileged=False, user='', detach=False, stream=False, socket=False, environment=None, workdir=None, demux=False): """ Run a command inside this container. Similar to ``docker exec``. ...
Run a command inside this container. Similar to ``docker exec``. Args: cmd (str or list): Command to be executed stdout (bool): Attach to stdout. Default: ``True`` stderr (bool): Attach to stderr. Default: ``True`` stdin (bool): Attach to stdin. ...
exec_run
python
docker/docker-py
docker/models/containers.py
https://github.com/docker/docker-py/blob/master/docker/models/containers.py
Apache-2.0
def get_archive(self, path, chunk_size=DEFAULT_DATA_CHUNK_SIZE, encode_stream=False): """ Retrieve a file or folder from the container in the form of a tar archive. Args: path (str): Path to the file or folder to retrieve chunk_size (int): The...
Retrieve a file or folder from the container in the form of a tar archive. Args: path (str): Path to the file or folder to retrieve chunk_size (int): The number of bytes returned by each iteration of the generator. If ``None``, data will be streamed as i...
get_archive
python
docker/docker-py
docker/models/containers.py
https://github.com/docker/docker-py/blob/master/docker/models/containers.py
Apache-2.0
def create(self, image, command=None, **kwargs): """ Create a container without starting it. Similar to ``docker create``. Takes the same arguments as :py:meth:`run`, except for ``stdout``, ``stderr``, and ``remove``. Returns: A :py:class:`Container` object. ...
Create a container without starting it. Similar to ``docker create``. Takes the same arguments as :py:meth:`run`, except for ``stdout``, ``stderr``, and ``remove``. Returns: A :py:class:`Container` object. Raises: :py:class:`docker.errors.ImageNotFound...
create
python
docker/docker-py
docker/models/containers.py
https://github.com/docker/docker-py/blob/master/docker/models/containers.py
Apache-2.0
def _create_container_args(kwargs): """ Convert arguments to create() to arguments to create_container(). """ # Copy over kwargs which can be copied directly create_kwargs = {} for key in copy.copy(kwargs): if key in RUN_CREATE_KWARGS: create_kwargs[key] = kwargs.pop(key) ...
Convert arguments to create() to arguments to create_container().
_create_container_args
python
docker/docker-py
docker/models/containers.py
https://github.com/docker/docker-py/blob/master/docker/models/containers.py
Apache-2.0
def labels(self): """ The labels of an image as dictionary. """ result = self.attrs['Config'].get('Labels') return result or {}
The labels of an image as dictionary.
labels
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def short_id(self): """ The ID of the image truncated to 12 characters, plus the ``sha256:`` prefix. """ if self.id.startswith('sha256:'): return self.id[:19] return self.id[:12]
The ID of the image truncated to 12 characters, plus the ``sha256:`` prefix.
short_id
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def remove(self, force=False, noprune=False): """ Remove this image. Args: force (bool): Force removal of the image noprune (bool): Do not delete untagged parents Raises: :py:class:`docker.errors.APIError` If the server returns an err...
Remove this image. Args: force (bool): Force removal of the image noprune (bool): Do not delete untagged parents Raises: :py:class:`docker.errors.APIError` If the server returns an error.
remove
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def save(self, chunk_size=DEFAULT_DATA_CHUNK_SIZE, named=False): """ Get a tarball of an image. Similar to the ``docker save`` command. Args: chunk_size (int): The generator will return up to that much data per iteration, but may return less. If ``None``, data will b...
Get a tarball of an image. Similar to the ``docker save`` command. Args: chunk_size (int): The generator will return up to that much data per iteration, but may return less. If ``None``, data will be streamed as it is received. Default: 2 MB name...
save
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def pull(self, platform=None): """ Pull the image digest. Args: platform (str): The platform to pull the image for. Default: ``None`` Returns: (:py:class:`Image`): A reference to the pulled image. """ repository, _ = parse_repository_...
Pull the image digest. Args: platform (str): The platform to pull the image for. Default: ``None`` Returns: (:py:class:`Image`): A reference to the pulled image.
pull
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def has_platform(self, platform): """ Check whether the given platform identifier is available for this digest. Args: platform (str or dict): A string using the ``os[/arch[/variant]]`` format, or a platform dictionary. Returns: (bool): ``...
Check whether the given platform identifier is available for this digest. Args: platform (str or dict): A string using the ``os[/arch[/variant]]`` format, or a platform dictionary. Returns: (bool): ``True`` if the platform is recognized as avail...
has_platform
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def get_registry_data(self, name, auth_config=None): """ Gets the registry data for an image. Args: name (str): The name of the image. auth_config (dict): Override the credentials that are found in the config for this request. ``auth_config`` should cont...
Gets the registry data for an image. Args: name (str): The name of the image. auth_config (dict): Override the credentials that are found in the config for this request. ``auth_config`` should contain the ``username`` and ``password`` keys to be...
get_registry_data
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def list(self, name=None, all=False, filters=None): """ List images on the server. Args: name (str): Only show images belonging to the repository ``name`` all (bool): Show intermediate image layers. By default, these are filtered out. filters ...
List images on the server. Args: name (str): Only show images belonging to the repository ``name`` all (bool): Show intermediate image layers. By default, these are filtered out. filters (dict): Filters to be processed on the image list. ...
list
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def load(self, data): """ Load an image that was previously saved using :py:meth:`~docker.models.images.Image.save` (or ``docker save``). Similar to ``docker load``. Args: data (binary): Image data to be loaded. Returns: (list of :py:class:`Image...
Load an image that was previously saved using :py:meth:`~docker.models.images.Image.save` (or ``docker save``). Similar to ``docker load``. Args: data (binary): Image data to be loaded. Returns: (list of :py:class:`Image`): The images. Raises: ...
load
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def pull(self, repository, tag=None, all_tags=False, **kwargs): """ Pull an image of the given name and return it. Similar to the ``docker pull`` command. If ``tag`` is ``None`` or empty, it is set to ``latest``. If ``all_tags`` is set, the ``tag`` parameter is ignored and all im...
Pull an image of the given name and return it. Similar to the ``docker pull`` command. If ``tag`` is ``None`` or empty, it is set to ``latest``. If ``all_tags`` is set, the ``tag`` parameter is ignored and all image tags will be pulled. If you want to get the raw pull o...
pull
python
docker/docker-py
docker/models/images.py
https://github.com/docker/docker-py/blob/master/docker/models/images.py
Apache-2.0
def containers(self): """ The containers that are connected to the network, as a list of :py:class:`~docker.models.containers.Container` objects. """ return [ self.client.containers.get(cid) for cid in (self.attrs.get('Containers') or {}).keys() ]
The containers that are connected to the network, as a list of :py:class:`~docker.models.containers.Container` objects.
containers
python
docker/docker-py
docker/models/networks.py
https://github.com/docker/docker-py/blob/master/docker/models/networks.py
Apache-2.0
def connect(self, container, *args, **kwargs): """ Connect a container to this network. Args: container (str): Container to connect to this network, as either an ID, name, or :py:class:`~docker.models.containers.Container` object. aliases ...
Connect a container to this network. Args: container (str): Container to connect to this network, as either an ID, name, or :py:class:`~docker.models.containers.Container` object. aliases (:py:class:`list`): A list of aliases for this endpoint. ...
connect
python
docker/docker-py
docker/models/networks.py
https://github.com/docker/docker-py/blob/master/docker/models/networks.py
Apache-2.0
def disconnect(self, container, *args, **kwargs): """ Disconnect a container from this network. Args: container (str): Container to disconnect from this network, as either an ID, name, or :py:class:`~docker.models.containers.Container` object. ...
Disconnect a container from this network. Args: container (str): Container to disconnect from this network, as either an ID, name, or :py:class:`~docker.models.containers.Container` object. force (bool): Force the container to disconnect from a n...
disconnect
python
docker/docker-py
docker/models/networks.py
https://github.com/docker/docker-py/blob/master/docker/models/networks.py
Apache-2.0
def get(self, network_id, *args, **kwargs): """ Get a network by its ID. Args: network_id (str): The ID of the network. verbose (bool): Retrieve the service details across the cluster in swarm mode. scope (str): Filter the network by scope (``...
Get a network by its ID. Args: network_id (str): The ID of the network. verbose (bool): Retrieve the service details across the cluster in swarm mode. scope (str): Filter the network by scope (``swarm``, ``global`` or ``local``). ...
get
python
docker/docker-py
docker/models/networks.py
https://github.com/docker/docker-py/blob/master/docker/models/networks.py
Apache-2.0
def list(self, *args, **kwargs): """ List networks. Similar to the ``docker network ls`` command. Args: names (:py:class:`list`): List of names to filter by. ids (:py:class:`list`): List of ids to filter by. filters (dict): Filters to be processed on the netw...
List networks. Similar to the ``docker network ls`` command. Args: names (:py:class:`list`): List of names to filter by. ids (:py:class:`list`): List of ids to filter by. filters (dict): Filters to be processed on the network list. Available filters:...
list
python
docker/docker-py
docker/models/networks.py
https://github.com/docker/docker-py/blob/master/docker/models/networks.py
Apache-2.0
def list(self, *args, **kwargs): """ List swarm nodes. Args: filters (dict): Filters to process on the nodes list. Valid filters: ``id``, ``name``, ``membership`` and ``role``. Default: ``None`` Returns: A list of :py:class:`Node`...
List swarm nodes. Args: filters (dict): Filters to process on the nodes list. Valid filters: ``id``, ``name``, ``membership`` and ``role``. Default: ``None`` Returns: A list of :py:class:`Node` objects. Raises: :py:c...
list
python
docker/docker-py
docker/models/nodes.py
https://github.com/docker/docker-py/blob/master/docker/models/nodes.py
Apache-2.0
def list(self): """ List plugins installed on the server. Returns: (list of :py:class:`Plugin`): The plugins. Raises: :py:class:`docker.errors.APIError` If the server returns an error. """ resp = self.client.api.plugins() ...
List plugins installed on the server. Returns: (list of :py:class:`Plugin`): The plugins. Raises: :py:class:`docker.errors.APIError` If the server returns an error.
list
python
docker/docker-py
docker/models/plugins.py
https://github.com/docker/docker-py/blob/master/docker/models/plugins.py
Apache-2.0
def reload(self): """ Load this object from the server again and update ``attrs`` with the new data. """ new_model = self.collection.get(self.id) self.attrs = new_model.attrs
Load this object from the server again and update ``attrs`` with the new data.
reload
python
docker/docker-py
docker/models/resource.py
https://github.com/docker/docker-py/blob/master/docker/models/resource.py
Apache-2.0
def prepare_model(self, attrs): """ Create a model from a set of attributes. """ if isinstance(attrs, Model): attrs.client = self.client attrs.collection = self return attrs elif isinstance(attrs, dict): return self.model(attrs=attr...
Create a model from a set of attributes.
prepare_model
python
docker/docker-py
docker/models/resource.py
https://github.com/docker/docker-py/blob/master/docker/models/resource.py
Apache-2.0
def list(self, **kwargs): """ List secrets. Similar to the ``docker secret ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Secret`): The secrets. Raises: :py:class:`docker.errors.APIError`...
List secrets. Similar to the ``docker secret ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Secret`): The secrets. Raises: :py:class:`docker.errors.APIError` If the server return...
list
python
docker/docker-py
docker/models/secrets.py
https://github.com/docker/docker-py/blob/master/docker/models/secrets.py
Apache-2.0
def tasks(self, filters=None): """ List the tasks in this service. Args: filters (dict): A map of filters to process on the tasks list. Valid filters: ``id``, ``name``, ``node``, ``label``, and ``desired-state``. Returns: :py:clas...
List the tasks in this service. Args: filters (dict): A map of filters to process on the tasks list. Valid filters: ``id``, ``name``, ``node``, ``label``, and ``desired-state``. Returns: :py:class:`list`: List of task dictionaries. ...
tasks
python
docker/docker-py
docker/models/services.py
https://github.com/docker/docker-py/blob/master/docker/models/services.py
Apache-2.0
def update(self, **kwargs): """ Update a service's configuration. Similar to the ``docker service update`` command. Takes the same parameters as :py:meth:`~ServiceCollection.create`. Raises: :py:class:`docker.errors.APIError` If the server returns an...
Update a service's configuration. Similar to the ``docker service update`` command. Takes the same parameters as :py:meth:`~ServiceCollection.create`. Raises: :py:class:`docker.errors.APIError` If the server returns an error.
update
python
docker/docker-py
docker/models/services.py
https://github.com/docker/docker-py/blob/master/docker/models/services.py
Apache-2.0
def logs(self, **kwargs): """ Get log stream for the service. Note: This method works only for services with the ``json-file`` or ``journald`` logging drivers. Args: details (bool): Show extra details provided to logs. Default: ``False`` f...
Get log stream for the service. Note: This method works only for services with the ``json-file`` or ``journald`` logging drivers. Args: details (bool): Show extra details provided to logs. Default: ``False`` follow (bool): Keep connection open to...
logs
python
docker/docker-py
docker/models/services.py
https://github.com/docker/docker-py/blob/master/docker/models/services.py
Apache-2.0
def scale(self, replicas): """ Scale service container. Args: replicas (int): The number of containers that should be running. Returns: bool: ``True`` if successful. """ if 'Global' in self.attrs['Spec']['Mode'].keys(): raise Invalid...
Scale service container. Args: replicas (int): The number of containers that should be running. Returns: bool: ``True`` if successful.
scale
python
docker/docker-py
docker/models/services.py
https://github.com/docker/docker-py/blob/master/docker/models/services.py
Apache-2.0
def get(self, service_id, insert_defaults=None): """ Get a service. Args: service_id (str): The ID of the service. insert_defaults (boolean): If true, default values will be merged into the output. Returns: :py:class:`Service`: The se...
Get a service. Args: service_id (str): The ID of the service. insert_defaults (boolean): If true, default values will be merged into the output. Returns: :py:class:`Service`: The service. Raises: :py:class:`docker.errors...
get
python
docker/docker-py
docker/models/services.py
https://github.com/docker/docker-py/blob/master/docker/models/services.py
Apache-2.0
def list(self, **kwargs): """ List services. Args: filters (dict): Filters to process on the nodes list. Valid filters: ``id``, ``name`` , ``label`` and ``mode``. Default: ``None``. status (bool): Include the service task count of running ...
List services. Args: filters (dict): Filters to process on the nodes list. Valid filters: ``id``, ``name`` , ``label`` and ``mode``. Default: ``None``. status (bool): Include the service task count of running and desired tasks. De...
list
python
docker/docker-py
docker/models/services.py
https://github.com/docker/docker-py/blob/master/docker/models/services.py
Apache-2.0
def update(self, rotate_worker_token=False, rotate_manager_token=False, rotate_manager_unlock_key=False, **kwargs): """ Update the swarm's configuration. It takes the same arguments as :py:meth:`init`, except ``advertise_addr``, ``listen_addr``, and ``force_new_cluster``....
Update the swarm's configuration. It takes the same arguments as :py:meth:`init`, except ``advertise_addr``, ``listen_addr``, and ``force_new_cluster``. In addition, it takes these arguments: Args: rotate_worker_token (bool): Rotate the worker join token. Default: ...
update
python
docker/docker-py
docker/models/swarm.py
https://github.com/docker/docker-py/blob/master/docker/models/swarm.py
Apache-2.0
def list(self, **kwargs): """ List volumes. Similar to the ``docker volume ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Volume`): The volumes. Raises: :py:class:`docker.errors.APIError`...
List volumes. Similar to the ``docker volume ls`` command. Args: filters (dict): Server-side list filtering options. Returns: (list of :py:class:`Volume`): The volumes. Raises: :py:class:`docker.errors.APIError` If the server return...
list
python
docker/docker-py
docker/models/volumes.py
https://github.com/docker/docker-py/blob/master/docker/models/volumes.py
Apache-2.0
def exclude_paths(root, patterns, dockerfile=None): """ Given a root directory path and a list of .dockerignore patterns, return an iterator of all paths (both regular files and directories) in the root directory that do *not* match any of the patterns. All paths returned are relative to the root. ...
Given a root directory path and a list of .dockerignore patterns, return an iterator of all paths (both regular files and directories) in the root directory that do *not* match any of the patterns. All paths returned are relative to the root.
exclude_paths
python
docker/docker-py
docker/utils/build.py
https://github.com/docker/docker-py/blob/master/docker/utils/build.py
Apache-2.0
def home_dir(): """ Get the user's home directory, using the same logic as the Docker Engine client - use %USERPROFILE% on Windows, $HOME/getuid on POSIX. """ if IS_WINDOWS_PLATFORM: return os.environ.get('USERPROFILE', '') else: return os.path.expanduser('~')
Get the user's home directory, using the same logic as the Docker Engine client - use %USERPROFILE% on Windows, $HOME/getuid on POSIX.
home_dir
python
docker/docker-py
docker/utils/config.py
https://github.com/docker/docker-py/blob/master/docker/utils/config.py
Apache-2.0
def fnmatchcase(name, pat): """Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize its arguments. """ try: re_pat = _cache[pat] except KeyError: res = translate(pat) if len(_cache) >= _MAXCACHE: _...
Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize its arguments.
fnmatchcase
python
docker/docker-py
docker/utils/fnmatch.py
https://github.com/docker/docker-py/blob/master/docker/utils/fnmatch.py
Apache-2.0
def stream_as_text(stream): """ Given a stream of bytes or text, if any of the items in the stream are bytes convert them to text. This function can be removed once we return text streams instead of byte streams. """ for data in stream: if not isinstance(data, str): data ...
Given a stream of bytes or text, if any of the items in the stream are bytes convert them to text. This function can be removed once we return text streams instead of byte streams.
stream_as_text
python
docker/docker-py
docker/utils/json_stream.py
https://github.com/docker/docker-py/blob/master/docker/utils/json_stream.py
Apache-2.0
def split_buffer(stream, splitter=None, decoder=lambda a: a): """Given a generator which yields strings and a splitter function, joins all input, splits on the separator and yields each chunk. Unlike string.split(), each chunk includes the trailing separator, except for the last one if none was found on...
Given a generator which yields strings and a splitter function, joins all input, splits on the separator and yields each chunk. Unlike string.split(), each chunk includes the trailing separator, except for the last one if none was found on the end of the input.
split_buffer
python
docker/docker-py
docker/utils/json_stream.py
https://github.com/docker/docker-py/blob/master/docker/utils/json_stream.py
Apache-2.0
def from_dict(config): ''' Instantiate a new ProxyConfig from a dictionary that represents a client configuration, as described in `the documentation`_. .. _the documentation: https://docs.docker.com/network/proxy/#configure-the-docker-client ''' return Proxy...
Instantiate a new ProxyConfig from a dictionary that represents a client configuration, as described in `the documentation`_. .. _the documentation: https://docs.docker.com/network/proxy/#configure-the-docker-client
from_dict
python
docker/docker-py
docker/utils/proxy.py
https://github.com/docker/docker-py/blob/master/docker/utils/proxy.py
Apache-2.0
def get_environment(self): ''' Return a dictionary representing the environment variables used to set the proxy settings. ''' env = {} if self.http: env['http_proxy'] = env['HTTP_PROXY'] = self.http if self.https: env['https_proxy'] = env['...
Return a dictionary representing the environment variables used to set the proxy settings.
get_environment
python
docker/docker-py
docker/utils/proxy.py
https://github.com/docker/docker-py/blob/master/docker/utils/proxy.py
Apache-2.0
def inject_proxy_environment(self, environment): ''' Given a list of strings representing environment variables, prepend the environment variables corresponding to the proxy settings. ''' if not self: return environment proxy_env = format_environment(self.get...
Given a list of strings representing environment variables, prepend the environment variables corresponding to the proxy settings.
inject_proxy_environment
python
docker/docker-py
docker/utils/proxy.py
https://github.com/docker/docker-py/blob/master/docker/utils/proxy.py
Apache-2.0
def read(socket, n=4096): """ Reads at most n bytes from socket """ recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK) if not isinstance(socket, NpipeSocket): if not hasattr(select, "poll"): # Limited to 1024 select.select([socket], [], []) ...
Reads at most n bytes from socket
read
python
docker/docker-py
docker/utils/socket.py
https://github.com/docker/docker-py/blob/master/docker/utils/socket.py
Apache-2.0
def read_exactly(socket, n): """ Reads exactly n bytes from socket Raises SocketError if there isn't enough data """ data = b"" while len(data) < n: next_data = read(socket, n - len(data)) if not next_data: raise SocketError("Unexpected EOF") data += next_data...
Reads exactly n bytes from socket Raises SocketError if there isn't enough data
read_exactly
python
docker/docker-py
docker/utils/socket.py
https://github.com/docker/docker-py/blob/master/docker/utils/socket.py
Apache-2.0
def next_frame_header(socket): """ Returns the stream and size of the next frame of data waiting to be read from socket, according to the protocol defined here: https://docs.docker.com/engine/api/v1.24/#attach-to-a-container """ try: data = read_exactly(socket, 8) except SocketError...
Returns the stream and size of the next frame of data waiting to be read from socket, according to the protocol defined here: https://docs.docker.com/engine/api/v1.24/#attach-to-a-container
next_frame_header
python
docker/docker-py
docker/utils/socket.py
https://github.com/docker/docker-py/blob/master/docker/utils/socket.py
Apache-2.0
def frames_iter(socket, tty): """ Return a generator of frames read from socket. A frame is a tuple where the first item is the stream number and the second item is a chunk of data. If the tty setting is enabled, the streams are multiplexed into the stdout stream. """ if tty: return...
Return a generator of frames read from socket. A frame is a tuple where the first item is the stream number and the second item is a chunk of data. If the tty setting is enabled, the streams are multiplexed into the stdout stream.
frames_iter
python
docker/docker-py
docker/utils/socket.py
https://github.com/docker/docker-py/blob/master/docker/utils/socket.py
Apache-2.0
def frames_iter_no_tty(socket): """ Returns a generator of data read from the socket when the tty setting is not enabled. """ while True: (stream, n) = next_frame_header(socket) if n < 0: break while n > 0: result = read(socket, n) if resul...
Returns a generator of data read from the socket when the tty setting is not enabled.
frames_iter_no_tty
python
docker/docker-py
docker/utils/socket.py
https://github.com/docker/docker-py/blob/master/docker/utils/socket.py
Apache-2.0
def frames_iter_tty(socket): """ Return a generator of data read from the socket when the tty setting is enabled. """ while True: result = read(socket) if len(result) == 0: # We have reached EOF return yield result
Return a generator of data read from the socket when the tty setting is enabled.
frames_iter_tty
python
docker/docker-py
docker/utils/socket.py
https://github.com/docker/docker-py/blob/master/docker/utils/socket.py
Apache-2.0
def consume_socket_output(frames, demux=False): """ Iterate through frames read from the socket and return the result. Args: demux (bool): If False, stdout and stderr are multiplexed, and the result is the concatenation of all the frames. If True, the streams are ...
Iterate through frames read from the socket and return the result. Args: demux (bool): If False, stdout and stderr are multiplexed, and the result is the concatenation of all the frames. If True, the streams are demultiplexed, and the result is a 2-tuple where each...
consume_socket_output
python
docker/docker-py
docker/utils/socket.py
https://github.com/docker/docker-py/blob/master/docker/utils/socket.py
Apache-2.0
def demux_adaptor(stream_id, data): """ Utility to demultiplex stdout and stderr when reading frames from the socket. """ if stream_id == STDOUT: return (data, None) elif stream_id == STDERR: return (None, data) else: raise ValueError(f'{stream_id} is not a valid stre...
Utility to demultiplex stdout and stderr when reading frames from the socket.
demux_adaptor
python
docker/docker-py
docker/utils/socket.py
https://github.com/docker/docker-py/blob/master/docker/utils/socket.py
Apache-2.0
def parse_env_file(env_file): """ Reads a line-separated environment file. The format of each line should be "key=value". """ environment = {} with open(env_file) as f: for line in f: if line[0] == '#': continue line = line.strip() i...
Reads a line-separated environment file. The format of each line should be "key=value".
parse_env_file
python
docker/docker-py
docker/utils/utils.py
https://github.com/docker/docker-py/blob/master/docker/utils/utils.py
Apache-2.0
def order(self): """Return a representation that allows this object to be sorted correctly with the default comparator. """ # non-GA releases should appear before GA releases # Order: tp -> beta -> rc -> GA if self.stage: for st in STAGES: if s...
Return a representation that allows this object to be sorted correctly with the default comparator.
order
python
docker/docker-py
scripts/versions.py
https://github.com/docker/docker-py/blob/master/scripts/versions.py
Apache-2.0
def force_leave_swarm(client): """Actually force leave a Swarm. There seems to be a bug in Swarm that occasionally throws "context deadline exceeded" errors when leaving.""" while True: try: if isinstance(client, docker.DockerClient): return client.swarm.leave(force=True)...
Actually force leave a Swarm. There seems to be a bug in Swarm that occasionally throws "context deadline exceeded" errors when leaving.
force_leave_swarm
python
docker/docker-py
tests/helpers.py
https://github.com/docker/docker-py/blob/master/tests/helpers.py
Apache-2.0
def test_resource_warnings(self): """ Test no warnings are produced when using the client. """ with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') client = docker.APIClient(version='auto', **kwargs_from_env()) client.image...
Test no warnings are produced when using the client.
test_resource_warnings
python
docker/docker-py
tests/integration/api_client_test.py
https://github.com/docker/docker-py/blob/master/tests/integration/api_client_test.py
Apache-2.0
def dummy_tar_stream(self, n_bytes): '''Yields a stream that is valid tar data of size n_bytes.''' with tempfile.NamedTemporaryFile() as tar_file: self.write_dummy_tar_content(n_bytes, tar_file) tar_file.seek(0) yield tar_file
Yields a stream that is valid tar data of size n_bytes.
dummy_tar_stream
python
docker/docker-py
tests/integration/api_image_test.py
https://github.com/docker/docker-py/blob/master/tests/integration/api_image_test.py
Apache-2.0
def dummy_tar_file(self, n_bytes): '''Yields the name of a valid tar file of size n_bytes.''' with tempfile.NamedTemporaryFile(delete=False) as tar_file: self.write_dummy_tar_content(n_bytes, tar_file) tar_file.seek(0) yield tar_file.name
Yields the name of a valid tar file of size n_bytes.
dummy_tar_file
python
docker/docker-py
tests/integration/api_image_test.py
https://github.com/docker/docker-py/blob/master/tests/integration/api_image_test.py
Apache-2.0
def temporary_http_file_server(self, stream): '''Serve data from an IO stream over HTTP.''' class Handler(SimpleHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header('Content-Type', 'application/x-tar') self.end_heade...
Serve data from an IO stream over HTTP.
temporary_http_file_server
python
docker/docker-py
tests/integration/api_image_test.py
https://github.com/docker/docker-py/blob/master/tests/integration/api_image_test.py
Apache-2.0
def test_disable_socket_timeout(self): """Test that the timeout is disabled on a generic socket object.""" socket = self.DummySocket() self.client._disable_socket_timeout(socket) assert socket.timeout is None
Test that the timeout is disabled on a generic socket object.
test_disable_socket_timeout
python
docker/docker-py
tests/unit/api_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/api_test.py
Apache-2.0
def test_disable_socket_timeout2(self): """Test that the timeouts are disabled on a generic socket object and it's _sock object if present.""" socket = self.DummySocket() socket._sock = self.DummySocket() self.client._disable_socket_timeout(socket) assert socket.timeout...
Test that the timeouts are disabled on a generic socket object and it's _sock object if present.
test_disable_socket_timeout2
python
docker/docker-py
tests/unit/api_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/api_test.py
Apache-2.0
def test_disable_socket_timout_non_blocking(self): """Test that a non-blocking socket does not get set to blocking.""" socket = self.DummySocket() socket._sock = self.DummySocket(0.0) self.client._disable_socket_timeout(socket) assert socket.timeout is None assert socke...
Test that a non-blocking socket does not get set to blocking.
test_disable_socket_timout_non_blocking
python
docker/docker-py
tests/unit/api_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/api_test.py
Apache-2.0
def test_from_env(self): """Test that environment variables are passed through to utils.kwargs_from_env(). KwargsFromEnvTest tests that environment variables are parsed correctly.""" os.environ.update(DOCKER_HOST='tcp://192.168.59.103:2376', DOCKER_CERT_PATH=TES...
Test that environment variables are passed through to utils.kwargs_from_env(). KwargsFromEnvTest tests that environment variables are parsed correctly.
test_from_env
python
docker/docker-py
tests/unit/client_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/client_test.py
Apache-2.0
def test_status_code_200(self): """The status_code property is present with 200 response.""" resp = requests.Response() resp.status_code = 200 err = APIError('', response=resp) assert err.status_code == 200
The status_code property is present with 200 response.
test_status_code_200
python
docker/docker-py
tests/unit/errors_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/errors_test.py
Apache-2.0
def test_status_code_400(self): """The status_code property is present with 400 response.""" resp = requests.Response() resp.status_code = 400 err = APIError('', response=resp) assert err.status_code == 400
The status_code property is present with 400 response.
test_status_code_400
python
docker/docker-py
tests/unit/errors_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/errors_test.py
Apache-2.0
def test_status_code_500(self): """The status_code property is present with 500 response.""" resp = requests.Response() resp.status_code = 500 err = APIError('', response=resp) assert err.status_code == 500
The status_code property is present with 500 response.
test_status_code_500
python
docker/docker-py
tests/unit/errors_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/errors_test.py
Apache-2.0
def test_is_server_error_200(self): """Report not server error on 200 response.""" resp = requests.Response() resp.status_code = 200 err = APIError('', response=resp) assert err.is_server_error() is False
Report not server error on 200 response.
test_is_server_error_200
python
docker/docker-py
tests/unit/errors_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/errors_test.py
Apache-2.0
def test_is_server_error_300(self): """Report not server error on 300 response.""" resp = requests.Response() resp.status_code = 300 err = APIError('', response=resp) assert err.is_server_error() is False
Report not server error on 300 response.
test_is_server_error_300
python
docker/docker-py
tests/unit/errors_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/errors_test.py
Apache-2.0
def test_is_server_error_400(self): """Report not server error on 400 response.""" resp = requests.Response() resp.status_code = 400 err = APIError('', response=resp) assert err.is_server_error() is False
Report not server error on 400 response.
test_is_server_error_400
python
docker/docker-py
tests/unit/errors_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/errors_test.py
Apache-2.0
def test_is_client_error_500(self): """Report not client error on 500 response.""" resp = requests.Response() resp.status_code = 500 err = APIError('', response=resp) assert err.is_client_error() is False
Report not client error on 500 response.
test_is_client_error_500
python
docker/docker-py
tests/unit/errors_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/errors_test.py
Apache-2.0
def test_container_without_stderr(self): """The massage does not contain stderr""" client = make_fake_client() container = client.containers.get(FAKE_CONTAINER_ID) command = "echo Hello World" exit_status = 42 image = FAKE_IMAGE_ID stderr = None err = Con...
The massage does not contain stderr
test_container_without_stderr
python
docker/docker-py
tests/unit/errors_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/errors_test.py
Apache-2.0
def make_fake_api_client(overrides=None): """ Returns non-complete fake APIClient. This returns most of the default cases correctly, but most arguments that change behaviour will not work. """ if overrides is None: overrides = {} api_client = docker.APIClient(version=DEFAULT_DOCKER...
Returns non-complete fake APIClient. This returns most of the default cases correctly, but most arguments that change behaviour will not work.
make_fake_api_client
python
docker/docker-py
tests/unit/fake_api_client.py
https://github.com/docker/docker-py/blob/master/tests/unit/fake_api_client.py
Apache-2.0
def test_exclude_custom_dockerfile(self): """ If we're using a custom Dockerfile, make sure that's not excluded. """ assert self.exclude(['*'], dockerfile='Dockerfile.alt') == { 'Dockerfile.alt', '.dockerignore' } assert self.exclude( ['*'...
If we're using a custom Dockerfile, make sure that's not excluded.
test_exclude_custom_dockerfile
python
docker/docker-py
tests/unit/utils_build_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/utils_build_test.py
Apache-2.0
def generate_tempfile(self, file_content=None): """ Generates a temporary file for tests with the content of 'file_content' and returns the filename. Don't forget to unlink the file with os.unlink() after. """ local_tempfile = tempfile.NamedTemporaryFile(delete=False) ...
Generates a temporary file for tests with the content of 'file_content' and returns the filename. Don't forget to unlink the file with os.unlink() after.
generate_tempfile
python
docker/docker-py
tests/unit/utils_test.py
https://github.com/docker/docker-py/blob/master/tests/unit/utils_test.py
Apache-2.0
def literalise(ctx: Context) -> None: """ Write various literals in the `colour.hints` module. Parameters ---------- ctx Context. """ message_box("Literalising...") with ctx.cd("utilities"): ctx.run("./literalise.py") ctx.run("pre-commit run --files colour/hints/__...
Write various literals in the `colour.hints` module. Parameters ---------- ctx Context.
literalise
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def clean( ctx: Context, docs: bool = True, bytecode: bool = False, pytest: bool = True, ) -> None: """ Clean the project. Parameters ---------- ctx Context. docs Whether to clean the *docs* directory. bytecode Whether to clean the bytecode files, e.g...
Clean the project. Parameters ---------- ctx Context. docs Whether to clean the *docs* directory. bytecode Whether to clean the bytecode files, e.g., *.pyc* files. pytest Whether to clean the *Pytest* cache directory.
clean
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def formatting( ctx: Context, asciify: bool = True, bibtex: bool = True, ) -> None: """ Convert unicode characters to ASCII and cleanup the *BibTeX* file. Parameters ---------- ctx Context. asciify Whether to convert unicode characters to ASCII. bibtex Wh...
Convert unicode characters to ASCII and cleanup the *BibTeX* file. Parameters ---------- ctx Context. asciify Whether to convert unicode characters to ASCII. bibtex Whether to cleanup the *BibTeX* file.
formatting
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def quality( ctx: Context, pyright: bool = True, rstlint: bool = True, ) -> None: """ Check the codebase with *Pyright* and lints various *restructuredText* files with *rst-lint*. Parameters ---------- ctx Context. pyright Whether to check the codebase with *Pyri...
Check the codebase with *Pyright* and lints various *restructuredText* files with *rst-lint*. Parameters ---------- ctx Context. pyright Whether to check the codebase with *Pyright*. rstlint Whether to lint various *restructuredText* files with *rst-lint*.
quality
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def tests(ctx: Context) -> None: """ Run the unit tests with *Pytest*. Parameters ---------- ctx Context. """ message_box('Running "Pytest"...') ctx.run( "pytest " "--doctest-modules " f"--ignore={PYTHON_PACKAGE_NAME}/examples " f"--cov={PYTHON_P...
Run the unit tests with *Pytest*. Parameters ---------- ctx Context.
tests
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def examples(ctx: Context, plots: bool = False) -> None: """ Run the examples. Parameters ---------- ctx Context. plots Whether to skip or only run the plotting examples: This a mutually exclusive switch. """ message_box("Running examples...") for root, _di...
Run the examples. Parameters ---------- ctx Context. plots Whether to skip or only run the plotting examples: This a mutually exclusive switch.
examples
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def docs( ctx: Context, plots: bool = True, html: bool = True, pdf: bool = True, ) -> None: """ Build the documentation. Parameters ---------- ctx Context. plots Whether to generate the documentation plots. html Whether to build the *HTML* documentati...
Build the documentation. Parameters ---------- ctx Context. plots Whether to generate the documentation plots. html Whether to build the *HTML* documentation. pdf Whether to build the *PDF* documentation.
docs
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def todo(ctx: Context) -> None: """ Export the TODO items. Parameters ---------- ctx Context. """ message_box('Exporting "TODO" items...') with ctx.cd("utilities"): ctx.run("./export_todo.py")
Export the TODO items. Parameters ---------- ctx Context.
todo
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def requirements(ctx: Context) -> None: """ Export the *requirements.txt* file. Parameters ---------- ctx Context. """ message_box('Exporting "requirements.txt" file...') ctx.run('uv export --no-hashes --all-extras | grep -v "-e \\." > requirements.txt') message_box('Expor...
Export the *requirements.txt* file. Parameters ---------- ctx Context.
requirements
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def build(ctx: Context) -> None: """ Build the project and runs dependency tasks. Parameters ---------- ctx Context. """ message_box("Building...") if "modified: README.rst" in ctx.run("git status").stdout: # pyright: ignore error = 'Please commit your changes to the...
Build the project and runs dependency tasks. Parameters ---------- ctx Context.
build
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def virtualise(ctx: Context, tests: bool = True) -> None: """ Create a virtual environment for the project build. Parameters ---------- ctx Context. tests Whether to run tests on the virtual environment. """ unique_name = f"{PYPI_PACKAGE_NAME}-{uuid.uuid1()}" with c...
Create a virtual environment for the project build. Parameters ---------- ctx Context. tests Whether to run tests on the virtual environment.
virtualise
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def tag(ctx: Context) -> None: """ Tag the repository according to defined version using *git-flow*. Parameters ---------- ctx Context. """ message_box("Tagging...") result = ctx.run("git rev-parse --abbrev-ref HEAD", hide="both") if result.stdout.strip() != "develop": # ...
Tag the repository according to defined version using *git-flow*. Parameters ---------- ctx Context.
tag
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def release(ctx: Context) -> None: """ Release the project to *Pypi* with *Twine*. Parameters ---------- ctx Context. """ message_box("Releasing...") with ctx.cd("dist"): ctx.run("twine upload *.tar.gz") ctx.run("twine upload *.whl")
Release the project to *Pypi* with *Twine*. Parameters ---------- ctx Context.
release
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def sha256(ctx: Context) -> None: """ Compute the project *Pypi* package *sha256* with *OpenSSL*. Parameters ---------- ctx Context. """ message_box('Computing "sha256"...') with ctx.cd("dist"): ctx.run(f"openssl sha256 {PYPI_ARCHIVE_NAME}-*.tar.gz")
Compute the project *Pypi* package *sha256* with *OpenSSL*. Parameters ---------- ctx Context.
sha256
python
colour-science/colour
tasks.py
https://github.com/colour-science/colour/blob/master/tasks.py
BSD-3-Clause
def chromatic_adaptation_CIE1994( XYZ_1: ArrayLike, xy_o1: ArrayLike, xy_o2: ArrayLike, Y_o: ArrayLike, E_o1: ArrayLike, E_o2: ArrayLike, n: ArrayLike = 1, ) -> NDArrayFloat: """ Adapt the specified stimulus *CIE XYZ_1* tristimulus values from test viewing conditions to reference...
Adapt the specified stimulus *CIE XYZ_1* tristimulus values from test viewing conditions to reference viewing conditions using *CIE 1994* chromatic adaptation model. Parameters ---------- XYZ_1 *CIE XYZ* tristimulus values of test sample / stimulus. xy_o1 Chromaticity coord...
chromatic_adaptation_CIE1994
python
colour-science/colour
colour/adaptation/cie1994.py
https://github.com/colour-science/colour/blob/master/colour/adaptation/cie1994.py
BSD-3-Clause
def intermediate_values(xy_o: ArrayLike) -> NDArrayFloat: """ Compute the intermediate values :math:`\\xi`, :math:`\\eta`, :math:`\\zeta`. Parameters ---------- xy_o Chromaticity coordinates :math:`x_o` and :math:`y_o` of whitepoint. Returns ------- :class:`numpy.ndarray` ...
Compute the intermediate values :math:`\xi`, :math:`\eta`, :math:`\zeta`. Parameters ---------- xy_o Chromaticity coordinates :math:`x_o` and :math:`y_o` of whitepoint. Returns ------- :class:`numpy.ndarray` Intermediate values :math:`\xi`, :math:`\eta`, :math:`\zeta`....
intermediate_values
python
colour-science/colour
colour/adaptation/cie1994.py
https://github.com/colour-science/colour/blob/master/colour/adaptation/cie1994.py
BSD-3-Clause
def effective_adapting_responses( xez: ArrayLike, Y_o: ArrayLike, E_o: ArrayLike ) -> NDArrayFloat: """ Compute the effective adapting responses in the fundamental primary system of the test or reference field. Parameters ---------- xez Intermediate values :math:`\\xi`, :math:`\\eta...
Compute the effective adapting responses in the fundamental primary system of the test or reference field. Parameters ---------- xez Intermediate values :math:`\xi`, :math:`\eta`, :math:`\zeta`. Y_o Luminance factor :math:`Y_o` of achromatic background as percentage nor...
effective_adapting_responses
python
colour-science/colour
colour/adaptation/cie1994.py
https://github.com/colour-science/colour/blob/master/colour/adaptation/cie1994.py
BSD-3-Clause
def beta_1(x: ArrayLike) -> DTypeFloat | NDArrayFloat: """ Compute the exponent :math:`\\beta_1` for the middle and long-wavelength sensitive cones. Parameters ---------- x Middle and long-wavelength sensitive cone response. Returns ------- :class:`numpy.ndarray` Ex...
Compute the exponent :math:`\beta_1` for the middle and long-wavelength sensitive cones. Parameters ---------- x Middle and long-wavelength sensitive cone response. Returns ------- :class:`numpy.ndarray` Exponent :math:`\beta_1`. Examples -------- >>> beta...
beta_1
python
colour-science/colour
colour/adaptation/cie1994.py
https://github.com/colour-science/colour/blob/master/colour/adaptation/cie1994.py
BSD-3-Clause
def beta_2(x: ArrayLike) -> DTypeFloat | NDArrayFloat: """ Compute the exponent :math:`\\beta_2` for the short-wavelength sensitive cones. Parameters ---------- x Short-wavelength sensitive cone response. Returns ------- :class:`numpy.ndarray` Exponent :math:`\\beta...
Compute the exponent :math:`\beta_2` for the short-wavelength sensitive cones. Parameters ---------- x Short-wavelength sensitive cone response. Returns ------- :class:`numpy.ndarray` Exponent :math:`\beta_2`. Examples -------- >>> beta_2(318.323316315) #...
beta_2
python
colour-science/colour
colour/adaptation/cie1994.py
https://github.com/colour-science/colour/blob/master/colour/adaptation/cie1994.py
BSD-3-Clause
def exponential_factors(RGB_o: ArrayLike) -> NDArrayFloat: """ Compute the chromatic adaptation exponential factors :math:`\\beta_1(R_o)`, :math:`\\beta_1(G_o)` and :math:`\\beta_2(B_o)` of the specified cone responses. Parameters ---------- RGB_o Cone responses. Returns -...
Compute the chromatic adaptation exponential factors :math:`\beta_1(R_o)`, :math:`\beta_1(G_o)` and :math:`\beta_2(B_o)` of the specified cone responses. Parameters ---------- RGB_o Cone responses. Returns ------- :class:`numpy.ndarray` Chromatic adaptation expone...
exponential_factors
python
colour-science/colour
colour/adaptation/cie1994.py
https://github.com/colour-science/colour/blob/master/colour/adaptation/cie1994.py
BSD-3-Clause