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_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
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...
[ "def", "are_equivalent", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", "==", "1", ":", "return", "True", "first_item", "=", "args", "[", "0", "]", "for", "item", "in", "args", "[", "1", ":", "]", ":", "if",...
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...
[ "Indicate", "if", "arguments", "passed", "to", "this", "function", "are", "equivalent", "." ]
train
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...
[ "def", "are_dicts_equivalent", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=too-many-return-statements", "if", "not", "args", ":", "return", "False", "if", "len", "(", "args", ")", "==", "1", ":", "return", "True", "if", "not", "...
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:...
[ "Indicate", "if", ":", "ref", ":", "dicts", "<python", ":", "dict", ">", "passed", "to", "this", "function", "have", "identical", "keys", "and", "values", "." ]
train
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...
[ "def", "is_between", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "minimum", "is", "None", "and", "maximum", "is", "None", ":", "raise", "ValueError", "(", "'minimum and maximum cannot bot...
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 `...
[ "Indicate", "whether", "value", "is", "greater", "than", "or", "equal", "to", "a", "supplied", "minimum", "and", "/", "or", "less", "than", "or", "equal", "to", "maximum", "." ]
train
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...
[ "def", "has_length", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "minimum", "is", "None", "and", "maximum", "is", "None", ":", "raise", "ValueError", "(", "'minimum and maximum cannot bot...
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__...
[ "Indicate", "whether", "value", "has", "a", "length", "greater", "than", "or", "equal", "to", "a", "supplied", "minimum", "and", "/", "or", "less", "than", "or", "equal", "to", "maximum", "." ]
train
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...
[ "def", "is_dict", "(", "value", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "return", "True", "try", ":", "value", "=", "validators", ".", "dict", "(", "value", ",", "*", "*", "kwargs", ")", "except",...
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...
[ "Indicate", "whether", "value", "is", "a", "valid", ":", "class", ":", "dict", "<python", ":", "dict", ">" ]
train
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 ...
[ "def", "is_json", "(", "value", ",", "schema", "=", "None", ",", "json_serializer", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "json", "(", "value", ",", "schema", "=", "schema", ",", "json_serializer",...
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...
[ "Indicate", "whether", "value", "is", "a", "valid", "JSON", "object", "." ]
train
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...
[ "def", "is_string", "(", "value", ",", "coerce_value", "=", "False", ",", "minimum_length", "=", "None", ",", "maximum_length", "=", "None", ",", "whitespace_padding", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "value", "is", "None", ":", "re...
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,...
[ "Indicate", "whether", "value", "is", "a", "string", "." ]
train
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...
[ "def", "is_iterable", "(", "obj", ",", "forbid_literals", "=", "(", "str", ",", "bytes", ")", ",", "minimum_length", "=", "None", ",", "maximum_length", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "obj", "is", "None", ":", "return", "False", ...
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...
[ "Indicate", "whether", "obj", "is", "iterable", "." ]
train
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...
[ "def", "is_not_empty", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "not_empty", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exce...
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...
[ "Indicate", "whether", "value", "is", "empty", "." ]
train
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:...
[ "def", "is_none", "(", "value", ",", "allow_empty", "=", "False", ",", "*", "*", "kwargs", ")", ":", "try", ":", "validators", ".", "none", "(", "value", ",", "allow_empty", "=", "allow_empty", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as...
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`` ...
[ "Indicate", "whether", "value", "is", ":", "obj", ":", "None", "<python", ":", "None", ">", "." ]
train
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...
[ "def", "is_variable_name", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "validators", ".", "variable_name", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception", ...
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: ``...
[ "Indicate", "whether", "value", "is", "a", "valid", "Python", "variable", "name", "." ]
train
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 ...
[ "def", "is_uuid", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "validators", ".", "uuid", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception", ":", "return", ...
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 ...
[ "Indicate", "whether", "value", "contains", "a", ":", "class", ":", "UUID", "<python", ":", "uuid", ".", "UUID", ">" ]
train
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...
[ "def", "is_date", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "coerce_value", "=", "False", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "date", "(", "value", ",", "minimum", "=", ...
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>` / ...
[ "Indicate", "whether", "value", "is", "a", ":", "class", ":", "date", "<python", ":", "datetime", ".", "date", ">", "." ]
train
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...
[ "def", "is_datetime", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "coerce_value", "=", "False", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "datetime", "(", "value", ",", "minimum", ...
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...
[ "Indicate", "whether", "value", "is", "a", ":", "class", ":", "datetime", "<python", ":", "datetime", ".", "datetime", ">", "." ]
train
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...
[ "def", "is_time", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "coerce_value", "=", "False", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "time", "(", "value", ",", "minimum", "=", ...
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...
[ "Indicate", "whether", "value", "is", "a", ":", "class", ":", "time", "<python", ":", "datetime", ".", "time", ">", "." ]
train
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...
[ "def", "is_timezone", "(", "value", ",", "positive", "=", "True", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "timezone", "(", "value", ",", "positive", "=", "positive", ",", "*", "*", "kwargs", ")", "except", "Syn...
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: ...
[ "Indicate", "whether", "value", "is", "a", ":", "class", ":", "tzinfo", "<python", ":", "datetime", ".", "tzinfo", ">", "." ]
train
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. ...
[ "def", "is_numeric", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "numeric", "(", "value", ",", "minimum", "=", "minimum", ",", "maximum", "=",...
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...
[ "Indicate", "whether", "value", "is", "a", "numeric", "value", "." ]
train
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...
[ "def", "is_integer", "(", "value", ",", "coerce_value", "=", "False", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "base", "=", "10", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "integer", "(", ...
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...
[ "Indicate", "whether", "value", "contains", "a", "whole", "number", "." ]
train
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...
[ "def", "is_float", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "float", "(", "value", ",", "minimum", "=", "minimum", ",", "maximum", "=", "...
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...
[ "Indicate", "whether", "value", "is", "a", ":", "class", ":", "float", "<python", ":", "float", ">", "." ]
train
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...
[ "def", "is_fraction", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "fraction", "(", "value", ",", "minimum", "=", "minimum", ",", "maximum", "=...
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`...
[ "Indicate", "whether", "value", "is", "a", ":", "class", ":", "Fraction", "<python", ":", "fractions", ".", "Fraction", ">", "." ]
train
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 ...
[ "def", "is_decimal", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "decimal", "(", "value", ",", "minimum", "=", "minimum", ",", "maximum", "=",...
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...
[ "Indicate", "whether", "value", "contains", "a", ":", "class", ":", "Decimal", "<python", ":", "decimal", ".", "Decimal", ">", "." ]
train
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...
[ "def", "is_pathlike", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "path", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception"...
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 ...
[ "Indicate", "whether", "value", "is", "a", "path", "-", "like", "object", "." ]
train
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 `...
[ "def", "is_on_filesystem", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "path_exists", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", ...
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...
[ "Indicate", "whether", "value", "is", "a", "file", "or", "directory", "that", "exists", "on", "the", "local", "filesystem", "." ]
train
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...
[ "def", "is_file", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "file_exists", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Excepti...
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 ...
[ "Indicate", "whether", "value", "is", "a", "file", "that", "exists", "on", "the", "local", "filesystem", "." ]
train
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...
[ "def", "is_directory", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "directory_exists", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", ...
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...
[ "Indicate", "whether", "value", "is", "a", "directory", "that", "exists", "on", "the", "local", "filesystem", "." ]
train
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 ...
[ "def", "is_readable", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "validators", ".", "readable", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception", ":", "re...
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...
[ "Indicate", "whether", "value", "is", "a", "readable", "file", "." ]
train
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...
[ "def", "is_writeable", "(", "value", ",", "*", "*", "kwargs", ")", ":", "if", "sys", ".", "platform", "in", "[", "'win32'", ",", "'cygwin'", "]", ":", "raise", "NotImplementedError", "(", "'not supported on Windows'", ")", "try", ":", "validators", ".", "w...
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...
[ "Indicate", "whether", "value", "is", "a", "writeable", "file", "." ]
train
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...
[ "def", "is_executable", "(", "value", ",", "*", "*", "kwargs", ")", ":", "if", "sys", ".", "platform", "in", "[", "'win32'", ",", "'cygwin'", "]", ":", "raise", "NotImplementedError", "(", "'not supported on Windows'", ")", "try", ":", "validators", ".", "...
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...
[ "Indicate", "whether", "value", "is", "an", "executable", "file", "." ]
train
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...
[ "def", "is_email", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "email", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception", ...
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. ...
[ "Indicate", "whether", "value", "is", "an", "email", "address", "." ]
train
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>`_, ...
[ "def", "is_url", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "url", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception", ":...
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....
[ "Indicate", "whether", "value", "is", "a", "URL", "." ]
train
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``...
[ "def", "is_domain", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "domain", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception"...
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...
[ "Indicate", "whether", "value", "is", "a", "valid", "domain", "." ]
train
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 ...
[ "def", "is_ip_address", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "ip_address", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Ex...
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 ...
[ "Indicate", "whether", "value", "is", "a", "valid", "IP", "address", "(", "version", "4", "or", "version", "6", ")", "." ]
train
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...
[ "def", "is_ipv4", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "ipv4", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception", ...
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...
[ "Indicate", "whether", "value", "is", "a", "valid", "IP", "version", "4", "address", "." ]
train
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...
[ "def", "is_ipv6", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "ipv6", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "Exception", ...
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...
[ "Indicate", "whether", "value", "is", "a", "valid", "IP", "version", "6", "address", "." ]
train
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...
[ "def", "is_mac_address", "(", "value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "value", "=", "validators", ".", "mac_address", "(", "value", ",", "*", "*", "kwargs", ")", "except", "SyntaxError", "as", "error", ":", "raise", "error", "except", "...
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...
[ "Indicate", "whether", "value", "is", "a", "valid", "MAC", "address", "." ]
train
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,...
[ "def", "draw_line", "(", "self", ",", "lx", ",", "ltor", ")", ":", "tag", "=", "self", ".", "get_tag", "(", ")", "c", "=", "self", ".", "canvas", "s", "=", "self", ".", "style", "sep", "=", "s", ".", "h_sep", "exx", "=", "0", "exy", "=", "0",...
Draw a series of elements from left to right
[ "Draw", "a", "series", "of", "elements", "from", "left", "to", "right" ]
train
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): ...
[ "def", "get_file_fields", "(", ")", ":", "# get models", "all_models", "=", "apps", ".", "get_models", "(", ")", "# get fields", "fields", "=", "[", "]", "for", "model", "in", "all_models", ":", "for", "field", "in", "model", ".", "_meta", ".", "get_fields...
Get all fields which are inherited from FileField
[ "Get", "all", "fields", "which", "are", "inherited", "from", "FileField" ]
train
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))
[ "def", "remove_media", "(", "files", ")", ":", "for", "filename", "in", "files", ":", "os", ".", "remove", "(", "os", ".", "path", ".", "join", "(", "settings", ".", "MEDIA_ROOT", ",", "filename", ")", ")" ]
Delete file from media dir
[ "Delete", "file", "from", "media", "dir" ]
train
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)]...
[ "def", "remove_empty_dirs", "(", "path", "=", "None", ")", ":", "if", "not", "path", ":", "path", "=", "settings", ".", "MEDIA_ROOT", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "return", "False", "listdir", "=", "[", "os", ...
Recursively delete empty directories; return True if everything was deleted.
[ "Recursively", "delete", "empty", "directories", ";", "return", "True", "if", "everything", "was", "deleted", "." ]
train
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 ...
[ "def", "get_used_media", "(", ")", ":", "media", "=", "set", "(", ")", "for", "field", "in", "get_file_fields", "(", ")", ":", "is_null", "=", "{", "'%s__isnull'", "%", "field", ".", "name", ":", "True", ",", "}", "is_empty", "=", "{", "'%s'", "%", ...
Get media which are still used in models
[ "Get", "media", "which", "are", "still", "used", "in", "models" ]
train
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)) ...
[ "def", "get_all_media", "(", "exclude", "=", "None", ")", ":", "if", "not", "exclude", ":", "exclude", "=", "[", "]", "media", "=", "set", "(", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "six", ".", "text_type", ...
Get all media from MEDIA_ROOT
[ "Get", "all", "media", "from", "MEDIA_ROOT" ]
train
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
[ "def", "get_unused_media", "(", "exclude", "=", "None", ")", ":", "if", "not", "exclude", ":", "exclude", "=", "[", "]", "all_media", "=", "get_all_media", "(", "exclude", ")", "used_media", "=", "get_used_media", "(", ")", "return", "all_media", "-", "use...
Get media which are not used in models
[ "Get", "media", "which", "are", "not", "used", "in", "models" ]
train
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()
[ "def", "createCluster", "(", "self", ",", "hzVersion", ",", "xmlconfig", ")", ":", "self", ".", "send_createCluster", "(", "hzVersion", ",", "xmlconfig", ")", "return", "self", ".", "recv_createCluster", "(", ")" ]
Parameters: - hzVersion - xmlconfig
[ "Parameters", ":", "-", "hzVersion", "-", "xmlconfig" ]
train
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()
[ "def", "shutdownMember", "(", "self", ",", "clusterId", ",", "memberId", ")", ":", "self", ".", "send_shutdownMember", "(", "clusterId", ",", "memberId", ")", "return", "self", ".", "recv_shutdownMember", "(", ")" ]
Parameters: - clusterId - memberId
[ "Parameters", ":", "-", "clusterId", "-", "memberId" ]
train
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()
[ "def", "terminateMember", "(", "self", ",", "clusterId", ",", "memberId", ")", ":", "self", ".", "send_terminateMember", "(", "clusterId", ",", "memberId", ")", "return", "self", ".", "recv_terminateMember", "(", ")" ]
Parameters: - clusterId - memberId
[ "Parameters", ":", "-", "clusterId", "-", "memberId" ]
train
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()
[ "def", "suspendMember", "(", "self", ",", "clusterId", ",", "memberId", ")", ":", "self", ".", "send_suspendMember", "(", "clusterId", ",", "memberId", ")", "return", "self", ".", "recv_suspendMember", "(", ")" ]
Parameters: - clusterId - memberId
[ "Parameters", ":", "-", "clusterId", "-", "memberId" ]
train
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()
[ "def", "resumeMember", "(", "self", ",", "clusterId", ",", "memberId", ")", ":", "self", ".", "send_resumeMember", "(", "clusterId", ",", "memberId", ")", "return", "self", ".", "recv_resumeMember", "(", ")" ]
Parameters: - clusterId - memberId
[ "Parameters", ":", "-", "clusterId", "-", "memberId" ]
train
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()
[ "def", "mergeMemberToCluster", "(", "self", ",", "clusterId", ",", "memberId", ")", ":", "self", ".", "send_mergeMemberToCluster", "(", "clusterId", ",", "memberId", ")", "return", "self", ".", "recv_mergeMemberToCluster", "(", ")" ]
Parameters: - clusterId - memberId
[ "Parameters", ":", "-", "clusterId", "-", "memberId" ]
train
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()
[ "def", "executeOnController", "(", "self", ",", "clusterId", ",", "script", ",", "lang", ")", ":", "self", ".", "send_executeOnController", "(", "clusterId", ",", "script", ",", "lang", ")", "return", "self", ".", "recv_executeOnController", "(", ")" ]
Parameters: - clusterId - script - lang
[ "Parameters", ":", "-", "clusterId", "-", "script", "-", "lang" ]
train
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...
[ "def", "deltaE", "(", "color1", ",", "color2", ",", "input_space", "=", "\"sRGB1\"", ",", "uniform_space", "=", "\"CAM02-UCS\"", ")", ":", "uniform1", "=", "cspace_convert", "(", "color1", ",", "input_space", ",", "uniform_space", ")", "uniform2", "=", "cspace...
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...
[ "Computes", "the", ":", "math", ":", "\\", "Delta", "E", "distance", "between", "pairs", "of", "colors", "." ]
train
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...
[ "def", "XYZ100_to_sRGB1_linear", "(", "XYZ100", ")", ":", "XYZ100", "=", "np", ".", "asarray", "(", "XYZ100", ",", "dtype", "=", "float", ")", "# this is broadcasting matrix * array-of-vectors, where the vector is the", "# last dim", "RGB_linear", "=", "np", ".", "ein...
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).
[ "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"...
train
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
[ "def", "sRGB1_to_sRGB1_linear", "(", "sRGB1", ")", ":", "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.
[ "Convert", "sRGB", "(", "as", "floats", "in", "the", "0", "-", "to", "-", "1", "range", ")", "to", "linear", "sRGB", "." ]
train
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 ...
[ "def", "cspace_converter", "(", "start", ",", "end", ")", ":", "start", "=", "norm_cspace_id", "(", "start", ")", "end", "=", "norm_cspace_id", "(", "end", ")", "return", "GRAPH", ".", "get_transform", "(", "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 are doing a large number of conversions b...
[ "Returns", "a", "function", "for", "converting", "from", "colorspace", "start", "to", "colorspace", "end", "." ]
train
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...
[ "def", "cspace_convert", "(", "arr", ",", "start", ",", "end", ")", ":", "converter", "=", "cspace_converter", "(", "start", ",", "end", ")", "return", "converter", "(", "arr", ")" ]
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.
[ "Converts", "the", "colors", "in", "arr", "from", "colorspace", "start", "to", "colorspace", "end", "." ]
train
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...
[ "def", "XYZ100_to_CIECAM02", "(", "self", ",", "XYZ100", ",", "on_negative_A", "=", "\"raise\"", ")", ":", "#### Argument checking", "XYZ100", "=", "np", ".", "asarray", "(", "XYZ100", ",", "dtype", "=", "float", ")", "if", "XYZ100", ".", "shape", "[", "-"...
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...
[ "Computes", "CIECAM02", "appearance", "correlates", "for", "the", "given", "tristimulus", "value", "(", "s", ")", "XYZ", "(", "normalized", "to", "be", "on", "the", "0", "-", "100", "scale", ")", "." ]
train
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...
[ "def", "CIECAM02_to_XYZ100", "(", "self", ",", "J", "=", "None", ",", "C", "=", "None", ",", "h", "=", "None", ",", "Q", "=", "None", ",", "M", "=", "None", ",", "s", "=", "None", ",", "H", "=", "None", ")", ":", "#### Argument checking", "requir...
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...
[ "Return", "the", "unique", "tristimulus", "values", "that", "have", "the", "given", "CIECAM02", "appearance", "correlates", "under", "these", "viewing", "conditions", "." ]
train
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"`` * ...
[ "def", "standard_illuminant_XYZ100", "(", "name", ",", "observer", "=", "\"CIE 1931 2 deg\"", ")", ":", "if", "observer", "==", "\"CIE 1931 2 deg\"", ":", "return", "np", ".", "asarray", "(", "cie1931", "[", "name", "]", ",", "dtype", "=", "float", ")", "eli...
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...
[ "Takes", "a", "string", "naming", "a", "standard", "illuminant", "and", "returns", "its", "XYZ", "coordinates", "(", "normalized", "to", "Y", "=", "100", ")", "." ]
train
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...
[ "def", "as_XYZ100_w", "(", "whitepoint", ")", ":", "if", "isinstance", "(", "whitepoint", ",", "str", ")", ":", "return", "standard_illuminant_XYZ100", "(", "whitepoint", ")", "else", ":", "whitepoint", "=", "np", ".", "asarray", "(", "whitepoint", ",", "dty...
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 ...
[ "A", "convenience", "function", "for", "getting", "whitepoints", "." ]
train
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 ...
[ "def", "machado_et_al_2009_matrix", "(", "cvd_type", ",", "severity", ")", ":", "assert", "0", "<=", "severity", "<=", "100", "fraction", "=", "severity", "%", "10", "low", "=", "int", "(", "severity", "-", "fraction", ")", "high", "=", "low", "+", "10",...
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: ...
[ "Retrieve", "a", "matrix", "for", "simulating", "anomalous", "color", "vision", "." ]
train
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...
[ "def", "_make_retval_checker", "(", "self", ")", ":", "rvchk", "=", "self", ".", "retval", ".", "checker", "if", "rvchk", ":", "def", "_checker", "(", "value", ")", ":", "if", "not", "rvchk", ".", "check", "(", "value", ")", ":", "raise", "self", "."...
Create a function that checks the return value of the function.
[ "Create", "a", "function", "that", "checks", "the", "return", "value", "of", "the", "function", "." ]
train
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) ...
[ "def", "_make_args_checker", "(", "self", ")", ":", "def", "_checker", "(", "*", "args", ",", "*", "*", "kws", ")", ":", "# Check if too many arguments are provided", "nargs", "=", "len", "(", "args", ")", "nnonvaargs", "=", "min", "(", "nargs", ",", "self...
Create a function that checks signature of the source function.
[ "Create", "a", "function", "that", "checks", "signature", "of", "the", "source", "function", "." ]
train
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...
[ "def", "checker_for_type", "(", "t", ")", ":", "try", ":", "if", "t", "is", "True", ":", "return", "true_checker", "if", "t", "is", "False", ":", "return", "false_checker", "checker", "=", "memoized_type_checkers", ".", "get", "(", "t", ")", "if", "check...
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")...
[ "Return", "checker", "function", "for", "the", "given", "type", "t", "." ]
train
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...
[ "def", "_prepare_value", "(", "val", ",", "maxlen", "=", "50", ",", "notype", "=", "False", ")", ":", "if", "val", "is", "None", "or", "val", "is", "True", "or", "val", "is", "False", ":", "return", "str", "(", "val", ")", "sval", "=", "repr", "(...
Stringify value `val`, ensuring that it is not too long.
[ "Stringify", "value", "val", "ensuring", "that", "it", "is", "not", "too", "long", "." ]
train
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
[ "def", "_nth_str", "(", "n", ")", ":", "if", "n", "%", "10", "==", "1", "and", "n", "%", "100", "!=", "11", ":", "return", "\"%dst\"", "%", "n", "if", "n", "%", "10", "==", "2", "and", "n", "%", "100", "!=", "12", ":", "return", "\"%dnd\"", ...
Return posessive form of numeral `n`: 1st, 2nd, 3rd, etc.
[ "Return", "posessive", "form", "of", "numeral", "n", ":", "1st", "2nd", "3rd", "etc", "." ]
train
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...
[ "def", "train", "(", "self", ",", "text", ",", "className", ")", ":", "self", ".", "data", ".", "increaseClass", "(", "className", ")", "tokens", "=", "self", ".", "tokenizer", ".", "tokenize", "(", "text", ")", "for", "token", "in", "tokens", ":", "...
enhances trained data using the given text and class
[ "enhances", "trained", "data", "using", "the", "given", "text", "and", "class" ]
train
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...
[ "def", "hid_device_path_exists", "(", "device_path", ",", "guid", "=", "None", ")", ":", "# expecing HID devices\r", "if", "not", "guid", ":", "guid", "=", "winapi", ".", "GetHidGuid", "(", ")", "info_data", "=", "winapi", ".", "SP_DEVINFO_DATA", "(", ")", "...
Test if required device_path is still valid (HID device connected to host)
[ "Test", "if", "required", "device_path", "is", "still", "valid", "(", "HID", "device", "connected", "to", "host", ")" ]
train
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...
[ "def", "find_all_hid_devices", "(", ")", ":", "#\r", "# From DDK documentation (finding and Opening HID collection):\r", "# After a user-mode application is loaded, it does the following sequence\r", "# of operations:\r", "#\r", "# * Calls HidD_GetHidGuid to obtain the system-defined GUID for ...
Finds all HID devices connected to the system
[ "Finds", "all", "HID", "devices", "connected", "to", "the", "system" ]
train
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 ...
[ "def", "show_hids", "(", "target_vid", "=", "0", ",", "target_pid", "=", "0", ",", "output", "=", "None", ")", ":", "# first be kind with local encodings\r", "if", "not", "output", ":", "# beware your script should manage encodings\r", "output", "=", "sys", ".", "...
Check all HID devices conected to PC hosts.
[ "Check", "all", "HID", "devices", "conected", "to", "PC", "hosts", "." ]
train
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...
[ "def", "get_devices_by_parent", "(", "self", ",", "hid_filter", "=", "None", ")", ":", "all_devs", "=", "self", ".", "get_devices", "(", "hid_filter", ")", "dev_group", "=", "dict", "(", ")", "for", "hid_device", "in", "all_devs", ":", "#keep a list of known d...
Group devices returned from filter query in order \ by devcice parent id.
[ "Group", "devices", "returned", "from", "filter", "query", "in", "order", "\\", "by", "devcice", "parent", "id", "." ]
train
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): ...
[ "def", "get_devices", "(", "self", ",", "hid_filter", "=", "None", ")", ":", "if", "not", "hid_filter", ":", "#empty list or called without any parameters\r", "if", "type", "(", "hid_filter", ")", "==", "type", "(", "None", ")", ":", "#request to query connected d...
Filter a HID device list by current object parameters. Devices must match the all of the filtering parameters
[ "Filter", "a", "HID", "device", "list", "by", "current", "object", "parameters", ".", "Devices", "must", "match", "the", "all", "of", "the", "filtering", "parameters" ]
train
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...
[ "def", "get_parent_device", "(", "self", ")", ":", "if", "not", "self", ".", "parent_instance_id", ":", "return", "\"\"", "dev_buffer_type", "=", "winapi", ".", "c_tchar", "*", "MAX_DEVICE_ID_LEN", "dev_buffer", "=", "dev_buffer_type", "(", ")", "try", ":", "i...
Retreive parent device string id
[ "Retreive", "parent", "device", "string", "id" ]
train
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 ...
[ "def", "open", "(", "self", ",", "output_only", "=", "False", ",", "shared", "=", "True", ")", ":", "if", "self", ".", "is_opened", "(", ")", ":", "raise", "HIDError", "(", "\"Device already opened\"", ")", "sharing_flags", "=", "0", "if", "shared", ":",...
Open HID device and obtain 'Collection Information'. It effectively prepares the HidDevice object for reading and writing
[ "Open", "HID", "device", "and", "obtain", "Collection", "Information", ".", "It", "effectively", "prepares", "the", "HidDevice", "object", "for", "reading", "and", "writing" ]
train
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] ...
[ "def", "get_physical_descriptor", "(", "self", ")", ":", "raw_data_type", "=", "c_ubyte", "*", "1024", "raw_data", "=", "raw_data_type", "(", ")", "if", "hid_dll", ".", "HidD_GetPhysicalDescriptor", "(", "self", ".", "hid_handle", ",", "byref", "(", "raw_data", ...
Returns physical HID device descriptor
[ "Returns", "physical", "HID", "device", "descriptor" ]
train
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...
[ "def", "send_output_report", "(", "self", ",", "data", ")", ":", "assert", "(", "self", ".", "is_opened", "(", ")", ")", "#make sure we have c_ubyte array storage\r", "if", "not", "(", "isinstance", "(", "data", ",", "ctypes", ".", "Array", ")", "and", "issu...
Send input/output/feature report ID = report_id, data should be a c_ubyte object with included the required report data
[ "Send", "input", "/", "output", "/", "feature", "report", "ID", "=", "report_id", "data", "should", "be", "a", "c_ubyte", "object", "with", "included", "the", "required", "report", "data" ]
train
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...
[ "def", "send_feature_report", "(", "self", ",", "data", ")", ":", "assert", "(", "self", ".", "is_opened", "(", ")", ")", "#make sure we have c_ubyte array storage\r", "if", "not", "(", "isinstance", "(", "data", ",", "ctypes", ".", "Array", ")", "and", "iss...
Send input/output/feature report ID = report_id, data should be a c_byte object with included the required report data
[ "Send", "input", "/", "output", "/", "feature", "report", "ID", "=", "report_id", "data", "should", "be", "a", "c_byte", "object", "with", "included", "the", "required", "report", "data" ]
train
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 ...
[ "def", "__reset_vars", "(", "self", ")", ":", "self", ".", "__button_caps_storage", "=", "list", "(", ")", "self", ".", "usages_storage", "=", "dict", "(", ")", "self", ".", "report_set", "=", "dict", "(", ")", "self", ".", "ptr_preparsed_data", "=", "No...
Reset vars (for init or gc)
[ "Reset", "vars", "(", "for", "init", "or", "gc", ")" ]
train
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_...
[ "def", "close", "(", "self", ")", ":", "# free parsed data\r", "if", "not", "self", ".", "is_opened", "(", ")", ":", "return", "self", ".", "__open_status", "=", "False", "# abort all running threads first\r", "if", "self", ".", "__reading_thread", "and", "self"...
Release system resources
[ "Release", "system", "resources" ]
train
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...
[ "def", "__find_reports", "(", "self", ",", "report_type", ",", "usage_page", ",", "usage_id", "=", "0", ")", ":", "if", "not", "self", ".", "is_opened", "(", ")", ":", "raise", "HIDError", "(", "\"Device must be opened\"", ")", "#\r", "results", "=", "list...
Find input report referencing HID usage control/data item
[ "Find", "input", "report", "referencing", "HID", "usage", "control", "/", "data", "item" ]
train
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, ...
[ "def", "find_any_reports", "(", "self", ",", "usage_page", "=", "0", ",", "usage_id", "=", "0", ")", ":", "items", "=", "[", "(", "HidP_Input", ",", "self", ".", "find_input_reports", "(", "usage_page", ",", "usage_id", ")", ")", ",", "(", "HidP_Output",...
Find any report type referencing HID usage control/data item. Results are returned in a dictionary mapping report_type to usage lists.
[ "Find", "any", "report", "type", "referencing", "HID", "usage", "control", "/", "data", "item", ".", "Results", "are", "returned", "in", "a", "dictionary", "mapping", "report_type", "to", "usage", "lists", "." ]
train
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...
[ "def", "_process_raw_report", "(", "self", ",", "raw_report", ")", ":", "if", "not", "self", ".", "is_opened", "(", ")", ":", "return", "if", "not", "self", ".", "__evt_handlers", "and", "not", "self", ".", "__raw_handler", ":", "return", "if", "not", "r...
Default raw input report data handler
[ "Default", "raw", "input", "report", "data", "handler" ]
train
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...
[ "def", "find_input_usage", "(", "self", ",", "full_usage_id", ")", ":", "for", "report_id", ",", "report_obj", "in", "self", ".", "__input_report_templates", ".", "items", "(", ")", ":", "if", "full_usage_id", "in", "report_obj", ":", "return", "report_id", "r...
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.
[ "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"...
train
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...
[ "def", "add_event_handler", "(", "self", ",", "full_usage_id", ",", "handler_function", ",", "event_kind", "=", "HID_EVT_ALL", ",", "aux_data", "=", "None", ")", ":", "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
[ "Add", "event", "handler", "for", "usage", "value", "/", "button", "changes", "returns", "True", "if", "the", "handler", "function", "was", "updated" ]
train
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...
[ "def", "set_value", "(", "self", ",", "value", ")", ":", "if", "self", ".", "__is_value_array", ":", "if", "len", "(", "value", ")", "==", "self", ".", "__report_count", ":", "for", "index", ",", "item", "in", "enumerate", "(", "value", ")", ":", "se...
Set usage value within report
[ "Set", "usage", "value", "within", "report" ]
train
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): ...
[ "def", "get_value", "(", "self", ")", ":", "if", "self", ".", "__is_value_array", ":", "if", "self", ".", "__bit_size", "==", "8", ":", "#matching c_ubyte\r", "return", "list", "(", "self", ".", "__value", ")", "else", ":", "result", "=", "[", "]", "fo...
Retreive usage value within report
[ "Retreive", "usage", "value", "within", "report" ]
train
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() ...
[ "def", "get_usage_string", "(", "self", ")", ":", "if", "self", ".", "string_index", ":", "usage_string_type", "=", "c_wchar", "*", "MAX_HID_STRING_LENGTH", "# 128 max string length\r", "abuffer", "=", "usage_string_type", "(", ")", "hid_dll", ".", "HidD_GetIndexedStr...
Returns usage representation string (as embedded in HID device if available)
[ "Returns", "usage", "representation", "string", "(", "as", "embedded", "in", "HID", "device", "if", "available", ")" ]
train
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
[ "def", "get_usages", "(", "self", ")", ":", "result", "=", "dict", "(", ")", "for", "key", ",", "usage", "in", "self", ".", "items", "(", ")", ":", "result", "[", "key", "]", "=", "usage", ".", "value", "return", "result" ]
Return a dictionary mapping full usages Ids to plain values
[ "Return", "a", "dictionary", "mapping", "full", "usages", "Ids", "to", "plain", "values" ]
train
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...
[ "def", "__alloc_raw_data", "(", "self", ",", "initial_values", "=", "None", ")", ":", "#allocate c_ubyte storage\r", "if", "self", ".", "__raw_data", "==", "None", ":", "#first time only, create storage\r", "raw_data_type", "=", "c_ubyte", "*", "self", ".", "__raw_r...
Pre-allocate re-usagle memory
[ "Pre", "-", "allocate", "re", "-", "usagle", "memory" ]
train
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...
[ "def", "set_raw_data", "(", "self", ",", "raw_data", ")", ":", "#pre-parsed data should exist\r", "assert", "(", "self", ".", "__hid_object", ".", "is_opened", "(", ")", ")", "#valid length\r", "if", "len", "(", "raw_data", ")", "!=", "self", ".", "__raw_repor...
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
[ "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" ]
train
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") ...
[ "def", "__prepare_raw_data", "(", "self", ")", ":", "#pre-parsed data should exist\r", "if", "not", "self", ".", "__hid_object", ".", "ptr_preparsed_data", ":", "raise", "HIDError", "(", "\"HID object close or unable to request pre parsed \"", "\"report data\"", ")", "# mak...
Format internal __raw_data storage according to usages setting
[ "Format", "internal", "__raw_data", "storage", "according", "to", "usages", "setting" ]
train
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") ...
[ "def", "get_raw_data", "(", "self", ")", ":", "if", "self", ".", "__report_kind", "!=", "HidP_Output", "and", "self", ".", "__report_kind", "!=", "HidP_Feature", ":", "raise", "HIDError", "(", "\"Only for output or feature reports\"", ")", "self", ".", "__prepare_...
Get raw HID report based on internal report item settings, creates new c_ubytes storage
[ "Get", "raw", "HID", "report", "based", "on", "internal", "report", "item", "settings", "creates", "new", "c_ubytes", "storage" ]
train
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") ...
[ "def", "send", "(", "self", ",", "raw_data", "=", "None", ")", ":", "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
[ "Prepare", "HID", "raw", "report", "(", "unless", "raw_data", "is", "provided", ")", "and", "send", "it", "to", "HID", "device" ]
train
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...
[ "def", "get", "(", "self", ",", "do_process_raw_report", "=", "True", ")", ":", "assert", "(", "self", ".", "__hid_object", ".", "is_opened", "(", ")", ")", "if", "self", ".", "__report_kind", "!=", "HidP_Input", "and", "self", ".", "__report_kind", "!=", ...
Read report from device
[ "Read", "report", "from", "device" ]
train
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 ...
[ "def", "inspect", "(", "self", ")", ":", "results", "=", "{", "}", "for", "fname", "in", "dir", "(", "self", ")", ":", "if", "not", "fname", ".", "startswith", "(", "'_'", ")", ":", "value", "=", "getattr", "(", "self", ",", "fname", ")", "if", ...
Retreive dictionary of 'Field: Value' attributes
[ "Retreive", "dictionary", "of", "Field", ":", "Value", "attributes" ]
train
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...
[ "def", "set_mute", "(", "mute_value", ")", ":", "all_mutes", "=", "(", "(", "0x8", ",", "0x9", ")", ",", "# LED page", "(", "0x1", ",", "0xA7", ")", ",", "# desktop page", "(", "0xb", ",", "0x2f", ")", ",", ")", "all_target_usages", "=", "[", "hid", ...
Browse for mute usages and set value
[ "Browse", "for", "mute", "usages", "and", "set", "value" ]
train
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...
[ "def", "on_hid_pnp", "(", "self", ",", "hid_event", "=", "None", ")", ":", "# keep old reference for UI updates\r", "old_device", "=", "self", ".", "device", "if", "hid_event", ":", "print", "(", "\"Hey, a hid device just %s!\"", "%", "hid_event", ")", "if", "hid_...
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
[ "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" ]
train
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...
[ "def", "simple_decorator", "(", "decorator", ")", ":", "def", "new_decorator", "(", "funct_target", ")", ":", "\"\"\"This will be modified\"\"\"", "decorated", "=", "decorator", "(", "funct_target", ")", "decorated", ".", "__name__", "=", "funct_target", ".", "__nam...
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...
[ "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", ...
train
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...
[ "def", "logging_decorator", "(", "func", ")", ":", "def", "you_will_never_see_this_name", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Neither this docstring\"\"\"", "print", "(", "'calling %s ...'", "%", "func", ".", "__name__", ")", "result", "=...
Allow logging function calls
[ "Allow", "logging", "function", "calls" ]
train
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() ...
[ "def", "synchronized", "(", "lock", ")", ":", "@", "simple_decorator", "def", "wrap", "(", "function_target", ")", ":", "\"\"\"Decorator wrapper\"\"\"", "def", "new_function", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "\"\"\"Decorated function with Mutex\"\...
Synchronization decorator. Allos to set a mutex on any function
[ "Synchronization", "decorator", ".", "Allos", "to", "set", "a", "mutex", "on", "any", "function" ]
train
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...
[ "def", "on_hid_pnp", "(", "self", ",", "hid_event", "=", "None", ")", ":", "old_device", "=", "self", ".", "hid_device", "if", "hid_event", ":", "self", ".", "pnpChanged", ".", "emit", "(", "hid_event", ")", "if", "hid_event", "==", "\"connected\"", ":", ...
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
[ "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" ]
train
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...
[ "def", "_on_hid_pnp", "(", "self", ",", "w_param", ",", "l_param", ")", ":", "new_status", "=", "\"unknown\"", "if", "w_param", "==", "DBT_DEVICEARRIVAL", ":", "# hid device attached\r", "notify_obj", "=", "None", "if", "int", "(", "l_param", ")", ":", "# Disa...
Process WM_DEVICECHANGE system messages
[ "Process", "WM_DEVICECHANGE", "system", "messages" ]
train
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/hid_pnp_mixin.py#L96-L130