repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
insightindustry/validator-collection
validator_collection/checkers.py
are_equivalent
def are_equivalent(*args, **kwargs): """Indicate if arguments passed to this function are equivalent. .. hint:: This checker operates recursively on the members contained within iterables and :class:`dict <python:dict>` objects. .. caution:: If you only pass one argument to this checke...
python
def are_equivalent(*args, **kwargs): """Indicate if arguments passed to this function are equivalent. .. hint:: This checker operates recursively on the members contained within iterables and :class:`dict <python:dict>` objects. .. caution:: If you only pass one argument to this checke...
Indicate if arguments passed to this function are equivalent. .. hint:: This checker operates recursively on the members contained within iterables and :class:`dict <python:dict>` objects. .. caution:: If you only pass one argument to this checker - even if it is an iterable - the ch...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L89-L148
insightindustry/validator-collection
validator_collection/checkers.py
are_dicts_equivalent
def are_dicts_equivalent(*args, **kwargs): """Indicate if :ref:`dicts <python:dict>` passed to this function have identical keys and values. :param args: One or more values, passed as positional arguments. :returns: ``True`` if ``args`` have identical keys/values, and ``False`` if not. :rtype: :cl...
python
def are_dicts_equivalent(*args, **kwargs): """Indicate if :ref:`dicts <python:dict>` passed to this function have identical keys and values. :param args: One or more values, passed as positional arguments. :returns: ``True`` if ``args`` have identical keys/values, and ``False`` if not. :rtype: :cl...
Indicate if :ref:`dicts <python:dict>` passed to this function have identical keys and values. :param args: One or more values, passed as positional arguments. :returns: ``True`` if ``args`` have identical keys/values, and ``False`` if not. :rtype: :class:`bool <python:bool>` :raises SyntaxError:...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L152-L194
insightindustry/validator-collection
validator_collection/checkers.py
is_between
def is_between(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is greater than or equal to a supplied ``minimum`` and/or less than or equal to ``maximum``. .. note:: This function works on any ``value`` that support compari...
python
def is_between(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is greater than or equal to a supplied ``minimum`` and/or less than or equal to ``maximum``. .. note:: This function works on any ``value`` that support compari...
Indicate whether ``value`` is greater than or equal to a supplied ``minimum`` and/or less than or equal to ``maximum``. .. note:: This function works on any ``value`` that support comparison operators, whether they are numbers or not. Technically, this means that ``value``, ``minimum``, or `...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L198-L251
insightindustry/validator-collection
validator_collection/checkers.py
has_length
def has_length(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` has a length greater than or equal to a supplied ``minimum`` and/or less than or equal to ``maximum``. .. note:: This function works on any ``value`` that suppo...
python
def has_length(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` has a length greater than or equal to a supplied ``minimum`` and/or less than or equal to ``maximum``. .. note:: This function works on any ``value`` that suppo...
Indicate whether ``value`` has a length greater than or equal to a supplied ``minimum`` and/or less than or equal to ``maximum``. .. note:: This function works on any ``value`` that supports the :func:`len() <python:len>` operation. This means that ``value`` must implement the :func:`__len__...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L255-L305
insightindustry/validator-collection
validator_collection/checkers.py
is_dict
def is_dict(value, **kwargs): """Indicate whether ``value`` is a valid :class:`dict <python:dict>` .. note:: This will return ``True`` even if ``value`` is an empty :class:`dict <python:dict>`. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it...
python
def is_dict(value, **kwargs): """Indicate whether ``value`` is a valid :class:`dict <python:dict>` .. note:: This will return ``True`` even if ``value`` is an empty :class:`dict <python:dict>`. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it...
Indicate whether ``value`` is a valid :class:`dict <python:dict>` .. note:: This will return ``True`` even if ``value`` is an empty :class:`dict <python:dict>`. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <py...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L309-L336
insightindustry/validator-collection
validator_collection/checkers.py
is_json
def is_json(value, schema = None, json_serializer = None, **kwargs): """Indicate whether ``value`` is a valid JSON object. .. note:: ``schema`` supports JSON Schema Drafts 3 - 7. Unless the JSON Schema indicates the meta-schema using a ``$schema`` property, the ...
python
def is_json(value, schema = None, json_serializer = None, **kwargs): """Indicate whether ``value`` is a valid JSON object. .. note:: ``schema`` supports JSON Schema Drafts 3 - 7. Unless the JSON Schema indicates the meta-schema using a ``$schema`` property, the ...
Indicate whether ``value`` is a valid JSON object. .. note:: ``schema`` supports JSON Schema Drafts 3 - 7. Unless the JSON Schema indicates the meta-schema using a ``$schema`` property, the schema will be assumed to conform to Draft 7. :param value: The value to evaluate. :param schema...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L340-L375
insightindustry/validator-collection
validator_collection/checkers.py
is_string
def is_string(value, coerce_value = False, minimum_length = None, maximum_length = None, whitespace_padding = False, **kwargs): """Indicate whether ``value`` is a string. :param value: The value to evaluate. :param coerce_value: If ``Tr...
python
def is_string(value, coerce_value = False, minimum_length = None, maximum_length = None, whitespace_padding = False, **kwargs): """Indicate whether ``value`` is a string. :param value: The value to evaluate. :param coerce_value: If ``Tr...
Indicate whether ``value`` is a string. :param value: The value to evaluate. :param coerce_value: If ``True``, will check whether ``value`` can be coerced to a string if it is not already. Defaults to ``False``. :type coerce_value: :class:`bool <python:bool>` :param minimum_length: If supplied,...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L379-L436
insightindustry/validator-collection
validator_collection/checkers.py
is_iterable
def is_iterable(obj, forbid_literals = (str, bytes), minimum_length = None, maximum_length = None, **kwargs): """Indicate whether ``obj`` is iterable. :param forbid_literals: A collection of literals that will be considered invalid even if t...
python
def is_iterable(obj, forbid_literals = (str, bytes), minimum_length = None, maximum_length = None, **kwargs): """Indicate whether ``obj`` is iterable. :param forbid_literals: A collection of literals that will be considered invalid even if t...
Indicate whether ``obj`` is iterable. :param forbid_literals: A collection of literals that will be considered invalid even if they are (actually) iterable. Defaults to a :class:`tuple <python:tuple>` containing :class:`str <python:str>` and :class:`bytes <python:bytes>`. :type forbid_literals: ite...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L440-L485
insightindustry/validator-collection
validator_collection/checkers.py
is_not_empty
def is_not_empty(value, **kwargs): """Indicate whether ``value`` is empty. :param value: The value to evaluate. :returns: ``True`` if ``value`` is empty, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplica...
python
def is_not_empty(value, **kwargs): """Indicate whether ``value`` is empty. :param value: The value to evaluate. :returns: ``True`` if ``value`` is empty, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplica...
Indicate whether ``value`` is empty. :param value: The value to evaluate. :returns: ``True`` if ``value`` is empty, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates keyword parameters passed to the...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L489-L508
insightindustry/validator-collection
validator_collection/checkers.py
is_none
def is_none(value, allow_empty = False, **kwargs): """Indicate whether ``value`` is :obj:`None <python:None>`. :param value: The value to evaluate. :param allow_empty: If ``True``, accepts falsey values as equivalent to :obj:`None <python:None>`. Defaults to ``False``. :type allow_empty: :class:...
python
def is_none(value, allow_empty = False, **kwargs): """Indicate whether ``value`` is :obj:`None <python:None>`. :param value: The value to evaluate. :param allow_empty: If ``True``, accepts falsey values as equivalent to :obj:`None <python:None>`. Defaults to ``False``. :type allow_empty: :class:...
Indicate whether ``value`` is :obj:`None <python:None>`. :param value: The value to evaluate. :param allow_empty: If ``True``, accepts falsey values as equivalent to :obj:`None <python:None>`. Defaults to ``False``. :type allow_empty: :class:`bool <python:bool>` :returns: ``True`` if ``value`` ...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L512-L536
insightindustry/validator-collection
validator_collection/checkers.py
is_variable_name
def is_variable_name(value, **kwargs): """Indicate whether ``value`` is a valid Python variable name. .. caution:: This function does **NOT** check whether the variable exists. It only checks that the ``value`` would work as a Python variable (or class, or function, etc.) name. :param v...
python
def is_variable_name(value, **kwargs): """Indicate whether ``value`` is a valid Python variable name. .. caution:: This function does **NOT** check whether the variable exists. It only checks that the ``value`` would work as a Python variable (or class, or function, etc.) name. :param v...
Indicate whether ``value`` is a valid Python variable name. .. caution:: This function does **NOT** check whether the variable exists. It only checks that the ``value`` would work as a Python variable (or class, or function, etc.) name. :param value: The value to evaluate. :returns: ``...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L540-L565
insightindustry/validator-collection
validator_collection/checkers.py
is_uuid
def is_uuid(value, **kwargs): """Indicate whether ``value`` contains a :class:`UUID <python:uuid.UUID>` :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate ...
python
def is_uuid(value, **kwargs): """Indicate whether ``value`` contains a :class:`UUID <python:uuid.UUID>` :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate ...
Indicate whether ``value`` contains a :class:`UUID <python:uuid.UUID>` :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates ...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L585-L604
insightindustry/validator-collection
validator_collection/checkers.py
is_date
def is_date(value, minimum = None, maximum = None, coerce_value = False, **kwargs): """Indicate whether ``value`` is a :class:`date <python:datetime.date>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is on...
python
def is_date(value, minimum = None, maximum = None, coerce_value = False, **kwargs): """Indicate whether ``value`` is a :class:`date <python:datetime.date>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is on...
Indicate whether ``value`` is a :class:`date <python:datetime.date>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is on or after this value. :type minimum: :class:`datetime <python:datetime.datetime>` / :class:`date <python:datetime.date>` / ...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L610-L655
insightindustry/validator-collection
validator_collection/checkers.py
is_datetime
def is_datetime(value, minimum = None, maximum = None, coerce_value = False, **kwargs): """Indicate whether ``value`` is a :class:`datetime <python:datetime.datetime>`. :param value: The value to evaluate. :param minimum: If supplied, will ma...
python
def is_datetime(value, minimum = None, maximum = None, coerce_value = False, **kwargs): """Indicate whether ``value`` is a :class:`datetime <python:datetime.datetime>`. :param value: The value to evaluate. :param minimum: If supplied, will ma...
Indicate whether ``value`` is a :class:`datetime <python:datetime.datetime>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is on or after this value. :type minimum: :class:`datetime <python:datetime.datetime>` / :class:`date <python:datetime.d...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L659-L704
insightindustry/validator-collection
validator_collection/checkers.py
is_time
def is_time(value, minimum = None, maximum = None, coerce_value = False, **kwargs): """Indicate whether ``value`` is a :class:`time <python:datetime.time>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is on...
python
def is_time(value, minimum = None, maximum = None, coerce_value = False, **kwargs): """Indicate whether ``value`` is a :class:`time <python:datetime.time>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is on...
Indicate whether ``value`` is a :class:`time <python:datetime.time>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is on or after this value. :type minimum: :func:`datetime <validator_collection.validators.datetime>` or :func:`time <validator_collec...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L708-L754
insightindustry/validator-collection
validator_collection/checkers.py
is_timezone
def is_timezone(value, positive = True, **kwargs): """Indicate whether ``value`` is a :class:`tzinfo <python:datetime.tzinfo>`. .. caution:: This does **not** validate whether the value is a timezone that actually exists, nor can it resolve timzone names (e.g. ``'Ea...
python
def is_timezone(value, positive = True, **kwargs): """Indicate whether ``value`` is a :class:`tzinfo <python:datetime.tzinfo>`. .. caution:: This does **not** validate whether the value is a timezone that actually exists, nor can it resolve timzone names (e.g. ``'Ea...
Indicate whether ``value`` is a :class:`tzinfo <python:datetime.tzinfo>`. .. caution:: This does **not** validate whether the value is a timezone that actually exists, nor can it resolve timzone names (e.g. ``'Eastern'`` or ``'CET'``). For that kind of functionality, we recommend you utilize: ...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L758-L793
insightindustry/validator-collection
validator_collection/checkers.py
is_numeric
def is_numeric(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is a numeric value. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this value. ...
python
def is_numeric(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is a numeric value. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this value. ...
Indicate whether ``value`` is a numeric value. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this value. :type minimum: numeric :param maximum: If supplied, will make sure that ``value`` is less than or equal to...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L799-L832
insightindustry/validator-collection
validator_collection/checkers.py
is_integer
def is_integer(value, coerce_value = False, minimum = None, maximum = None, base = 10, **kwargs): """Indicate whether ``value`` contains a whole number. :param value: The value to evaluate. :param coerce_value: If ``True``, will re...
python
def is_integer(value, coerce_value = False, minimum = None, maximum = None, base = 10, **kwargs): """Indicate whether ``value`` contains a whole number. :param value: The value to evaluate. :param coerce_value: If ``True``, will re...
Indicate whether ``value`` contains a whole number. :param value: The value to evaluate. :param coerce_value: If ``True``, will return ``True`` if ``value`` can be coerced to whole number. If ``False``, will only return ``True`` if ``value`` is already a whole number (regardless of type). Defaults...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L836-L886
insightindustry/validator-collection
validator_collection/checkers.py
is_float
def is_float(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is a :class:`float <python:float>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this val...
python
def is_float(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is a :class:`float <python:float>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this val...
Indicate whether ``value`` is a :class:`float <python:float>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this value. :type minimum: numeric :param maximum: If supplied, will make sure that ``value`` is less than o...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L890-L923
insightindustry/validator-collection
validator_collection/checkers.py
is_fraction
def is_fraction(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is a :class:`Fraction <python:fractions.Fraction>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater tha...
python
def is_fraction(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` is a :class:`Fraction <python:fractions.Fraction>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater tha...
Indicate whether ``value`` is a :class:`Fraction <python:fractions.Fraction>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this value. :type minimum: numeric :param maximum: If supplied, will make sure that ``value`...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L927-L960
insightindustry/validator-collection
validator_collection/checkers.py
is_decimal
def is_decimal(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` contains a :class:`Decimal <python:decimal.Decimal>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than ...
python
def is_decimal(value, minimum = None, maximum = None, **kwargs): """Indicate whether ``value`` contains a :class:`Decimal <python:decimal.Decimal>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than ...
Indicate whether ``value`` contains a :class:`Decimal <python:decimal.Decimal>`. :param value: The value to evaluate. :param minimum: If supplied, will make sure that ``value`` is greater than or equal to this value. :type minimum: numeric :param maximum: If supplied, will make sure that ``valu...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L964-L997
insightindustry/validator-collection
validator_collection/checkers.py
is_pathlike
def is_pathlike(value, **kwargs): """Indicate whether ``value`` is a path-like object. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameter...
python
def is_pathlike(value, **kwargs): """Indicate whether ``value`` is a path-like object. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameter...
Indicate whether ``value`` is a path-like object. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates keyword parameters ...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1045-L1064
insightindustry/validator-collection
validator_collection/checkers.py
is_on_filesystem
def is_on_filesystem(value, **kwargs): """Indicate whether ``value`` is a file or directory that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if `...
python
def is_on_filesystem(value, **kwargs): """Indicate whether ``value`` is a file or directory that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if `...
Indicate whether ``value`` is a file or directory that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameter...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1068-L1088
insightindustry/validator-collection
validator_collection/checkers.py
is_file
def is_file(value, **kwargs): """Indicate whether ``value`` is a file that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplica...
python
def is_file(value, **kwargs): """Indicate whether ``value`` is a file that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplica...
Indicate whether ``value`` is a file that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates ...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1092-L1111
insightindustry/validator-collection
validator_collection/checkers.py
is_directory
def is_directory(value, **kwargs): """Indicate whether ``value`` is a directory that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contai...
python
def is_directory(value, **kwargs): """Indicate whether ``value`` is a directory that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contai...
Indicate whether ``value`` is a directory that exists on the local filesystem. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplica...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1115-L1134
insightindustry/validator-collection
validator_collection/checkers.py
is_readable
def is_readable(value, **kwargs): """Indicate whether ``value`` is a readable file. .. caution:: **Use of this validator is an anti-pattern and should be used with caution.** Validating the readability of a file *before* attempting to read it exposes your code to a bug called `TOCTOU ...
python
def is_readable(value, **kwargs): """Indicate whether ``value`` is a readable file. .. caution:: **Use of this validator is an anti-pattern and should be used with caution.** Validating the readability of a file *before* attempting to read it exposes your code to a bug called `TOCTOU ...
Indicate whether ``value`` is a readable file. .. caution:: **Use of this validator is an anti-pattern and should be used with caution.** Validating the readability of a file *before* attempting to read it exposes your code to a bug called `TOCTOU <https://en.wikipedia.org/wiki/Time_of_ch...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1138-L1181
insightindustry/validator-collection
validator_collection/checkers.py
is_writeable
def is_writeable(value, **kwargs): """Indicate whether ``value`` is a writeable file. .. caution:: This validator does **NOT** work correctly on a Windows file system. This is due to the vagaries of how Windows manages its file system and the various ways in which it can man...
python
def is_writeable(value, **kwargs): """Indicate whether ``value`` is a writeable file. .. caution:: This validator does **NOT** work correctly on a Windows file system. This is due to the vagaries of how Windows manages its file system and the various ways in which it can man...
Indicate whether ``value`` is a writeable file. .. caution:: This validator does **NOT** work correctly on a Windows file system. This is due to the vagaries of how Windows manages its file system and the various ways in which it can manage file permission. If called on a Windows file sys...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1185-L1257
insightindustry/validator-collection
validator_collection/checkers.py
is_executable
def is_executable(value, **kwargs): """Indicate whether ``value`` is an executable file. .. caution:: This validator does **NOT** work correctly on a Windows file system. This is due to the vagaries of how Windows manages its file system and the various ways in which it can...
python
def is_executable(value, **kwargs): """Indicate whether ``value`` is an executable file. .. caution:: This validator does **NOT** work correctly on a Windows file system. This is due to the vagaries of how Windows manages its file system and the various ways in which it can...
Indicate whether ``value`` is an executable file. .. caution:: This validator does **NOT** work correctly on a Windows file system. This is due to the vagaries of how Windows manages its file system and the various ways in which it can manage file permission. If called on a Windows file s...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1260-L1323
insightindustry/validator-collection
validator_collection/checkers.py
is_email
def is_email(value, **kwargs): """Indicate whether ``value`` is an email address. .. note:: Email address validation is...complicated. The methodology that we have adopted here is *generally* compliant with `RFC 5322 <https://tools.ietf.org/html/rfc5322>`_ and uses a combination of str...
python
def is_email(value, **kwargs): """Indicate whether ``value`` is an email address. .. note:: Email address validation is...complicated. The methodology that we have adopted here is *generally* compliant with `RFC 5322 <https://tools.ietf.org/html/rfc5322>`_ and uses a combination of str...
Indicate whether ``value`` is an email address. .. note:: Email address validation is...complicated. The methodology that we have adopted here is *generally* compliant with `RFC 5322 <https://tools.ietf.org/html/rfc5322>`_ and uses a combination of string parsing and regular expressions. ...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1329-L1362
insightindustry/validator-collection
validator_collection/checkers.py
is_url
def is_url(value, **kwargs): """Indicate whether ``value`` is a URL. .. note:: URL validation is...complicated. The methodology that we have adopted here is *generally* compliant with `RFC 1738 <https://tools.ietf.org/html/rfc1738>`_, `RFC 6761 <https://tools.ietf.org/html/rfc6761>`_, ...
python
def is_url(value, **kwargs): """Indicate whether ``value`` is a URL. .. note:: URL validation is...complicated. The methodology that we have adopted here is *generally* compliant with `RFC 1738 <https://tools.ietf.org/html/rfc1738>`_, `RFC 6761 <https://tools.ietf.org/html/rfc6761>`_, ...
Indicate whether ``value`` is a URL. .. note:: URL validation is...complicated. The methodology that we have adopted here is *generally* compliant with `RFC 1738 <https://tools.ietf.org/html/rfc1738>`_, `RFC 6761 <https://tools.ietf.org/html/rfc6761>`_, `RFC 2181 <https://tools.ietf....
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1366-L1402
insightindustry/validator-collection
validator_collection/checkers.py
is_domain
def is_domain(value, **kwargs): """Indicate whether ``value`` is a valid domain. .. caution:: This validator does not verify that ``value`` **exists** as a domain. It merely verifies that its contents *might* exist as a domain. .. note:: This validator checks to validate that ``value``...
python
def is_domain(value, **kwargs): """Indicate whether ``value`` is a valid domain. .. caution:: This validator does not verify that ``value`` **exists** as a domain. It merely verifies that its contents *might* exist as a domain. .. note:: This validator checks to validate that ``value``...
Indicate whether ``value`` is a valid domain. .. caution:: This validator does not verify that ``value`` **exists** as a domain. It merely verifies that its contents *might* exist as a domain. .. note:: This validator checks to validate that ``value`` resembles a valid domain name. I...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1406-L1450
insightindustry/validator-collection
validator_collection/checkers.py
is_ip_address
def is_ip_address(value, **kwargs): """Indicate whether ``value`` is a valid IP address (version 4 or version 6). :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains ...
python
def is_ip_address(value, **kwargs): """Indicate whether ``value`` is a valid IP address (version 4 or version 6). :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains ...
Indicate whether ``value`` is a valid IP address (version 4 or version 6). :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates ...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1454-L1473
insightindustry/validator-collection
validator_collection/checkers.py
is_ipv4
def is_ipv4(value, **kwargs): """Indicate whether ``value`` is a valid IP version 4 address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword par...
python
def is_ipv4(value, **kwargs): """Indicate whether ``value`` is a valid IP version 4 address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword par...
Indicate whether ``value`` is a valid IP version 4 address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates keyword p...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1477-L1496
insightindustry/validator-collection
validator_collection/checkers.py
is_ipv6
def is_ipv6(value, **kwargs): """Indicate whether ``value`` is a valid IP version 6 address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword par...
python
def is_ipv6(value, **kwargs): """Indicate whether ``value`` is a valid IP version 6 address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword par...
Indicate whether ``value`` is a valid IP version 6 address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates keyword p...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1500-L1518
insightindustry/validator-collection
validator_collection/checkers.py
is_mac_address
def is_mac_address(value, **kwargs): """Indicate whether ``value`` is a valid MAC address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword param...
python
def is_mac_address(value, **kwargs): """Indicate whether ``value`` is a valid MAC address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword param...
Indicate whether ``value`` is a valid MAC address. :param value: The value to evaluate. :returns: ``True`` if ``value`` is valid, ``False`` if it is not. :rtype: :class:`bool <python:bool>` :raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates keyword parameters...
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/checkers.py#L1522-L1540
kevinpt/syntrax
syntrax.py
RailroadLayout.draw_line
def draw_line(self, lx, ltor): '''Draw a series of elements from left to right''' tag = self.get_tag() c = self.canvas s = self.style sep = s.h_sep exx = 0 exy = 0 terms = lx if ltor else reversed(lx) # Reverse so we can draw left to right for term in terms: t, texx,...
python
def draw_line(self, lx, ltor): '''Draw a series of elements from left to right''' tag = self.get_tag() c = self.canvas s = self.style sep = s.h_sep exx = 0 exy = 0 terms = lx if ltor else reversed(lx) # Reverse so we can draw left to right for term in terms: t, texx,...
Draw a series of elements from left to right
https://github.com/kevinpt/syntrax/blob/eecc2714731ec6475d264326441e0f2a47467c28/syntrax.py#L1291-L1325
akolpakov/django-unused-media
django_unused_media/utils.py
get_file_fields
def get_file_fields(): """ Get all fields which are inherited from FileField """ # get models all_models = apps.get_models() # get fields fields = [] for model in all_models: for field in model._meta.get_fields(): if isinstance(field, models.FileField): ...
python
def get_file_fields(): """ Get all fields which are inherited from FileField """ # get models all_models = apps.get_models() # get fields fields = [] for model in all_models: for field in model._meta.get_fields(): if isinstance(field, models.FileField): ...
Get all fields which are inherited from FileField
https://github.com/akolpakov/django-unused-media/blob/0a6c38840f4eac49d285c7be5da7330a564cee92/django_unused_media/utils.py#L7-L25
akolpakov/django-unused-media
django_unused_media/remove.py
remove_media
def remove_media(files): """ Delete file from media dir """ for filename in files: os.remove(os.path.join(settings.MEDIA_ROOT, filename))
python
def remove_media(files): """ Delete file from media dir """ for filename in files: os.remove(os.path.join(settings.MEDIA_ROOT, filename))
Delete file from media dir
https://github.com/akolpakov/django-unused-media/blob/0a6c38840f4eac49d285c7be5da7330a564cee92/django_unused_media/remove.py#L8-L13
akolpakov/django-unused-media
django_unused_media/remove.py
remove_empty_dirs
def remove_empty_dirs(path=None): """ Recursively delete empty directories; return True if everything was deleted. """ if not path: path = settings.MEDIA_ROOT if not os.path.isdir(path): return False listdir = [os.path.join(path, filename) for filename in os.listdir(path)]...
python
def remove_empty_dirs(path=None): """ Recursively delete empty directories; return True if everything was deleted. """ if not path: path = settings.MEDIA_ROOT if not os.path.isdir(path): return False listdir = [os.path.join(path, filename) for filename in os.listdir(path)]...
Recursively delete empty directories; return True if everything was deleted.
https://github.com/akolpakov/django-unused-media/blob/0a6c38840f4eac49d285c7be5da7330a564cee92/django_unused_media/remove.py#L16-L33
akolpakov/django-unused-media
django_unused_media/cleanup.py
get_used_media
def get_used_media(): """ Get media which are still used in models """ media = set() for field in get_file_fields(): is_null = { '%s__isnull' % field.name: True, } is_empty = { '%s' % field.name: '', } storage = field.storage ...
python
def get_used_media(): """ Get media which are still used in models """ media = set() for field in get_file_fields(): is_null = { '%s__isnull' % field.name: True, } is_empty = { '%s' % field.name: '', } storage = field.storage ...
Get media which are still used in models
https://github.com/akolpakov/django-unused-media/blob/0a6c38840f4eac49d285c7be5da7330a564cee92/django_unused_media/cleanup.py#L14-L37
akolpakov/django-unused-media
django_unused_media/cleanup.py
get_all_media
def get_all_media(exclude=None): """ Get all media from MEDIA_ROOT """ if not exclude: exclude = [] media = set() for root, dirs, files in os.walk(six.text_type(settings.MEDIA_ROOT)): for name in files: path = os.path.abspath(os.path.join(root, name)) ...
python
def get_all_media(exclude=None): """ Get all media from MEDIA_ROOT """ if not exclude: exclude = [] media = set() for root, dirs, files in os.walk(six.text_type(settings.MEDIA_ROOT)): for name in files: path = os.path.abspath(os.path.join(root, name)) ...
Get all media from MEDIA_ROOT
https://github.com/akolpakov/django-unused-media/blob/0a6c38840f4eac49d285c7be5da7330a564cee92/django_unused_media/cleanup.py#L40-L60
akolpakov/django-unused-media
django_unused_media/cleanup.py
get_unused_media
def get_unused_media(exclude=None): """ Get media which are not used in models """ if not exclude: exclude = [] all_media = get_all_media(exclude) used_media = get_used_media() return all_media - used_media
python
def get_unused_media(exclude=None): """ Get media which are not used in models """ if not exclude: exclude = [] all_media = get_all_media(exclude) used_media = get_used_media() return all_media - used_media
Get media which are not used in models
https://github.com/akolpakov/django-unused-media/blob/0a6c38840f4eac49d285c7be5da7330a564cee92/django_unused_media/cleanup.py#L63-L74
hazelcast/hazelcast-remote-controller
python-controller/hzrc/RemoteController.py
Client.createCluster
def createCluster(self, hzVersion, xmlconfig): """ Parameters: - hzVersion - xmlconfig """ self.send_createCluster(hzVersion, xmlconfig) return self.recv_createCluster()
python
def createCluster(self, hzVersion, xmlconfig): """ Parameters: - hzVersion - xmlconfig """ self.send_createCluster(hzVersion, xmlconfig) return self.recv_createCluster()
Parameters: - hzVersion - xmlconfig
https://github.com/hazelcast/hazelcast-remote-controller/blob/41b9e7d2d722b69ff79642eb34b702c9a6087635/python-controller/hzrc/RemoteController.py#L199-L206
hazelcast/hazelcast-remote-controller
python-controller/hzrc/RemoteController.py
Client.shutdownMember
def shutdownMember(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_shutdownMember(clusterId, memberId) return self.recv_shutdownMember()
python
def shutdownMember(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_shutdownMember(clusterId, memberId) return self.recv_shutdownMember()
Parameters: - clusterId - memberId
https://github.com/hazelcast/hazelcast-remote-controller/blob/41b9e7d2d722b69ff79642eb34b702c9a6087635/python-controller/hzrc/RemoteController.py#L267-L274
hazelcast/hazelcast-remote-controller
python-controller/hzrc/RemoteController.py
Client.terminateMember
def terminateMember(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_terminateMember(clusterId, memberId) return self.recv_terminateMember()
python
def terminateMember(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_terminateMember(clusterId, memberId) return self.recv_terminateMember()
Parameters: - clusterId - memberId
https://github.com/hazelcast/hazelcast-remote-controller/blob/41b9e7d2d722b69ff79642eb34b702c9a6087635/python-controller/hzrc/RemoteController.py#L300-L307
hazelcast/hazelcast-remote-controller
python-controller/hzrc/RemoteController.py
Client.suspendMember
def suspendMember(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_suspendMember(clusterId, memberId) return self.recv_suspendMember()
python
def suspendMember(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_suspendMember(clusterId, memberId) return self.recv_suspendMember()
Parameters: - clusterId - memberId
https://github.com/hazelcast/hazelcast-remote-controller/blob/41b9e7d2d722b69ff79642eb34b702c9a6087635/python-controller/hzrc/RemoteController.py#L333-L340
hazelcast/hazelcast-remote-controller
python-controller/hzrc/RemoteController.py
Client.resumeMember
def resumeMember(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_resumeMember(clusterId, memberId) return self.recv_resumeMember()
python
def resumeMember(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_resumeMember(clusterId, memberId) return self.recv_resumeMember()
Parameters: - clusterId - memberId
https://github.com/hazelcast/hazelcast-remote-controller/blob/41b9e7d2d722b69ff79642eb34b702c9a6087635/python-controller/hzrc/RemoteController.py#L366-L373
hazelcast/hazelcast-remote-controller
python-controller/hzrc/RemoteController.py
Client.mergeMemberToCluster
def mergeMemberToCluster(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_mergeMemberToCluster(clusterId, memberId) return self.recv_mergeMemberToCluster()
python
def mergeMemberToCluster(self, clusterId, memberId): """ Parameters: - clusterId - memberId """ self.send_mergeMemberToCluster(clusterId, memberId) return self.recv_mergeMemberToCluster()
Parameters: - clusterId - memberId
https://github.com/hazelcast/hazelcast-remote-controller/blob/41b9e7d2d722b69ff79642eb34b702c9a6087635/python-controller/hzrc/RemoteController.py#L492-L499
hazelcast/hazelcast-remote-controller
python-controller/hzrc/RemoteController.py
Client.executeOnController
def executeOnController(self, clusterId, script, lang): """ Parameters: - clusterId - script - lang """ self.send_executeOnController(clusterId, script, lang) return self.recv_executeOnController()
python
def executeOnController(self, clusterId, script, lang): """ Parameters: - clusterId - script - lang """ self.send_executeOnController(clusterId, script, lang) return self.recv_executeOnController()
Parameters: - clusterId - script - lang
https://github.com/hazelcast/hazelcast-remote-controller/blob/41b9e7d2d722b69ff79642eb34b702c9a6087635/python-controller/hzrc/RemoteController.py#L525-L533
njsmith/colorspacious
colorspacious/comparison.py
deltaE
def deltaE(color1, color2, input_space="sRGB1", uniform_space="CAM02-UCS"): """Computes the :math:`\Delta E` distance between pairs of colors. :param input_space: The space the colors start out in. Can be anything recognized by :func:`cspace_convert`. Default: "sRGB1" :param uniform_space...
python
def deltaE(color1, color2, input_space="sRGB1", uniform_space="CAM02-UCS"): """Computes the :math:`\Delta E` distance between pairs of colors. :param input_space: The space the colors start out in. Can be anything recognized by :func:`cspace_convert`. Default: "sRGB1" :param uniform_space...
Computes the :math:`\Delta E` distance between pairs of colors. :param input_space: The space the colors start out in. Can be anything recognized by :func:`cspace_convert`. Default: "sRGB1" :param uniform_space: Which space to perform the distance measurement in. This should be a uniform space li...
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/comparison.py#L9-L38
njsmith/colorspacious
colorspacious/basics.py
XYZ100_to_sRGB1_linear
def XYZ100_to_sRGB1_linear(XYZ100): """Convert XYZ to linear sRGB, where XYZ is normalized so that reference white D65 is X=95.05, Y=100, Z=108.90 and sRGB is on the 0-1 scale. Linear sRGB has a linear relationship to actual light, so it is an appropriate space for simulating light (e.g. for alpha blend...
python
def XYZ100_to_sRGB1_linear(XYZ100): """Convert XYZ to linear sRGB, where XYZ is normalized so that reference white D65 is X=95.05, Y=100, Z=108.90 and sRGB is on the 0-1 scale. Linear sRGB has a linear relationship to actual light, so it is an appropriate space for simulating light (e.g. for alpha blend...
Convert XYZ to linear sRGB, where XYZ is normalized so that reference white D65 is X=95.05, Y=100, Z=108.90 and sRGB is on the 0-1 scale. Linear sRGB has a linear relationship to actual light, so it is an appropriate space for simulating light (e.g. for alpha blending).
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/basics.py#L44-L55
njsmith/colorspacious
colorspacious/basics.py
sRGB1_to_sRGB1_linear
def sRGB1_to_sRGB1_linear(sRGB1): """Convert sRGB (as floats in the 0-to-1 range) to linear sRGB.""" sRGB1 = np.asarray(sRGB1, dtype=float) sRGB1_linear = C_linear(sRGB1) return sRGB1_linear
python
def sRGB1_to_sRGB1_linear(sRGB1): """Convert sRGB (as floats in the 0-to-1 range) to linear sRGB.""" sRGB1 = np.asarray(sRGB1, dtype=float) sRGB1_linear = C_linear(sRGB1) return sRGB1_linear
Convert sRGB (as floats in the 0-to-1 range) to linear sRGB.
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/basics.py#L60-L64
njsmith/colorspacious
colorspacious/conversion.py
cspace_converter
def cspace_converter(start, end): """Returns a function for converting from colorspace ``start`` to colorspace ``end``. E.g., these are equivalent:: out = cspace_convert(arr, start, end) :: start_to_end_fn = cspace_converter(start, end) out = start_to_end_fn(arr) If you ...
python
def cspace_converter(start, end): """Returns a function for converting from colorspace ``start`` to colorspace ``end``. E.g., these are equivalent:: out = cspace_convert(arr, start, end) :: start_to_end_fn = cspace_converter(start, end) out = start_to_end_fn(arr) If you ...
Returns a function for converting from colorspace ``start`` to colorspace ``end``. E.g., these are equivalent:: out = cspace_convert(arr, start, end) :: start_to_end_fn = cspace_converter(start, end) out = start_to_end_fn(arr) If you are doing a large number of conversions b...
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/conversion.py#L198-L220
njsmith/colorspacious
colorspacious/conversion.py
cspace_convert
def cspace_convert(arr, start, end): """Converts the colors in ``arr`` from colorspace ``start`` to colorspace ``end``. :param arr: An array-like of colors. :param start, end: Any supported colorspace specifiers. See :ref:`supported-colorspaces` for details. """ converter = cspace_conv...
python
def cspace_convert(arr, start, end): """Converts the colors in ``arr`` from colorspace ``start`` to colorspace ``end``. :param arr: An array-like of colors. :param start, end: Any supported colorspace specifiers. See :ref:`supported-colorspaces` for details. """ converter = cspace_conv...
Converts the colors in ``arr`` from colorspace ``start`` to colorspace ``end``. :param arr: An array-like of colors. :param start, end: Any supported colorspace specifiers. See :ref:`supported-colorspaces` for details.
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/conversion.py#L222-L232
njsmith/colorspacious
colorspacious/ciecam02.py
CIECAM02Space.XYZ100_to_CIECAM02
def XYZ100_to_CIECAM02(self, XYZ100, on_negative_A="raise"): """Computes CIECAM02 appearance correlates for the given tristimulus value(s) XYZ (normalized to be on the 0-100 scale). Example: ``vc.XYZ100_to_CIECAM02([30.0, 45.5, 21.0])`` :param XYZ100: An array-like of tristimulus value...
python
def XYZ100_to_CIECAM02(self, XYZ100, on_negative_A="raise"): """Computes CIECAM02 appearance correlates for the given tristimulus value(s) XYZ (normalized to be on the 0-100 scale). Example: ``vc.XYZ100_to_CIECAM02([30.0, 45.5, 21.0])`` :param XYZ100: An array-like of tristimulus value...
Computes CIECAM02 appearance correlates for the given tristimulus value(s) XYZ (normalized to be on the 0-100 scale). Example: ``vc.XYZ100_to_CIECAM02([30.0, 45.5, 21.0])`` :param XYZ100: An array-like of tristimulus values. These should be given on the 0-100 scale, not the 0-1 scale...
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/ciecam02.py#L143-L252
njsmith/colorspacious
colorspacious/ciecam02.py
CIECAM02Space.CIECAM02_to_XYZ100
def CIECAM02_to_XYZ100(self, J=None, C=None, h=None, Q=None, M=None, s=None, H=None): """Return the unique tristimulus values that have the given CIECAM02 appearance correlates under these viewing conditions. You must specify 3 arguments: * Exactly one of ``J...
python
def CIECAM02_to_XYZ100(self, J=None, C=None, h=None, Q=None, M=None, s=None, H=None): """Return the unique tristimulus values that have the given CIECAM02 appearance correlates under these viewing conditions. You must specify 3 arguments: * Exactly one of ``J...
Return the unique tristimulus values that have the given CIECAM02 appearance correlates under these viewing conditions. You must specify 3 arguments: * Exactly one of ``J`` and ``Q`` * Exactly one of ``C``, ``M``, and ``s`` * Exactly one of ``h`` and ``H``. Arguments c...
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/ciecam02.py#L258-L414
njsmith/colorspacious
colorspacious/illuminants.py
standard_illuminant_XYZ100
def standard_illuminant_XYZ100(name, observer="CIE 1931 2 deg"): """Takes a string naming a standard illuminant, and returns its XYZ coordinates (normalized to Y = 100). We currently have the following standard illuminants in our database: * ``"A"`` * ``"C"`` * ``"D50"`` * ``"D55"`` * ...
python
def standard_illuminant_XYZ100(name, observer="CIE 1931 2 deg"): """Takes a string naming a standard illuminant, and returns its XYZ coordinates (normalized to Y = 100). We currently have the following standard illuminants in our database: * ``"A"`` * ``"C"`` * ``"D50"`` * ``"D55"`` * ...
Takes a string naming a standard illuminant, and returns its XYZ coordinates (normalized to Y = 100). We currently have the following standard illuminants in our database: * ``"A"`` * ``"C"`` * ``"D50"`` * ``"D55"`` * ``"D65"`` * ``"D75"`` If you need another that isn't on this li...
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/illuminants.py#L44-L81
njsmith/colorspacious
colorspacious/illuminants.py
as_XYZ100_w
def as_XYZ100_w(whitepoint): """A convenience function for getting whitepoints. ``whitepoint`` can be either a string naming a standard illuminant (see :func:`standard_illuminant_XYZ100`), or else a whitepoint given explicitly as an array-like of XYZ values. We internally call this function anywhe...
python
def as_XYZ100_w(whitepoint): """A convenience function for getting whitepoints. ``whitepoint`` can be either a string naming a standard illuminant (see :func:`standard_illuminant_XYZ100`), or else a whitepoint given explicitly as an array-like of XYZ values. We internally call this function anywhe...
A convenience function for getting whitepoints. ``whitepoint`` can be either a string naming a standard illuminant (see :func:`standard_illuminant_XYZ100`), or else a whitepoint given explicitly as an array-like of XYZ values. We internally call this function anywhere you have to specify a whitepoint ...
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/illuminants.py#L97-L116
njsmith/colorspacious
colorspacious/cvd.py
machado_et_al_2009_matrix
def machado_et_al_2009_matrix(cvd_type, severity): """Retrieve a matrix for simulating anomalous color vision. :param cvd_type: One of "protanomaly", "deuteranomaly", or "tritanomaly". :param severity: A value between 0 and 100. :returns: A 3x3 CVD simulation matrix as computed by Machado et al ...
python
def machado_et_al_2009_matrix(cvd_type, severity): """Retrieve a matrix for simulating anomalous color vision. :param cvd_type: One of "protanomaly", "deuteranomaly", or "tritanomaly". :param severity: A value between 0 and 100. :returns: A 3x3 CVD simulation matrix as computed by Machado et al ...
Retrieve a matrix for simulating anomalous color vision. :param cvd_type: One of "protanomaly", "deuteranomaly", or "tritanomaly". :param severity: A value between 0 and 100. :returns: A 3x3 CVD simulation matrix as computed by Machado et al (2009). These matrices were downloaded from: ...
https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/cvd.py#L21-L54
h2oai/typesentry
typesentry/signature.py
Signature._make_retval_checker
def _make_retval_checker(self): """Create a function that checks the return value of the function.""" rvchk = self.retval.checker if rvchk: def _checker(value): if not rvchk.check(value): raise self._type_error( "Incorrect r...
python
def _make_retval_checker(self): """Create a function that checks the return value of the function.""" rvchk = self.retval.checker if rvchk: def _checker(value): if not rvchk.check(value): raise self._type_error( "Incorrect r...
Create a function that checks the return value of the function.
https://github.com/h2oai/typesentry/blob/0ca8ed0e62d15ffe430545e7648c9a9b2547b49c/typesentry/signature.py#L172-L186
h2oai/typesentry
typesentry/signature.py
Signature._make_args_checker
def _make_args_checker(self): """ Create a function that checks signature of the source function. """ def _checker(*args, **kws): # Check if too many arguments are provided nargs = len(args) nnonvaargs = min(nargs, self._max_positional_args) ...
python
def _make_args_checker(self): """ Create a function that checks signature of the source function. """ def _checker(*args, **kws): # Check if too many arguments are provided nargs = len(args) nnonvaargs = min(nargs, self._max_positional_args) ...
Create a function that checks signature of the source function.
https://github.com/h2oai/typesentry/blob/0ca8ed0e62d15ffe430545e7648c9a9b2547b49c/typesentry/signature.py#L189-L249
h2oai/typesentry
typesentry/checks.py
checker_for_type
def checker_for_type(t): """ Return "checker" function for the given type `t`. This checker function will accept a single argument (of any type), and return True if the argument matches type `t`, or False otherwise. For example: chkr = checker_for_type(int) assert chkr.check(123) i...
python
def checker_for_type(t): """ Return "checker" function for the given type `t`. This checker function will accept a single argument (of any type), and return True if the argument matches type `t`, or False otherwise. For example: chkr = checker_for_type(int) assert chkr.check(123) i...
Return "checker" function for the given type `t`. This checker function will accept a single argument (of any type), and return True if the argument matches type `t`, or False otherwise. For example: chkr = checker_for_type(int) assert chkr.check(123) is True assert chkr.check("5")...
https://github.com/h2oai/typesentry/blob/0ca8ed0e62d15ffe430545e7648c9a9b2547b49c/typesentry/checks.py#L32-L61
h2oai/typesentry
typesentry/checks.py
_prepare_value
def _prepare_value(val, maxlen=50, notype=False): """ Stringify value `val`, ensuring that it is not too long. """ if val is None or val is True or val is False: return str(val) sval = repr(val) sval = sval.replace("\n", " ").replace("\t", " ").replace("`", "'") if len(sval) > maxlen...
python
def _prepare_value(val, maxlen=50, notype=False): """ Stringify value `val`, ensuring that it is not too long. """ if val is None or val is True or val is False: return str(val) sval = repr(val) sval = sval.replace("\n", " ").replace("\t", " ").replace("`", "'") if len(sval) > maxlen...
Stringify value `val`, ensuring that it is not too long.
https://github.com/h2oai/typesentry/blob/0ca8ed0e62d15ffe430545e7648c9a9b2547b49c/typesentry/checks.py#L774-L788
h2oai/typesentry
typesentry/checks.py
_nth_str
def _nth_str(n): """Return posessive form of numeral `n`: 1st, 2nd, 3rd, etc.""" if n % 10 == 1 and n % 100 != 11: return "%dst" % n if n % 10 == 2 and n % 100 != 12: return "%dnd" % n if n % 10 == 3 and n % 100 != 13: return "%drd" % n return "%dth" % n
python
def _nth_str(n): """Return posessive form of numeral `n`: 1st, 2nd, 3rd, etc.""" if n % 10 == 1 and n % 100 != 11: return "%dst" % n if n % 10 == 2 and n % 100 != 12: return "%dnd" % n if n % 10 == 3 and n % 100 != 13: return "%drd" % n return "%dth" % n
Return posessive form of numeral `n`: 1st, 2nd, 3rd, etc.
https://github.com/h2oai/typesentry/blob/0ca8ed0e62d15ffe430545e7648c9a9b2547b49c/typesentry/checks.py#L790-L798
muatik/naive-bayes-classifier
naiveBayesClassifier/trainer.py
Trainer.train
def train(self, text, className): """ enhances trained data using the given text and class """ self.data.increaseClass(className) tokens = self.tokenizer.tokenize(text) for token in tokens: token = self.tokenizer.remove_stop_words(token) token = s...
python
def train(self, text, className): """ enhances trained data using the given text and class """ self.data.increaseClass(className) tokens = self.tokenizer.tokenize(text) for token in tokens: token = self.tokenizer.remove_stop_words(token) token = s...
enhances trained data using the given text and class
https://github.com/muatik/naive-bayes-classifier/blob/cdc1d8681ef6674e946cff38e87ce3b00c732fbb/naiveBayesClassifier/trainer.py#L11-L21
rene-aguirre/pywinusb
pywinusb/hid/core.py
hid_device_path_exists
def hid_device_path_exists(device_path, guid = None): """Test if required device_path is still valid (HID device connected to host) """ # expecing HID devices if not guid: guid = winapi.GetHidGuid() info_data = winapi.SP_DEVINFO_DATA() info_data.cb_size = sizeof(win...
python
def hid_device_path_exists(device_path, guid = None): """Test if required device_path is still valid (HID device connected to host) """ # expecing HID devices if not guid: guid = winapi.GetHidGuid() info_data = winapi.SP_DEVINFO_DATA() info_data.cb_size = sizeof(win...
Test if required device_path is still valid (HID device connected to host)
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L67-L86
rene-aguirre/pywinusb
pywinusb/hid/core.py
find_all_hid_devices
def find_all_hid_devices(): "Finds all HID devices connected to the system" # # From DDK documentation (finding and Opening HID collection): # After a user-mode application is loaded, it does the following sequence # of operations: # # * Calls HidD_GetHidGuid to obtain the system-de...
python
def find_all_hid_devices(): "Finds all HID devices connected to the system" # # From DDK documentation (finding and Opening HID collection): # After a user-mode application is loaded, it does the following sequence # of operations: # # * Calls HidD_GetHidGuid to obtain the system-de...
Finds all HID devices connected to the system
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L88-L156
rene-aguirre/pywinusb
pywinusb/hid/core.py
show_hids
def show_hids(target_vid = 0, target_pid = 0, output = None): """Check all HID devices conected to PC hosts.""" # first be kind with local encodings if not output: # beware your script should manage encodings output = sys.stdout # then the big cheese... from . import tools ...
python
def show_hids(target_vid = 0, target_pid = 0, output = None): """Check all HID devices conected to PC hosts.""" # first be kind with local encodings if not output: # beware your script should manage encodings output = sys.stdout # then the big cheese... from . import tools ...
Check all HID devices conected to PC hosts.
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1571-L1609
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDeviceFilter.get_devices_by_parent
def get_devices_by_parent(self, hid_filter=None): """Group devices returned from filter query in order \ by devcice parent id. """ all_devs = self.get_devices(hid_filter) dev_group = dict() for hid_device in all_devs: #keep a list of known devices match...
python
def get_devices_by_parent(self, hid_filter=None): """Group devices returned from filter query in order \ by devcice parent id. """ all_devs = self.get_devices(hid_filter) dev_group = dict() for hid_device in all_devs: #keep a list of known devices match...
Group devices returned from filter query in order \ by devcice parent id.
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L168-L182
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDeviceFilter.get_devices
def get_devices(self, hid_filter = None): """Filter a HID device list by current object parameters. Devices must match the all of the filtering parameters """ if not hid_filter: #empty list or called without any parameters if type(hid_filter) == type(None): ...
python
def get_devices(self, hid_filter = None): """Filter a HID device list by current object parameters. Devices must match the all of the filtering parameters """ if not hid_filter: #empty list or called without any parameters if type(hid_filter) == type(None): ...
Filter a HID device list by current object parameters. Devices must match the all of the filtering parameters
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L184-L242
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.get_parent_device
def get_parent_device(self): """Retreive parent device string id""" if not self.parent_instance_id: return "" dev_buffer_type = winapi.c_tchar * MAX_DEVICE_ID_LEN dev_buffer = dev_buffer_type() try: if winapi.CM_Get_Device_ID(self.parent_instance_id...
python
def get_parent_device(self): """Retreive parent device string id""" if not self.parent_instance_id: return "" dev_buffer_type = winapi.c_tchar * MAX_DEVICE_ID_LEN dev_buffer = dev_buffer_type() try: if winapi.CM_Get_Device_ID(self.parent_instance_id...
Retreive parent device string id
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L266-L279
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.open
def open(self, output_only = False, shared = True): """Open HID device and obtain 'Collection Information'. It effectively prepares the HidDevice object for reading and writing """ if self.is_opened(): raise HIDError("Device already opened") sharing_flags = 0 ...
python
def open(self, output_only = False, shared = True): """Open HID device and obtain 'Collection Information'. It effectively prepares the HidDevice object for reading and writing """ if self.is_opened(): raise HIDError("Device already opened") sharing_flags = 0 ...
Open HID device and obtain 'Collection Information'. It effectively prepares the HidDevice object for reading and writing
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L395-L507
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.get_physical_descriptor
def get_physical_descriptor(self): """Returns physical HID device descriptor """ raw_data_type = c_ubyte * 1024 raw_data = raw_data_type() if hid_dll.HidD_GetPhysicalDescriptor(self.hid_handle, byref(raw_data), 1024 ): return [x for x in raw_data] ...
python
def get_physical_descriptor(self): """Returns physical HID device descriptor """ raw_data_type = c_ubyte * 1024 raw_data = raw_data_type() if hid_dll.HidD_GetPhysicalDescriptor(self.hid_handle, byref(raw_data), 1024 ): return [x for x in raw_data] ...
Returns physical HID device descriptor
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L510-L518
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.send_output_report
def send_output_report(self, data): """Send input/output/feature report ID = report_id, data should be a c_ubyte object with included the required report data """ assert( self.is_opened() ) #make sure we have c_ubyte array storage if not ( isinstance(data, ctypes.Ar...
python
def send_output_report(self, data): """Send input/output/feature report ID = report_id, data should be a c_ubyte object with included the required report data """ assert( self.is_opened() ) #make sure we have c_ubyte array storage if not ( isinstance(data, ctypes.Ar...
Send input/output/feature report ID = report_id, data should be a c_ubyte object with included the required report data
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L520-L567
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.send_feature_report
def send_feature_report(self, data): """Send input/output/feature report ID = report_id, data should be a c_byte object with included the required report data """ assert( self.is_opened() ) #make sure we have c_ubyte array storage if not ( isinstance(data, ctypes.Ar...
python
def send_feature_report(self, data): """Send input/output/feature report ID = report_id, data should be a c_byte object with included the required report data """ assert( self.is_opened() ) #make sure we have c_ubyte array storage if not ( isinstance(data, ctypes.Ar...
Send input/output/feature report ID = report_id, data should be a c_byte object with included the required report data
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L569-L585
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.__reset_vars
def __reset_vars(self): """Reset vars (for init or gc)""" self.__button_caps_storage = list() self.usages_storage = dict() self.report_set = dict() self.ptr_preparsed_data = None self.hid_handle = None #don't clean up the report queue because the ...
python
def __reset_vars(self): """Reset vars (for init or gc)""" self.__button_caps_storage = list() self.usages_storage = dict() self.report_set = dict() self.ptr_preparsed_data = None self.hid_handle = None #don't clean up the report queue because the ...
Reset vars (for init or gc)
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L587-L601
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.close
def close(self): """Release system resources""" # free parsed data if not self.is_opened(): return self.__open_status = False # abort all running threads first if self.__reading_thread and self.__reading_thread.is_alive(): self.__reading_...
python
def close(self): """Release system resources""" # free parsed data if not self.is_opened(): return self.__open_status = False # abort all running threads first if self.__reading_thread and self.__reading_thread.is_alive(): self.__reading_...
Release system resources
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L612-L654
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.__find_reports
def __find_reports(self, report_type, usage_page, usage_id = 0): "Find input report referencing HID usage control/data item" if not self.is_opened(): raise HIDError("Device must be opened") # results = list() if usage_page: for report_id in self.rep...
python
def __find_reports(self, report_type, usage_page, usage_id = 0): "Find input report referencing HID usage control/data item" if not self.is_opened(): raise HIDError("Device must be opened") # results = list() if usage_page: for report_id in self.rep...
Find input report referencing HID usage control/data item
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L656-L673
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.find_any_reports
def find_any_reports(self, usage_page = 0, usage_id = 0): """Find any report type referencing HID usage control/data item. Results are returned in a dictionary mapping report_type to usage lists. """ items = [ (HidP_Input, self.find_input_reports(usage_page, ...
python
def find_any_reports(self, usage_page = 0, usage_id = 0): """Find any report type referencing HID usage control/data item. Results are returned in a dictionary mapping report_type to usage lists. """ items = [ (HidP_Input, self.find_input_reports(usage_page, ...
Find any report type referencing HID usage control/data item. Results are returned in a dictionary mapping report_type to usage lists.
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L692-L702
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice._process_raw_report
def _process_raw_report(self, raw_report): "Default raw input report data handler" if not self.is_opened(): return if not self.__evt_handlers and not self.__raw_handler: return if not raw_report[0] and \ (raw_report[0] not in self.__input...
python
def _process_raw_report(self, raw_report): "Default raw input report data handler" if not self.is_opened(): return if not self.__evt_handlers and not self.__raw_handler: return if not raw_report[0] and \ (raw_report[0] not in self.__input...
Default raw input report data handler
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L717-L763
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.find_input_usage
def find_input_usage(self, full_usage_id): """Check if full usage Id included in input reports set Parameters: full_usage_id Full target usage, use get_full_usage_id Returns: Report ID as integer value, or None if report does not exist with targe...
python
def find_input_usage(self, full_usage_id): """Check if full usage Id included in input reports set Parameters: full_usage_id Full target usage, use get_full_usage_id Returns: Report ID as integer value, or None if report does not exist with targe...
Check if full usage Id included in input reports set Parameters: full_usage_id Full target usage, use get_full_usage_id Returns: Report ID as integer value, or None if report does not exist with target usage. Nottice that report ID 0 is a valid report.
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L769-L781
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidDevice.add_event_handler
def add_event_handler(self, full_usage_id, handler_function, event_kind = HID_EVT_ALL, aux_data = None): """Add event handler for usage value/button changes, returns True if the handler function was updated""" report_id = self.find_input_usage(full_usage_id) if report_id...
python
def add_event_handler(self, full_usage_id, handler_function, event_kind = HID_EVT_ALL, aux_data = None): """Add event handler for usage value/button changes, returns True if the handler function was updated""" report_id = self.find_input_usage(full_usage_id) if report_id...
Add event handler for usage value/button changes, returns True if the handler function was updated
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L783-L804
rene-aguirre/pywinusb
pywinusb/hid/core.py
ReportItem.set_value
def set_value(self, value): """Set usage value within report""" if self.__is_value_array: if len(value) == self.__report_count: for index, item in enumerate(value): self.__setitem__(index, item) else: raise ValueError("Va...
python
def set_value(self, value): """Set usage value within report""" if self.__is_value_array: if len(value) == self.__report_count: for index, item in enumerate(value): self.__setitem__(index, item) else: raise ValueError("Va...
Set usage value within report
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1094-L1104
rene-aguirre/pywinusb
pywinusb/hid/core.py
ReportItem.get_value
def get_value(self): """Retreive usage value within report""" if self.__is_value_array: if self.__bit_size == 8: #matching c_ubyte return list(self.__value) else: result = [] for i in range(self.__report_count): ...
python
def get_value(self): """Retreive usage value within report""" if self.__is_value_array: if self.__bit_size == 8: #matching c_ubyte return list(self.__value) else: result = [] for i in range(self.__report_count): ...
Retreive usage value within report
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1106-L1117
rene-aguirre/pywinusb
pywinusb/hid/core.py
ReportItem.get_usage_string
def get_usage_string(self): """Returns usage representation string (as embedded in HID device if available) """ if self.string_index: usage_string_type = c_wchar * MAX_HID_STRING_LENGTH # 128 max string length abuffer = usage_string_type() ...
python
def get_usage_string(self): """Returns usage representation string (as embedded in HID device if available) """ if self.string_index: usage_string_type = c_wchar * MAX_HID_STRING_LENGTH # 128 max string length abuffer = usage_string_type() ...
Returns usage representation string (as embedded in HID device if available)
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1143-L1156
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidReport.get_usages
def get_usages(self): "Return a dictionary mapping full usages Ids to plain values" result = dict() for key, usage in self.items(): result[key] = usage.value return result
python
def get_usages(self): "Return a dictionary mapping full usages Ids to plain values" result = dict() for key, usage in self.items(): result[key] = usage.value return result
Return a dictionary mapping full usages Ids to plain values
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1295-L1300
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidReport.__alloc_raw_data
def __alloc_raw_data(self, initial_values=None): """Pre-allocate re-usagle memory""" #allocate c_ubyte storage if self.__raw_data == None: #first time only, create storage raw_data_type = c_ubyte * self.__raw_report_size self.__raw_data = raw_data_type() eli...
python
def __alloc_raw_data(self, initial_values=None): """Pre-allocate re-usagle memory""" #allocate c_ubyte storage if self.__raw_data == None: #first time only, create storage raw_data_type = c_ubyte * self.__raw_report_size self.__raw_data = raw_data_type() eli...
Pre-allocate re-usagle memory
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1302-L1316
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidReport.set_raw_data
def set_raw_data(self, raw_data): """Set usage values based on given raw data, item[0] is report_id, length should match 'raw_data_length' value, best performance if raw_data is c_ubyte ctypes array object type """ #pre-parsed data should exist assert(self.__hid_obj...
python
def set_raw_data(self, raw_data): """Set usage values based on given raw data, item[0] is report_id, length should match 'raw_data_length' value, best performance if raw_data is c_ubyte ctypes array object type """ #pre-parsed data should exist assert(self.__hid_obj...
Set usage values based on given raw data, item[0] is report_id, length should match 'raw_data_length' value, best performance if raw_data is c_ubyte ctypes array object type
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1318-L1375
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidReport.__prepare_raw_data
def __prepare_raw_data(self): "Format internal __raw_data storage according to usages setting" #pre-parsed data should exist if not self.__hid_object.ptr_preparsed_data: raise HIDError("HID object close or unable to request pre parsed "\ "report data") ...
python
def __prepare_raw_data(self): "Format internal __raw_data storage according to usages setting" #pre-parsed data should exist if not self.__hid_object.ptr_preparsed_data: raise HIDError("HID object close or unable to request pre parsed "\ "report data") ...
Format internal __raw_data storage according to usages setting
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1378-L1452
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidReport.get_raw_data
def get_raw_data(self): """Get raw HID report based on internal report item settings, creates new c_ubytes storage """ if self.__report_kind != HidP_Output \ and self.__report_kind != HidP_Feature: raise HIDError("Only for output or feature reports") ...
python
def get_raw_data(self): """Get raw HID report based on internal report item settings, creates new c_ubytes storage """ if self.__report_kind != HidP_Output \ and self.__report_kind != HidP_Feature: raise HIDError("Only for output or feature reports") ...
Get raw HID report based on internal report item settings, creates new c_ubytes storage
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1454-L1463
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidReport.send
def send(self, raw_data = None): """Prepare HID raw report (unless raw_data is provided) and send it to HID device """ if self.__report_kind != HidP_Output \ and self.__report_kind != HidP_Feature: raise HIDError("Only for output or feature reports") ...
python
def send(self, raw_data = None): """Prepare HID raw report (unless raw_data is provided) and send it to HID device """ if self.__report_kind != HidP_Output \ and self.__report_kind != HidP_Feature: raise HIDError("Only for output or feature reports") ...
Prepare HID raw report (unless raw_data is provided) and send it to HID device
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1465-L1499
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidReport.get
def get(self, do_process_raw_report = True): "Read report from device" assert(self.__hid_object.is_opened()) if self.__report_kind != HidP_Input and \ self.__report_kind != HidP_Feature: raise HIDError("Only for input or feature reports") # pre-alloc raw...
python
def get(self, do_process_raw_report = True): "Read report from device" assert(self.__hid_object.is_opened()) if self.__report_kind != HidP_Input and \ self.__report_kind != HidP_Feature: raise HIDError("Only for input or feature reports") # pre-alloc raw...
Read report from device
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1501-L1525
rene-aguirre/pywinusb
pywinusb/hid/core.py
HidPUsageCaps.inspect
def inspect(self): """Retreive dictionary of 'Field: Value' attributes""" results = {} for fname in dir(self): if not fname.startswith('_'): value = getattr(self, fname) if isinstance(value, collections.Callable): continue ...
python
def inspect(self): """Retreive dictionary of 'Field: Value' attributes""" results = {} for fname in dir(self): if not fname.startswith('_'): value = getattr(self, fname) if isinstance(value, collections.Callable): continue ...
Retreive dictionary of 'Field: Value' attributes
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L1560-L1569
rene-aguirre/pywinusb
examples/raw_set.py
set_mute
def set_mute(mute_value): "Browse for mute usages and set value" all_mutes = ( \ (0x8, 0x9), # LED page (0x1, 0xA7), # desktop page (0xb, 0x2f), ) all_target_usages = [hid.get_full_usage_id(u[0], u[1]) for u in all_mutes] # usually you'll find and open the target...
python
def set_mute(mute_value): "Browse for mute usages and set value" all_mutes = ( \ (0x8, 0x9), # LED page (0x1, 0xA7), # desktop page (0xb, 0x2f), ) all_target_usages = [hid.get_full_usage_id(u[0], u[1]) for u in all_mutes] # usually you'll find and open the target...
Browse for mute usages and set value
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/examples/raw_set.py#L13-L57
rene-aguirre/pywinusb
examples/pnp_sample.py
MyFrame.on_hid_pnp
def on_hid_pnp(self, hid_event = None): """This function will be called on per class event changes, so we need to test if our device has being connected or is just gone""" # keep old reference for UI updates old_device = self.device if hid_event: print("Hey, a...
python
def on_hid_pnp(self, hid_event = None): """This function will be called on per class event changes, so we need to test if our device has being connected or is just gone""" # keep old reference for UI updates old_device = self.device if hid_event: print("Hey, a...
This function will be called on per class event changes, so we need to test if our device has being connected or is just gone
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/examples/pnp_sample.py#L35-L65
rene-aguirre/pywinusb
pywinusb/hid/helpers.py
simple_decorator
def simple_decorator(decorator): """This decorator can be used to turn simple functions into well-behaved decorators, so long as the decorators are fairly simple. If a decorator expects a function and returns a function (no descriptors), and if it doesn't modify function attributes or docstring...
python
def simple_decorator(decorator): """This decorator can be used to turn simple functions into well-behaved decorators, so long as the decorators are fairly simple. If a decorator expects a function and returns a function (no descriptors), and if it doesn't modify function attributes or docstring...
This decorator can be used to turn simple functions into well-behaved decorators, so long as the decorators are fairly simple. If a decorator expects a function and returns a function (no descriptors), and if it doesn't modify function attributes or docstring, then it is eligible to use this. S...
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/helpers.py#L18-L40
rene-aguirre/pywinusb
pywinusb/hid/helpers.py
logging_decorator
def logging_decorator(func): """Allow logging function calls""" def you_will_never_see_this_name(*args, **kwargs): """Neither this docstring""" print('calling %s ...' % func.__name__) result = func(*args, **kwargs) print('completed: %s' % func.__name__) return resu...
python
def logging_decorator(func): """Allow logging function calls""" def you_will_never_see_this_name(*args, **kwargs): """Neither this docstring""" print('calling %s ...' % func.__name__) result = func(*args, **kwargs) print('completed: %s' % func.__name__) return resu...
Allow logging function calls
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/helpers.py#L46-L54
rene-aguirre/pywinusb
pywinusb/hid/helpers.py
synchronized
def synchronized(lock): """ Synchronization decorator. Allos to set a mutex on any function """ @simple_decorator def wrap(function_target): """Decorator wrapper""" def new_function(*args, **kw): """Decorated function with Mutex""" lock.acquire() ...
python
def synchronized(lock): """ Synchronization decorator. Allos to set a mutex on any function """ @simple_decorator def wrap(function_target): """Decorator wrapper""" def new_function(*args, **kw): """Decorated function with Mutex""" lock.acquire() ...
Synchronization decorator. Allos to set a mutex on any function
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/helpers.py#L56-L71
rene-aguirre/pywinusb
examples/pnp_qt.py
HidQtPnPWindowMixin.on_hid_pnp
def on_hid_pnp(self, hid_event = None): """This function will be called on per class event changes, so we need to test if our device has being connected or is just gone""" old_device = self.hid_device if hid_event: self.pnpChanged.emit(hid_event) if hid_event == "co...
python
def on_hid_pnp(self, hid_event = None): """This function will be called on per class event changes, so we need to test if our device has being connected or is just gone""" old_device = self.hid_device if hid_event: self.pnpChanged.emit(hid_event) if hid_event == "co...
This function will be called on per class event changes, so we need to test if our device has being connected or is just gone
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/examples/pnp_qt.py#L41-L71
rene-aguirre/pywinusb
pywinusb/hid/hid_pnp_mixin.py
HidPnPWindowMixin._on_hid_pnp
def _on_hid_pnp(self, w_param, l_param): "Process WM_DEVICECHANGE system messages" new_status = "unknown" if w_param == DBT_DEVICEARRIVAL: # hid device attached notify_obj = None if int(l_param): # Disable this error since pylint doesn't...
python
def _on_hid_pnp(self, w_param, l_param): "Process WM_DEVICECHANGE system messages" new_status = "unknown" if w_param == DBT_DEVICEARRIVAL: # hid device attached notify_obj = None if int(l_param): # Disable this error since pylint doesn't...
Process WM_DEVICECHANGE system messages
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/hid_pnp_mixin.py#L96-L130