repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
seequent/properties | properties/base/containers.py | Dictionary.info | def info(self):
"""Supplemental description of the list, with length and type"""
itext = self.class_info
if self.key_prop.info and self.value_prop.info:
itext += ' (keys: {}; values: {})'.format(
self.key_prop.info, self.value_prop.info
)
elif self... | python | def info(self):
"""Supplemental description of the list, with length and type"""
itext = self.class_info
if self.key_prop.info and self.value_prop.info:
itext += ' (keys: {}; values: {})'.format(
self.key_prop.info, self.value_prop.info
)
elif self... | Supplemental description of the list, with length and type | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/containers.py#L557-L568 |
seequent/properties | properties/base/containers.py | Dictionary.assert_valid | def assert_valid(self, instance, value=None):
"""Check if dict and contained properties are valid"""
valid = super(Dictionary, self).assert_valid(instance, value)
if not valid:
return False
if value is None:
value = instance._get(self.name)
if value is Non... | python | def assert_valid(self, instance, value=None):
"""Check if dict and contained properties are valid"""
valid = super(Dictionary, self).assert_valid(instance, value)
if not valid:
return False
if value is None:
value = instance._get(self.name)
if value is Non... | Check if dict and contained properties are valid | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/containers.py#L600-L615 |
seequent/properties | properties/base/containers.py | Dictionary.serialize | def serialize(self, value, **kwargs):
"""Return a serialized copy of the dict"""
kwargs.update({'include_class': kwargs.get('include_class', True)})
if self.serializer is not None:
return self.serializer(value, **kwargs)
if value is None:
return None
seria... | python | def serialize(self, value, **kwargs):
"""Return a serialized copy of the dict"""
kwargs.update({'include_class': kwargs.get('include_class', True)})
if self.serializer is not None:
return self.serializer(value, **kwargs)
if value is None:
return None
seria... | Return a serialized copy of the dict | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/containers.py#L617-L636 |
seequent/properties | properties/base/containers.py | Dictionary.deserialize | def deserialize(self, value, **kwargs):
"""Return a deserialized copy of the dict"""
kwargs.update({'trusted': kwargs.get('trusted', False)})
if self.deserializer is not None:
return self.deserializer(value, **kwargs)
if value is None:
return None
output_t... | python | def deserialize(self, value, **kwargs):
"""Return a deserialized copy of the dict"""
kwargs.update({'trusted': kwargs.get('trusted', False)})
if self.deserializer is not None:
return self.deserializer(value, **kwargs)
if value is None:
return None
output_t... | Return a deserialized copy of the dict | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/containers.py#L638-L657 |
seequent/properties | properties/base/containers.py | Dictionary.to_json | def to_json(value, **kwargs):
"""Return a copy of the dictionary
If the values are HasProperties instances, they are serialized
"""
serial_dict = {
key: (
val.serialize(**kwargs) if isinstance(val, HasProperties)
else val
)
... | python | def to_json(value, **kwargs):
"""Return a copy of the dictionary
If the values are HasProperties instances, they are serialized
"""
serial_dict = {
key: (
val.serialize(**kwargs) if isinstance(val, HasProperties)
else val
)
... | Return a copy of the dictionary
If the values are HasProperties instances, they are serialized | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/containers.py#L673-L685 |
seequent/properties | properties/utils.py | filter_props | def filter_props(has_props_cls, input_dict, include_immutable=True):
"""Split a dictionary based keys that correspond to Properties
Returns:
**(props_dict, others_dict)** - Tuple of two dictionaries. The first contains
key/value pairs from the input dictionary that correspond to the
Properties of t... | python | def filter_props(has_props_cls, input_dict, include_immutable=True):
"""Split a dictionary based keys that correspond to Properties
Returns:
**(props_dict, others_dict)** - Tuple of two dictionaries. The first contains
key/value pairs from the input dictionary that correspond to the
Properties of t... | Split a dictionary based keys that correspond to Properties
Returns:
**(props_dict, others_dict)** - Tuple of two dictionaries. The first contains
key/value pairs from the input dictionary that correspond to the
Properties of the input HasProperties class. The second contains the remaining key/value
... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/utils.py#L13-L64 |
seequent/properties | properties/base/union.py | Union.default | def default(self):
"""Default value of the property"""
prop_def = getattr(self, '_default', utils.undefined)
for prop in self.props:
if prop.default is utils.undefined:
continue
if prop_def is utils.undefined:
prop_def = prop.default
... | python | def default(self):
"""Default value of the property"""
prop_def = getattr(self, '_default', utils.undefined)
for prop in self.props:
if prop.default is utils.undefined:
continue
if prop_def is utils.undefined:
prop_def = prop.default
... | Default value of the property | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/union.py#L125-L134 |
seequent/properties | properties/base/union.py | Union._try_prop_method | def _try_prop_method(self, instance, value, method_name):
"""Helper method to perform a method on each of the union props
This method gathers all errors and returns them at the end
if the method on each of the props fails.
"""
error_messages = []
for prop in self.props:
... | python | def _try_prop_method(self, instance, value, method_name):
"""Helper method to perform a method on each of the union props
This method gathers all errors and returns them at the end
if the method on each of the props fails.
"""
error_messages = []
for prop in self.props:
... | Helper method to perform a method on each of the union props
This method gathers all errors and returns them at the end
if the method on each of the props fails. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/union.py#L164-L185 |
seequent/properties | properties/base/union.py | Union.assert_valid | def assert_valid(self, instance, value=None):
"""Check if the Union has a valid value"""
valid = super(Union, self).assert_valid(instance, value)
if not valid:
return False
if value is None:
value = instance._get(self.name)
if value is None:
... | python | def assert_valid(self, instance, value=None):
"""Check if the Union has a valid value"""
valid = super(Union, self).assert_valid(instance, value)
if not valid:
return False
if value is None:
value = instance._get(self.name)
if value is None:
... | Check if the Union has a valid value | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/union.py#L191-L200 |
seequent/properties | properties/base/union.py | Union.serialize | def serialize(self, value, **kwargs):
"""Return a serialized value
If no serializer is provided, it uses the serialize method of the
prop corresponding to the value
"""
kwargs.update({'include_class': kwargs.get('include_class', True)})
if self.serializer is not None:
... | python | def serialize(self, value, **kwargs):
"""Return a serialized value
If no serializer is provided, it uses the serialize method of the
prop corresponding to the value
"""
kwargs.update({'include_class': kwargs.get('include_class', True)})
if self.serializer is not None:
... | Return a serialized value
If no serializer is provided, it uses the serialize method of the
prop corresponding to the value | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/union.py#L202-L219 |
seequent/properties | properties/base/union.py | Union.deserialize | def deserialize(self, value, **kwargs):
"""Return a deserialized value
If no deserializer is provided, it uses the deserialize method of the
prop corresponding to the value
"""
kwargs.update({'trusted': kwargs.get('trusted', False)})
if self.deserializer is not None:
... | python | def deserialize(self, value, **kwargs):
"""Return a deserialized value
If no deserializer is provided, it uses the deserialize method of the
prop corresponding to the value
"""
kwargs.update({'trusted': kwargs.get('trusted', False)})
if self.deserializer is not None:
... | Return a deserialized value
If no deserializer is provided, it uses the deserialize method of the
prop corresponding to the value | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/union.py#L221-L252 |
seequent/properties | properties/base/union.py | Union.to_json | def to_json(value, **kwargs):
"""Return value, serialized if value is a HasProperties instance"""
if isinstance(value, HasProperties):
return value.serialize(**kwargs)
return value | python | def to_json(value, **kwargs):
"""Return value, serialized if value is a HasProperties instance"""
if isinstance(value, HasProperties):
return value.serialize(**kwargs)
return value | Return value, serialized if value is a HasProperties instance | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/union.py#L258-L262 |
seequent/properties | properties/basic.py | accept_kwargs | def accept_kwargs(func):
"""Wrap a function that may not accept kwargs so they are accepted
The output function will always have call signature of
:code:`func(val, **kwargs)`, whereas the original function may have
call signatures of :code:`func(val)` or :code:`func(val, **kwargs)`.
In the case of ... | python | def accept_kwargs(func):
"""Wrap a function that may not accept kwargs so they are accepted
The output function will always have call signature of
:code:`func(val, **kwargs)`, whereas the original function may have
call signatures of :code:`func(val)` or :code:`func(val, **kwargs)`.
In the case of ... | Wrap a function that may not accept kwargs so they are accepted
The output function will always have call signature of
:code:`func(val, **kwargs)`, whereas the original function may have
call signatures of :code:`func(val)` or :code:`func(val, **kwargs)`.
In the case of the former, rather than erroring... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L34-L53 |
seequent/properties | properties/basic.py | _in_bounds | def _in_bounds(prop, instance, value):
"""Checks if the value is in the range (min, max)"""
if (
(prop.min is not None and value < prop.min) or
(prop.max is not None and value > prop.max)
):
prop.error(instance, value, extra='Not within allowed range.') | python | def _in_bounds(prop, instance, value):
"""Checks if the value is in the range (min, max)"""
if (
(prop.min is not None and value < prop.min) or
(prop.max is not None and value > prop.max)
):
prop.error(instance, value, extra='Not within allowed range.') | Checks if the value is in the range (min, max) | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L762-L768 |
seequent/properties | properties/basic.py | GettableProperty.terms | def terms(self):
"""Initialization terms and options for Property"""
terms = PropertyTerms(
self.name,
self.__class__,
self._args,
self._kwargs,
self.meta
)
return terms | python | def terms(self):
"""Initialization terms and options for Property"""
terms = PropertyTerms(
self.name,
self.__class__,
self._args,
self._kwargs,
self.meta
)
return terms | Initialization terms and options for Property | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L146-L155 |
seequent/properties | properties/basic.py | GettableProperty.tag | def tag(self, *tag, **kwtags):
"""Tag a Property instance with metadata dictionary"""
if not tag:
pass
elif len(tag) == 1 and isinstance(tag[0], dict):
self._meta.update(tag[0])
else:
raise TypeError('Tags must be provided as key-word arguments or '
... | python | def tag(self, *tag, **kwtags):
"""Tag a Property instance with metadata dictionary"""
if not tag:
pass
elif len(tag) == 1 and isinstance(tag[0], dict):
self._meta.update(tag[0])
else:
raise TypeError('Tags must be provided as key-word arguments or '
... | Tag a Property instance with metadata dictionary | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L209-L219 |
seequent/properties | properties/basic.py | GettableProperty.assert_valid | def assert_valid(self, instance, value=None):
"""Returns True if the Property is valid on a HasProperties instance
Raises a ValueError if the value is invalid.
"""
if value is None:
value = instance._get(self.name)
if (
value is not None and
... | python | def assert_valid(self, instance, value=None):
"""Returns True if the Property is valid on a HasProperties instance
Raises a ValueError if the value is invalid.
"""
if value is None:
value = instance._get(self.name)
if (
value is not None and
... | Returns True if the Property is valid on a HasProperties instance
Raises a ValueError if the value is invalid. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L247-L262 |
seequent/properties | properties/basic.py | GettableProperty.equal | def equal(self, value_a, value_b): #pylint: disable=no-self-use
"""Check if two valid Property values are equal
.. note::
This method assumes that :code:`None` and
:code:`properties.undefined` are never passed in as values
"""
... | python | def equal(self, value_a, value_b): #pylint: disable=no-self-use
"""Check if two valid Property values are equal
.. note::
This method assumes that :code:`None` and
:code:`properties.undefined` are never passed in as values
"""
... | Check if two valid Property values are equal
.. note::
This method assumes that :code:`None` and
:code:`properties.undefined` are never passed in as values | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L264-L275 |
seequent/properties | properties/basic.py | GettableProperty.get_property | def get_property(self):
"""Establishes access of GettableProperty values"""
scope = self
def fget(self):
"""Call the HasProperties _get method"""
return self._get(scope.name)
return property(fget=fget, doc=scope.sphinx()) | python | def get_property(self):
"""Establishes access of GettableProperty values"""
scope = self
def fget(self):
"""Call the HasProperties _get method"""
return self._get(scope.name)
return property(fget=fget, doc=scope.sphinx()) | Establishes access of GettableProperty values | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L277-L286 |
seequent/properties | properties/basic.py | GettableProperty.deserialize | def deserialize(self, value, **kwargs): #pylint: disable=unused-argument
"""Deserialize input value to valid Property value
This method uses the Property :code:`deserializer` if available.
Otherwise, it uses :code:`from_json`. Any keyword arguments are
... | python | def deserialize(self, value, **kwargs): #pylint: disable=unused-argument
"""Deserialize input value to valid Property value
This method uses the Property :code:`deserializer` if available.
Otherwise, it uses :code:`from_json`. Any keyword arguments are
... | Deserialize input value to valid Property value
This method uses the Property :code:`deserializer` if available.
Otherwise, it uses :code:`from_json`. Any keyword arguments are
passed through to these methods. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L302-L314 |
seequent/properties | properties/basic.py | GettableProperty.error | def error(self, instance, value, error_class=None, extra=''):
"""Generate a :code:`ValueError` for invalid value assignment
The instance is the containing HasProperties instance, but it may
be None if the error is raised outside a HasProperties class.
"""
error_class = error_cla... | python | def error(self, instance, value, error_class=None, extra=''):
"""Generate a :code:`ValueError` for invalid value assignment
The instance is the containing HasProperties instance, but it may
be None if the error is raised outside a HasProperties class.
"""
error_class = error_cla... | Generate a :code:`ValueError` for invalid value assignment
The instance is the containing HasProperties instance, but it may
be None if the error is raised outside a HasProperties class. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L326-L357 |
seequent/properties | properties/basic.py | GettableProperty.sphinx | def sphinx(self):
"""Generate Sphinx-formatted documentation for the Property"""
try:
assert __IPYTHON__
classdoc = ''
except (NameError, AssertionError):
scls = self.sphinx_class()
classdoc = ' ({})'.format(scls) if scls else ''
prop_doc ... | python | def sphinx(self):
"""Generate Sphinx-formatted documentation for the Property"""
try:
assert __IPYTHON__
classdoc = ''
except (NameError, AssertionError):
scls = self.sphinx_class()
classdoc = ' ({})'.format(scls) if scls else ''
prop_doc ... | Generate Sphinx-formatted documentation for the Property | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L359-L374 |
seequent/properties | properties/basic.py | GettableProperty.sphinx_class | def sphinx_class(self):
"""Property class name formatted for Sphinx doc linking"""
classdoc = ':class:`{cls} <{pref}.{cls}>`'
if self.__module__.split('.')[0] == 'properties':
pref = 'properties'
else:
pref = text_type(self.__module__)
return classdoc.form... | python | def sphinx_class(self):
"""Property class name formatted for Sphinx doc linking"""
classdoc = ':class:`{cls} <{pref}.{cls}>`'
if self.__module__.split('.')[0] == 'properties':
pref = 'properties'
else:
pref = text_type(self.__module__)
return classdoc.form... | Property class name formatted for Sphinx doc linking | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L376-L383 |
seequent/properties | properties/basic.py | DynamicProperty.setter | def setter(self, func):
"""Register a set function for the DynamicProperty
This function must take two arguments, self and the new value.
Input value to the function is validated with prop validation prior to
execution.
"""
if not callable(func):
raise TypeEr... | python | def setter(self, func):
"""Register a set function for the DynamicProperty
This function must take two arguments, self and the new value.
Input value to the function is validated with prop validation prior to
execution.
"""
if not callable(func):
raise TypeEr... | Register a set function for the DynamicProperty
This function must take two arguments, self and the new value.
Input value to the function is validated with prop validation prior to
execution. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L521-L535 |
seequent/properties | properties/basic.py | DynamicProperty.deleter | def deleter(self, func):
"""Register a delete function for the DynamicProperty
This function may only take one argument, self.
"""
if not callable(func):
raise TypeError('deleter must be callable function')
if hasattr(func, '__code__') and func.__code__.co_argcount !... | python | def deleter(self, func):
"""Register a delete function for the DynamicProperty
This function may only take one argument, self.
"""
if not callable(func):
raise TypeError('deleter must be callable function')
if hasattr(func, '__code__') and func.__code__.co_argcount !... | Register a delete function for the DynamicProperty
This function may only take one argument, self. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L542-L554 |
seequent/properties | properties/basic.py | DynamicProperty.get_property | def get_property(self):
"""Establishes the dynamic behavior of Property values"""
scope = self
def fget(self):
"""Call dynamic function then validate output"""
value = scope.func(self)
if value is None or value is undefined:
return None
... | python | def get_property(self):
"""Establishes the dynamic behavior of Property values"""
scope = self
def fget(self):
"""Call dynamic function then validate output"""
value = scope.func(self)
if value is None or value is undefined:
return None
... | Establishes the dynamic behavior of Property values | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L561-L584 |
seequent/properties | properties/basic.py | Property.assert_valid | def assert_valid(self, instance, value=None):
"""Returns True if the Property is valid on a HasProperties instance
Raises a ValueError if the value required and not set, not valid,
not correctly coerced, etc.
.. note::
Unlike :code:`validate`, this method requires instance... | python | def assert_valid(self, instance, value=None):
"""Returns True if the Property is valid on a HasProperties instance
Raises a ValueError if the value required and not set, not valid,
not correctly coerced, etc.
.. note::
Unlike :code:`validate`, this method requires instance... | Returns True if the Property is valid on a HasProperties instance
Raises a ValueError if the value required and not set, not valid,
not correctly coerced, etc.
.. note::
Unlike :code:`validate`, this method requires instance to be
a HasProperties instance; it cannot be... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L639-L662 |
seequent/properties | properties/basic.py | Property.get_property | def get_property(self):
"""Establishes access of Property values"""
scope = self
def fget(self):
"""Call the HasProperties _get method"""
return self._get(scope.name)
def fset(self, value):
"""Validate value and call the HasProperties _set method"""... | python | def get_property(self):
"""Establishes access of Property values"""
scope = self
def fget(self):
"""Call the HasProperties _get method"""
return self._get(scope.name)
def fset(self, value):
"""Validate value and call the HasProperties _set method"""... | Establishes access of Property values | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L664-L683 |
seequent/properties | properties/basic.py | Property.sphinx | def sphinx(self):
"""Basic docstring formatted for Sphinx docs"""
if callable(self.default):
default_val = self.default()
default_str = 'new instance of {}'.format(
default_val.__class__.__name__
)
else:
default_val = self.default
... | python | def sphinx(self):
"""Basic docstring formatted for Sphinx docs"""
if callable(self.default):
default_val = self.default()
default_str = 'new instance of {}'.format(
default_val.__class__.__name__
)
else:
default_val = self.default
... | Basic docstring formatted for Sphinx docs | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L685-L706 |
seequent/properties | properties/basic.py | Boolean.validate | def validate(self, instance, value):
"""Checks if value is a boolean"""
if self.cast:
value = bool(value)
if not isinstance(value, BOOLEAN_TYPES):
self.error(instance, value)
return value | python | def validate(self, instance, value):
"""Checks if value is a boolean"""
if self.cast:
value = bool(value)
if not isinstance(value, BOOLEAN_TYPES):
self.error(instance, value)
return value | Checks if value is a boolean | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L732-L738 |
seequent/properties | properties/basic.py | Boolean.from_json | def from_json(value, **kwargs):
"""Coerces JSON string to boolean"""
if isinstance(value, string_types):
value = value.upper()
if value in ('TRUE', 'Y', 'YES', 'ON'):
return True
if value in ('FALSE', 'N', 'NO', 'OFF'):
return False
... | python | def from_json(value, **kwargs):
"""Coerces JSON string to boolean"""
if isinstance(value, string_types):
value = value.upper()
if value in ('TRUE', 'Y', 'YES', 'ON'):
return True
if value in ('FALSE', 'N', 'NO', 'OFF'):
return False
... | Coerces JSON string to boolean | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L744-L754 |
seequent/properties | properties/basic.py | Integer.validate | def validate(self, instance, value):
"""Checks that value is an integer and in min/max bounds"""
try:
intval = int(value)
if not self.cast and abs(value - intval) > TOL:
self.error(
instance=instance,
value=value,
... | python | def validate(self, instance, value):
"""Checks that value is an integer and in min/max bounds"""
try:
intval = int(value)
if not self.cast and abs(value - intval) > TOL:
self.error(
instance=instance,
value=value,
... | Checks that value is an integer and in min/max bounds | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L809-L822 |
seequent/properties | properties/basic.py | Float.validate | def validate(self, instance, value):
"""Checks that value is a float and in min/max bounds
Non-float numbers are coerced to floats
"""
try:
floatval = float(value)
if not self.cast and abs(value - floatval) > TOL:
self.error(
i... | python | def validate(self, instance, value):
"""Checks that value is a float and in min/max bounds
Non-float numbers are coerced to floats
"""
try:
floatval = float(value)
if not self.cast and abs(value - floatval) > TOL:
self.error(
i... | Checks that value is a float and in min/max bounds
Non-float numbers are coerced to floats | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L860-L876 |
seequent/properties | properties/basic.py | Complex.validate | def validate(self, instance, value):
"""Checks that value is a complex number
Floats and Integers are coerced to complex numbers
"""
try:
compval = complex(value)
if not self.cast and (
abs(value.real - compval.real) > TOL or
... | python | def validate(self, instance, value):
"""Checks that value is a complex number
Floats and Integers are coerced to complex numbers
"""
try:
compval = complex(value)
if not self.cast and (
abs(value.real - compval.real) > TOL or
... | Checks that value is a complex number
Floats and Integers are coerced to complex numbers | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L907-L925 |
seequent/properties | properties/basic.py | String.validate | def validate(self, instance, value):
"""Check if value is a string, and strips it and changes case"""
value_type = type(value)
if not isinstance(value, string_types):
self.error(instance, value)
if self.regex is not None and self.regex.search(value) is None: #pylint: d... | python | def validate(self, instance, value):
"""Check if value is a string, and strips it and changes case"""
value_type = type(value)
if not isinstance(value, string_types):
self.error(instance, value)
if self.regex is not None and self.regex.search(value) is None: #pylint: d... | Check if value is a string, and strips it and changes case | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1021-L1037 |
seequent/properties | properties/basic.py | StringChoice.info | def info(self):
"""Formatted string to display the available choices"""
if self.descriptions is None:
choice_list = ['"{}"'.format(choice) for choice in self.choices]
else:
choice_list = [
'"{}" ({})'.format(choice, self.descriptions[choice])
... | python | def info(self):
"""Formatted string to display the available choices"""
if self.descriptions is None:
choice_list = ['"{}"'.format(choice) for choice in self.choices]
else:
choice_list = [
'"{}" ({})'.format(choice, self.descriptions[choice])
... | Formatted string to display the available choices | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1073-L1084 |
seequent/properties | properties/basic.py | StringChoice.validate | def validate(self, instance, value): #pylint: disable=inconsistent-return-statements
"""Check if input is a valid string based on the choices"""
if not isinstance(value, string_types):
self.error(instance, value)
for key, val in self.choices.item... | python | def validate(self, instance, value): #pylint: disable=inconsistent-return-statements
"""Check if input is a valid string based on the choices"""
if not isinstance(value, string_types):
self.error(instance, value)
for key, val in self.choices.item... | Check if input is a valid string based on the choices | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1158-L1168 |
seequent/properties | properties/basic.py | Color.validate | def validate(self, instance, value):
"""Check if input is valid color and converts to RGB"""
if isinstance(value, string_types):
value = COLORS_NAMED.get(value, value)
if value.upper() == 'RANDOM':
value = random.choice(COLORS_20)
value = value.upper()... | python | def validate(self, instance, value):
"""Check if input is valid color and converts to RGB"""
if isinstance(value, string_types):
value = COLORS_NAMED.get(value, value)
if value.upper() == 'RANDOM':
value = random.choice(COLORS_20)
value = value.upper()... | Check if input is valid color and converts to RGB | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1184-L1212 |
seequent/properties | properties/basic.py | DateTime.validate | def validate(self, instance, value):
"""Check if value is a valid datetime object or JSON datetime string"""
if isinstance(value, datetime.datetime):
return value
if not isinstance(value, string_types):
self.error(
instance=instance,
value=... | python | def validate(self, instance, value):
"""Check if value is a valid datetime object or JSON datetime string"""
if isinstance(value, datetime.datetime):
return value
if not isinstance(value, string_types):
self.error(
instance=instance,
value=... | Check if value is a valid datetime object or JSON datetime string | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1236-L1253 |
seequent/properties | properties/basic.py | Uuid.validate | def validate(self, instance, value):
"""Check that value is a valid UUID instance"""
if not isinstance(value, uuid.UUID):
self.error(instance, value)
return value | python | def validate(self, instance, value):
"""Check that value is a valid UUID instance"""
if not isinstance(value, uuid.UUID):
self.error(instance, value)
return value | Check that value is a valid UUID instance | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1283-L1287 |
seequent/properties | properties/basic.py | File.valid_modes | def valid_modes(self):
"""Valid modes of an open file"""
default_mode = (self.mode,) if self.mode is not None else None
return getattr(self, '_valid_mode', default_mode) | python | def valid_modes(self):
"""Valid modes of an open file"""
default_mode = (self.mode,) if self.mode is not None else None
return getattr(self, '_valid_mode', default_mode) | Valid modes of an open file | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1341-L1344 |
seequent/properties | properties/basic.py | File.get_property | def get_property(self):
"""Establishes access of Property values"""
prop = super(File, self).get_property()
# scope is the Property instance
scope = self
def fdel(self):
"""Set value to utils.undefined on delete"""
if self._get(scope.name) is not None:
... | python | def get_property(self):
"""Establishes access of Property values"""
prop = super(File, self).get_property()
# scope is the Property instance
scope = self
def fdel(self):
"""Set value to utils.undefined on delete"""
if self._get(scope.name) is not None:
... | Establishes access of Property values | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1358-L1374 |
seequent/properties | properties/basic.py | File.validate | def validate(self, instance, value):
"""Checks that the value is a valid file open in the correct mode
If value is a string, it attempts to open it with the given mode.
"""
if isinstance(value, string_types) and self.mode is not None:
try:
value = open(value,... | python | def validate(self, instance, value):
"""Checks that the value is a valid file open in the correct mode
If value is a string, it attempts to open it with the given mode.
"""
if isinstance(value, string_types) and self.mode is not None:
try:
value = open(value,... | Checks that the value is a valid file open in the correct mode
If value is a string, it attempts to open it with the given mode. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1376-L1396 |
seequent/properties | properties/basic.py | Renamed.display_warning | def display_warning(self):
"""Display a FutureWarning about using a Renamed Property"""
if self.warn:
warnings.warn(
"\nProperty '{}' is deprecated and may be removed in the "
"future. Please use '{}'.".format(self.name, self.new_name),
FutureW... | python | def display_warning(self):
"""Display a FutureWarning about using a Renamed Property"""
if self.warn:
warnings.warn(
"\nProperty '{}' is deprecated and may be removed in the "
"future. Please use '{}'.".format(self.name, self.new_name),
FutureW... | Display a FutureWarning about using a Renamed Property | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1475-L1482 |
seequent/properties | properties/basic.py | Renamed.get_property | def get_property(self):
"""Establishes the dynamic behavior of Property values"""
scope = self
def fget(self):
"""Call dynamic function then validate output"""
scope.display_warning()
return getattr(self, scope.new_name)
def fset(self, value):
... | python | def get_property(self):
"""Establishes the dynamic behavior of Property values"""
scope = self
def fget(self):
"""Call dynamic function then validate output"""
scope.display_warning()
return getattr(self, scope.new_name)
def fset(self, value):
... | Establishes the dynamic behavior of Property values | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L1484-L1503 |
seequent/properties | properties/base/instance.py | Instance.validate | def validate(self, instance, value):
"""Check if value is valid type of instance_class
If value is an instance of instance_class, it is returned unmodified.
If value is either (1) a keyword dictionary with valid parameters
to construct an instance of instance_class or (2) a valid input
... | python | def validate(self, instance, value):
"""Check if value is valid type of instance_class
If value is an instance of instance_class, it is returned unmodified.
If value is either (1) a keyword dictionary with valid parameters
to construct an instance of instance_class or (2) a valid input
... | Check if value is valid type of instance_class
If value is an instance of instance_class, it is returned unmodified.
If value is either (1) a keyword dictionary with valid parameters
to construct an instance of instance_class or (2) a valid input
argument to construct instance_class, th... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/instance.py#L89-L111 |
seequent/properties | properties/base/instance.py | Instance.assert_valid | def assert_valid(self, instance, value=None):
"""Checks if valid, including HasProperty instances pass validation"""
valid = super(Instance, self).assert_valid(instance, value)
if not valid:
return False
if value is None:
value = instance._get(self.name)
i... | python | def assert_valid(self, instance, value=None):
"""Checks if valid, including HasProperty instances pass validation"""
valid = super(Instance, self).assert_valid(instance, value)
if not valid:
return False
if value is None:
value = instance._get(self.name)
i... | Checks if valid, including HasProperty instances pass validation | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/instance.py#L113-L122 |
seequent/properties | properties/base/instance.py | Instance.serialize | def serialize(self, value, **kwargs):
"""Serialize instance to JSON
If the value is a HasProperties instance, it is serialized with
the include_class argument passed along. Otherwise, to_json is
called.
"""
kwargs.update({'include_class': kwargs.get('include_class', True... | python | def serialize(self, value, **kwargs):
"""Serialize instance to JSON
If the value is a HasProperties instance, it is serialized with
the include_class argument passed along. Otherwise, to_json is
called.
"""
kwargs.update({'include_class': kwargs.get('include_class', True... | Serialize instance to JSON
If the value is a HasProperties instance, it is serialized with
the include_class argument passed along. Otherwise, to_json is
called. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/instance.py#L125-L139 |
seequent/properties | properties/base/instance.py | Instance.to_json | def to_json(value, **kwargs):
"""Convert instance to JSON"""
if isinstance(value, HasProperties):
return value.serialize(**kwargs)
try:
return json.loads(json.dumps(value))
except TypeError:
raise TypeError(
"Cannot convert type {} to J... | python | def to_json(value, **kwargs):
"""Convert instance to JSON"""
if isinstance(value, HasProperties):
return value.serialize(**kwargs)
try:
return json.loads(json.dumps(value))
except TypeError:
raise TypeError(
"Cannot convert type {} to J... | Convert instance to JSON | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/instance.py#L161-L172 |
seequent/properties | properties/base/instance.py | Instance.sphinx_class | def sphinx_class(self):
"""Redefine sphinx class so documentation links to instance_class"""
classdoc = ':class:`{cls} <{pref}.{cls}>`'.format(
cls=self.instance_class.__name__,
pref=self.instance_class.__module__,
)
return classdoc | python | def sphinx_class(self):
"""Redefine sphinx class so documentation links to instance_class"""
classdoc = ':class:`{cls} <{pref}.{cls}>`'.format(
cls=self.instance_class.__name__,
pref=self.instance_class.__module__,
)
return classdoc | Redefine sphinx class so documentation links to instance_class | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/instance.py#L183-L189 |
seequent/properties | properties/link.py | properties_observer | def properties_observer(instance, prop, callback, **kwargs):
"""Adds properties callback handler"""
change_only = kwargs.get('change_only', True)
observer(instance, prop, callback, change_only=change_only) | python | def properties_observer(instance, prop, callback, **kwargs):
"""Adds properties callback handler"""
change_only = kwargs.get('change_only', True)
observer(instance, prop, callback, change_only=change_only) | Adds properties callback handler | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/link.py#L13-L16 |
seequent/properties | properties/link.py | directional_link._update | def _update(self, *_):
"""Set target value to source value"""
if getattr(self, '_unlinked', False):
return
if getattr(self, '_updating', False):
return
self._updating = True
try:
setattr(self.target[0], self.target[1], self.transform(
... | python | def _update(self, *_):
"""Set target value to source value"""
if getattr(self, '_unlinked', False):
return
if getattr(self, '_updating', False):
return
self._updating = True
try:
setattr(self.target[0], self.target[1], self.transform(
... | Set target value to source value | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/link.py#L110-L122 |
seequent/properties | properties/link.py | directional_link._validate | def _validate(item):
"""Validate (instance, prop name) tuple"""
if not isinstance(item, tuple) or len(item) != 2:
raise ValueError('Linked items must be instance/prop-name tuple')
if not isinstance(item[0], tuple(LINK_OBSERVERS)):
raise ValueError('Only {} instances may b... | python | def _validate(item):
"""Validate (instance, prop name) tuple"""
if not isinstance(item, tuple) or len(item) != 2:
raise ValueError('Linked items must be instance/prop-name tuple')
if not isinstance(item[0], tuple(LINK_OBSERVERS)):
raise ValueError('Only {} instances may b... | Validate (instance, prop name) tuple | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/link.py#L125-L138 |
seequent/properties | properties/math.py | Array.validate | def validate(self, instance, value):
"""Determine if array is valid based on shape and dtype"""
if not isinstance(value, (tuple, list, np.ndarray)):
self.error(instance, value)
if self.coerce:
value = self.wrapper(value)
valid_class = (
self.wrapper if... | python | def validate(self, instance, value):
"""Determine if array is valid based on shape and dtype"""
if not isinstance(value, (tuple, list, np.ndarray)):
self.error(instance, value)
if self.coerce:
value = self.wrapper(value)
valid_class = (
self.wrapper if... | Determine if array is valid based on shape and dtype | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L140-L164 |
seequent/properties | properties/math.py | Array.error | def error(self, instance, value, error_class=None, extra=''):
"""Generates a ValueError on setting property to an invalid value"""
error_class = error_class or ValidationError
if not isinstance(value, (list, tuple, np.ndarray)):
super(Array, self).error(instance, value, error_class, ... | python | def error(self, instance, value, error_class=None, extra=''):
"""Generates a ValueError on setting property to an invalid value"""
error_class = error_class or ValidationError
if not isinstance(value, (list, tuple, np.ndarray)):
super(Array, self).error(instance, value, error_class, ... | Generates a ValueError on setting property to an invalid value | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L178-L211 |
seequent/properties | properties/math.py | Array.deserialize | def deserialize(self, value, **kwargs):
"""De-serialize the property value from JSON
If no deserializer has been registered, this converts the value
to the wrapper class with given dtype.
"""
kwargs.update({'trusted': kwargs.get('trusted', False)})
if self.deserializer i... | python | def deserialize(self, value, **kwargs):
"""De-serialize the property value from JSON
If no deserializer has been registered, this converts the value
to the wrapper class with given dtype.
"""
kwargs.update({'trusted': kwargs.get('trusted', False)})
if self.deserializer i... | De-serialize the property value from JSON
If no deserializer has been registered, this converts the value
to the wrapper class with given dtype. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L213-L224 |
seequent/properties | properties/math.py | Array.to_json | def to_json(value, **kwargs):
"""Convert array to JSON list
nan values are converted to string 'nan', inf values to 'inf'.
"""
def _recurse_list(val):
if val and isinstance(val[0], list):
return [_recurse_list(v) for v in val]
return [str(v) if np... | python | def to_json(value, **kwargs):
"""Convert array to JSON list
nan values are converted to string 'nan', inf values to 'inf'.
"""
def _recurse_list(val):
if val and isinstance(val[0], list):
return [_recurse_list(v) for v in val]
return [str(v) if np... | Convert array to JSON list
nan values are converted to string 'nan', inf values to 'inf'. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L227-L236 |
seequent/properties | properties/math.py | BaseVector.validate | def validate(self, instance, value):
"""Check shape and dtype of vector and scales it to given length"""
value = super(BaseVector, self).validate(instance, value)
if self.length is not None:
try:
value.length = self._length_array(value)
except ZeroDivisi... | python | def validate(self, instance, value):
"""Check shape and dtype of vector and scales it to given length"""
value = super(BaseVector, self).validate(instance, value)
if self.length is not None:
try:
value.length = self._length_array(value)
except ZeroDivisi... | Check shape and dtype of vector and scales it to given length | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L278-L292 |
seequent/properties | properties/math.py | Vector2.validate | def validate(self, instance, value):
"""Check shape and dtype of vector
validate also coerces the vector from valid strings (these
include ZERO, X, Y, -X, -Y, EAST, WEST, NORTH, and SOUTH) and
scales it to the given length.
"""
if isinstance(value, string_types):
... | python | def validate(self, instance, value):
"""Check shape and dtype of vector
validate also coerces the vector from valid strings (these
include ZERO, X, Y, -X, -Y, EAST, WEST, NORTH, and SOUTH) and
scales it to the given length.
"""
if isinstance(value, string_types):
... | Check shape and dtype of vector
validate also coerces the vector from valid strings (these
include ZERO, X, Y, -X, -Y, EAST, WEST, NORTH, and SOUTH) and
scales it to the given length. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L373-L388 |
seequent/properties | properties/math.py | Vector3Array.validate | def validate(self, instance, value):
"""Check shape and dtype of vector
validate also coerces the vector from valid strings (these
include ZERO, X, Y, Z, -X, -Y, -Z, EAST, WEST, NORTH, SOUTH, UP,
and DOWN) and scales it to the given length.
"""
if not isinstance(value, (... | python | def validate(self, instance, value):
"""Check shape and dtype of vector
validate also coerces the vector from valid strings (these
include ZERO, X, Y, Z, -X, -Y, -Z, EAST, WEST, NORTH, SOUTH, UP,
and DOWN) and scales it to the given length.
"""
if not isinstance(value, (... | Check shape and dtype of vector
validate also coerces the vector from valid strings (these
include ZERO, X, Y, Z, -X, -Y, -Z, EAST, WEST, NORTH, SOUTH, UP,
and DOWN) and scales it to the given length. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L438-L458 |
raphaelm/django-i18nfield | i18nfield/strings.py | LazyI18nString.localize | def localize(self, lng: str) -> str:
"""
Evaluate the given string with respect to the locale defined by ``lng``.
If no string is available in the currently active language, this will give you
the string in the system's default language. If this is unavailable as well, it
will g... | python | def localize(self, lng: str) -> str:
"""
Evaluate the given string with respect to the locale defined by ``lng``.
If no string is available in the currently active language, this will give you
the string in the system's default language. If this is unavailable as well, it
will g... | Evaluate the given string with respect to the locale defined by ``lng``.
If no string is available in the currently active language, this will give you
the string in the system's default language. If this is unavailable as well, it
will give you the string in the first language available.
... | https://github.com/raphaelm/django-i18nfield/blob/fb707931e4498ab1b609eaa0323bb5c3d5f7c7e7/i18nfield/strings.py#L48-L81 |
seequent/properties | properties/handlers.py | _set_listener | def _set_listener(instance, obs):
"""Add listeners to a HasProperties instance"""
if obs.names is everything:
names = list(instance._props)
else:
names = obs.names
for name in names:
if name not in instance._listeners:
instance._listeners[name] = {typ: [] for typ in L... | python | def _set_listener(instance, obs):
"""Add listeners to a HasProperties instance"""
if obs.names is everything:
names = list(instance._props)
else:
names = obs.names
for name in names:
if name not in instance._listeners:
instance._listeners[name] = {typ: [] for typ in L... | Add listeners to a HasProperties instance | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/handlers.py#L89-L98 |
seequent/properties | properties/handlers.py | _get_listeners | def _get_listeners(instance, change):
"""Gets listeners of changed Property on a HasProperties instance"""
if (
change['mode'] not in listeners_disabled._quarantine and #pylint: disable=protected-access
change['name'] in instance._listeners
):
return instance._liste... | python | def _get_listeners(instance, change):
"""Gets listeners of changed Property on a HasProperties instance"""
if (
change['mode'] not in listeners_disabled._quarantine and #pylint: disable=protected-access
change['name'] in instance._listeners
):
return instance._liste... | Gets listeners of changed Property on a HasProperties instance | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/handlers.py#L101-L108 |
seequent/properties | properties/handlers.py | observer | def observer(names_or_instance, names=None, func=None, change_only=False):
"""Specify a callback function that will fire on Property value change
Observer functions on a HasProperties class fire after the observed
Property or Properties have been changed (unlike validator functions
that fire on set bef... | python | def observer(names_or_instance, names=None, func=None, change_only=False):
"""Specify a callback function that will fire on Property value change
Observer functions on a HasProperties class fire after the observed
Property or Properties have been changed (unlike validator functions
that fire on set bef... | Specify a callback function that will fire on Property value change
Observer functions on a HasProperties class fire after the observed
Property or Properties have been changed (unlike validator functions
that fire on set before the value is changed).
You can use this method as a decorator inside a Ha... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/handlers.py#L176-L230 |
seequent/properties | properties/handlers.py | validator | def validator(names_or_instance, names=None, func=None):
"""Specify a callback function to fire on class validation OR property set
This function has two modes of operation:
1. Registering callback functions that validate Property values when
they are set, before the change is saved to the HasPrope... | python | def validator(names_or_instance, names=None, func=None):
"""Specify a callback function to fire on class validation OR property set
This function has two modes of operation:
1. Registering callback functions that validate Property values when
they are set, before the change is saved to the HasPrope... | Specify a callback function to fire on class validation OR property set
This function has two modes of operation:
1. Registering callback functions that validate Property values when
they are set, before the change is saved to the HasProperties instance.
This mode is very similar to the :code:`o... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/handlers.py#L233-L308 |
seequent/properties | properties/base/base.py | build_from_bases | def build_from_bases(bases, classdict, attr, attr_dict):
"""Helper function to build private HasProperties attributes"""
output = OrderedDict()
output_keys = set()
all_bases = []
# Go through the bases from furthest to nearest ancestor
for base in reversed(bases):
# Only keep the items t... | python | def build_from_bases(bases, classdict, attr, attr_dict):
"""Helper function to build private HasProperties attributes"""
output = OrderedDict()
output_keys = set()
all_bases = []
# Go through the bases from furthest to nearest ancestor
for base in reversed(bases):
# Only keep the items t... | Helper function to build private HasProperties attributes | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L25-L55 |
seequent/properties | properties/base/base.py | equal | def equal(value_a, value_b):
"""Determine if two **HasProperties** instances are equivalent
Equivalence is determined by checking if (1) the two instances are
the same class and (2) all Property values on two instances are
equal, using :code:`Property.equal`. If the two values are the same
HasPrope... | python | def equal(value_a, value_b):
"""Determine if two **HasProperties** instances are equivalent
Equivalence is determined by checking if (1) the two instances are
the same class and (2) all Property values on two instances are
equal, using :code:`Property.equal`. If the two values are the same
HasPrope... | Determine if two **HasProperties** instances are equivalent
Equivalence is determined by checking if (1) the two instances are
the same class and (2) all Property values on two instances are
equal, using :code:`Property.equal`. If the two values are the same
HasProperties instance (eg. :code:`value_a i... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L617-L660 |
seequent/properties | properties/base/base.py | copy | def copy(value, **kwargs):
"""Return a copy of a **HasProperties** instance
A copy is produced by serializing the HasProperties instance then
deserializing it to a new instance. Therefore, if any properties
cannot be serialized/deserialized, :code:`copy` will fail. Any
keyword arguments will be pas... | python | def copy(value, **kwargs):
"""Return a copy of a **HasProperties** instance
A copy is produced by serializing the HasProperties instance then
deserializing it to a new instance. Therefore, if any properties
cannot be serialized/deserialized, :code:`copy` will fail. Any
keyword arguments will be pas... | Return a copy of a **HasProperties** instance
A copy is produced by serializing the HasProperties instance then
deserializing it to a new instance. Therefore, if any properties
cannot be serialized/deserialized, :code:`copy` will fail. Any
keyword arguments will be passed through to both :code:`seriali... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L663-L678 |
seequent/properties | properties/base/base.py | HasProperties._reset | def _reset(self, name=None):
"""Revert specified property to default value
If no property is specified, all properties are returned to default.
"""
if name is None:
for key in self._props:
if isinstance(self._props[key], basic.Property):
s... | python | def _reset(self, name=None):
"""Revert specified property to default value
If no property is specified, all properties are returned to default.
"""
if name is None:
for key in self._props:
if isinstance(self._props[key], basic.Property):
s... | Revert specified property to default value
If no property is specified, all properties are returned to default. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L377-L399 |
seequent/properties | properties/base/base.py | HasProperties.validate | def validate(self):
"""Call all registered class validator methods
These are all methods decorated with :code:`@properties.validator`.
Validator methods are expected to raise a ValidationError if they
fail.
"""
if getattr(self, '_getting_validated', False):
r... | python | def validate(self):
"""Call all registered class validator methods
These are all methods decorated with :code:`@properties.validator`.
Validator methods are expected to raise a ValidationError if they
fail.
"""
if getattr(self, '_getting_validated', False):
r... | Call all registered class validator methods
These are all methods decorated with :code:`@properties.validator`.
Validator methods are expected to raise a ValidationError if they
fail. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L401-L443 |
seequent/properties | properties/base/base.py | HasProperties._validate_props | def _validate_props(self):
"""Assert that all the properties are valid on validate()"""
for key, prop in iteritems(self._props):
try:
value = self._get(key)
err_msg = 'Invalid value for property {}: {}'.format(key, value)
if value is not None:
... | python | def _validate_props(self):
"""Assert that all the properties are valid on validate()"""
for key, prop in iteritems(self._props):
try:
value = self._get(key)
err_msg = 'Invalid value for property {}: {}'.format(key, value)
if value is not None:
... | Assert that all the properties are valid on validate() | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L446-L467 |
seequent/properties | properties/base/base.py | HasProperties.serialize | def serialize(self, include_class=True, save_dynamic=False, **kwargs):
"""Serializes a **HasProperties** instance to dictionary
This uses the Property serializers to serialize all Property values
to a JSON-compatible dictionary. Properties that are undefined are
not included. If the **H... | python | def serialize(self, include_class=True, save_dynamic=False, **kwargs):
"""Serializes a **HasProperties** instance to dictionary
This uses the Property serializers to serialize all Property values
to a JSON-compatible dictionary. Properties that are undefined are
not included. If the **H... | Serializes a **HasProperties** instance to dictionary
This uses the Property serializers to serialize all Property values
to a JSON-compatible dictionary. Properties that are undefined are
not included. If the **HasProperties** instance contains a reference
to itself, a :code:`propertie... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L476-L516 |
seequent/properties | properties/base/base.py | HasProperties.deserialize | def deserialize(cls, value, trusted=False, strict=False, #pylint: disable=too-many-locals
assert_valid=False, **kwargs):
"""Creates **HasProperties** instance from serialized dictionary
This uses the Property deserializers to deserialize all
JSON-compatible... | python | def deserialize(cls, value, trusted=False, strict=False, #pylint: disable=too-many-locals
assert_valid=False, **kwargs):
"""Creates **HasProperties** instance from serialized dictionary
This uses the Property deserializers to deserialize all
JSON-compatible... | Creates **HasProperties** instance from serialized dictionary
This uses the Property deserializers to deserialize all
JSON-compatible dictionary values into their corresponding Property
values on a new instance of a **HasProperties** class. Extra keys
in the dictionary that do not corre... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L519-L589 |
seequent/properties | properties/base/base.py | HasProperties._deserialize_class | def _deserialize_class(cls, input_cls_name, trusted, strict):
"""Returns the HasProperties class to use for deserialization"""
if not input_cls_name or input_cls_name == cls.__name__:
return cls
if trusted and input_cls_name in cls._REGISTRY:
return cls._REGISTRY[input_cl... | python | def _deserialize_class(cls, input_cls_name, trusted, strict):
"""Returns the HasProperties class to use for deserialization"""
if not input_cls_name or input_cls_name == cls.__name__:
return cls
if trusted and input_cls_name in cls._REGISTRY:
return cls._REGISTRY[input_cl... | Returns the HasProperties class to use for deserialization | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/base/base.py#L592-L603 |
seequent/properties | properties/extras/task.py | BaseTask.report_status | def report_status(self, status):
"""Hook for reporting the task status towards completion"""
status = Instance('', TaskStatus).validate(None, status)
print(r'{taskname} | {percent:>3}% | {message}'.format(
taskname=self.__class__.__name__,
percent=int(round(100*status.pro... | python | def report_status(self, status):
"""Hook for reporting the task status towards completion"""
status = Instance('', TaskStatus).validate(None, status)
print(r'{taskname} | {percent:>3}% | {message}'.format(
taskname=self.__class__.__name__,
percent=int(round(100*status.pro... | Hook for reporting the task status towards completion | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/extras/task.py#L81-L88 |
seequent/properties | properties/extras/uid.py | HasUID.serialize | def serialize(self, include_class=True, save_dynamic=False, **kwargs):
"""Serialize nested HasUID instances to a flat dictionary
**Parameters**:
* **include_class** - If True (the default), the name of the class
will also be saved to the serialized dictionary under key
:cod... | python | def serialize(self, include_class=True, save_dynamic=False, **kwargs):
"""Serialize nested HasUID instances to a flat dictionary
**Parameters**:
* **include_class** - If True (the default), the name of the class
will also be saved to the serialized dictionary under key
:cod... | Serialize nested HasUID instances to a flat dictionary
**Parameters**:
* **include_class** - If True (the default), the name of the class
will also be saved to the serialized dictionary under key
:code:`'__class__'`
* **save_dynamic** - If True, dynamic properties are writt... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/extras/uid.py#L69-L104 |
seequent/properties | properties/extras/uid.py | HasUID.deserialize | def deserialize(cls, value, trusted=False, strict=False,
assert_valid=False, **kwargs):
"""Deserialize nested HasUID instance from flat pointer dictionary
**Parameters**
* **value** - Flat pointer dictionary produced by :code:`serialize`
with UID/HasUID key/value ... | python | def deserialize(cls, value, trusted=False, strict=False,
assert_valid=False, **kwargs):
"""Deserialize nested HasUID instance from flat pointer dictionary
**Parameters**
* **value** - Flat pointer dictionary produced by :code:`serialize`
with UID/HasUID key/value ... | Deserialize nested HasUID instance from flat pointer dictionary
**Parameters**
* **value** - Flat pointer dictionary produced by :code:`serialize`
with UID/HasUID key/value pairs. It also includes a
:code:`__root__` key to specify the root HasUID instance.
* **trusted** - I... | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/extras/uid.py#L107-L172 |
seequent/properties | properties/extras/uid.py | Pointer.deserialize | def deserialize(self, value, **kwargs):
"""Deserialize instance from JSON value
If a deserializer is registered, that is used. Otherwise, if the
instance_class is a HasProperties subclass, an instance can be
deserialized from a dictionary.
"""
kwargs.update({'trusted': k... | python | def deserialize(self, value, **kwargs):
"""Deserialize instance from JSON value
If a deserializer is registered, that is used. Otherwise, if the
instance_class is a HasProperties subclass, an instance can be
deserialized from a dictionary.
"""
kwargs.update({'trusted': k... | Deserialize instance from JSON value
If a deserializer is registered, that is used. Otherwise, if the
instance_class is a HasProperties subclass, an instance can be
deserialized from a dictionary. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/extras/uid.py#L255-L271 |
seequent/properties | properties/images.py | ImagePNG.validate | def validate(self, instance, value):
"""Checks if value is an open PNG file, valid filename, or png.Image
Returns an open bytestream of the image
"""
# Pass if already validated
if getattr(value, '__valid__', False):
return value
# Validate that value is PNG
... | python | def validate(self, instance, value):
"""Checks if value is an open PNG file, valid filename, or png.Image
Returns an open bytestream of the image
"""
# Pass if already validated
if getattr(value, '__valid__', False):
return value
# Validate that value is PNG
... | Checks if value is an open PNG file, valid filename, or png.Image
Returns an open bytestream of the image | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/images.py#L53-L83 |
seequent/properties | properties/images.py | ImagePNG.to_json | def to_json(value, **kwargs):
"""Convert a PNG Image to base64-encoded JSON
to_json assumes that value has passed validation.
"""
b64rep = base64.b64encode(value.read())
value.seek(0)
jsonrep = '{preamble}{b64}'.format(
preamble=PNG_PREAMBLE,
b64=... | python | def to_json(value, **kwargs):
"""Convert a PNG Image to base64-encoded JSON
to_json assumes that value has passed validation.
"""
b64rep = base64.b64encode(value.read())
value.seek(0)
jsonrep = '{preamble}{b64}'.format(
preamble=PNG_PREAMBLE,
b64=... | Convert a PNG Image to base64-encoded JSON
to_json assumes that value has passed validation. | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/images.py#L86-L97 |
seequent/properties | properties/images.py | ImagePNG.from_json | def from_json(value, **kwargs):
"""Convert a PNG Image from base64-encoded JSON"""
if not value.startswith(PNG_PREAMBLE):
raise ValueError('Not a valid base64-encoded PNG image')
infile = BytesIO()
rep = base64.b64decode(value[len(PNG_PREAMBLE):].encode('utf-8'))
infi... | python | def from_json(value, **kwargs):
"""Convert a PNG Image from base64-encoded JSON"""
if not value.startswith(PNG_PREAMBLE):
raise ValueError('Not a valid base64-encoded PNG image')
infile = BytesIO()
rep = base64.b64decode(value[len(PNG_PREAMBLE):].encode('utf-8'))
infi... | Convert a PNG Image from base64-encoded JSON | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/images.py#L100-L108 |
eventbrite/conformity | conformity/validator.py | validate | def validate(schema, value, noun='value'):
"""
Checks the value against the schema, and raises ValidationError if validation
fails.
"""
errors = schema.errors(value)
if errors:
error_details = ''
for error in errors:
if error.pointer:
error_details += ... | python | def validate(schema, value, noun='value'):
"""
Checks the value against the schema, and raises ValidationError if validation
fails.
"""
errors = schema.errors(value)
if errors:
error_details = ''
for error in errors:
if error.pointer:
error_details += ... | Checks the value against the schema, and raises ValidationError if validation
fails. | https://github.com/eventbrite/conformity/blob/12014fe4e14f66869ffda9f9ca09cd20a985c769/conformity/validator.py#L36-L49 |
eventbrite/conformity | conformity/validator.py | validate_call | def validate_call(kwargs, returns, is_method=False):
"""
Decorator which runs validation on a callable's arguments and its return
value. Pass a schema for the kwargs and for the return value. Positional
arguments are not supported.
"""
def decorator(func):
@wraps(func)
def inner(... | python | def validate_call(kwargs, returns, is_method=False):
"""
Decorator which runs validation on a callable's arguments and its return
value. Pass a schema for the kwargs and for the return value. Positional
arguments are not supported.
"""
def decorator(func):
@wraps(func)
def inner(... | Decorator which runs validation on a callable's arguments and its return
value. Pass a schema for the kwargs and for the return value. Positional
arguments are not supported. | https://github.com/eventbrite/conformity/blob/12014fe4e14f66869ffda9f9ca09cd20a985c769/conformity/validator.py#L52-L83 |
eventbrite/conformity | conformity/fields/structures.py | _update_error_pointer | def _update_error_pointer(error, pointer_or_prefix):
"""
Helper function to update an Error's pointer attribute with a (potentially
prefixed) dictionary key or list index.
"""
if error.pointer:
error.pointer = '{}.{}'.format(pointer_or_prefix, error.pointer)
else:
error.pointer =... | python | def _update_error_pointer(error, pointer_or_prefix):
"""
Helper function to update an Error's pointer attribute with a (potentially
prefixed) dictionary key or list index.
"""
if error.pointer:
error.pointer = '{}.{}'.format(pointer_or_prefix, error.pointer)
else:
error.pointer =... | Helper function to update an Error's pointer attribute with a (potentially
prefixed) dictionary key or list index. | https://github.com/eventbrite/conformity/blob/12014fe4e14f66869ffda9f9ca09cd20a985c769/conformity/fields/structures.py#L24-L33 |
eventbrite/conformity | conformity/fields/structures.py | Dictionary.extend | def extend(
self,
contents=None,
optional_keys=None,
allow_extra_keys=None,
description=None,
replace_optional_keys=False,
):
"""
This method allows you to create a new `Dictionary` that extends the current `Dictionary` with additional
contents... | python | def extend(
self,
contents=None,
optional_keys=None,
allow_extra_keys=None,
description=None,
replace_optional_keys=False,
):
"""
This method allows you to create a new `Dictionary` that extends the current `Dictionary` with additional
contents... | This method allows you to create a new `Dictionary` that extends the current `Dictionary` with additional
contents and/or optional keys, and/or replaces the `allow_extra_keys` and/or `description` attributes.
:param contents: More contents, if any, to extend the current contents
:type contents:... | https://github.com/eventbrite/conformity/blob/12014fe4e14f66869ffda9f9ca09cd20a985c769/conformity/fields/structures.py#L170-L205 |
eventbrite/conformity | conformity/fields/basic.py | Constant.errors | def errors(self, value):
"""
Returns a list of errors with the value. An empty/None return means
that it's valid.
"""
if value not in self.values:
return [Error(self._error_message, code=ERROR_CODE_UNKNOWN)]
return [] | python | def errors(self, value):
"""
Returns a list of errors with the value. An empty/None return means
that it's valid.
"""
if value not in self.values:
return [Error(self._error_message, code=ERROR_CODE_UNKNOWN)]
return [] | Returns a list of errors with the value. An empty/None return means
that it's valid. | https://github.com/eventbrite/conformity/blob/12014fe4e14f66869ffda9f9ca09cd20a985c769/conformity/fields/basic.py#L62-L69 |
BBVA/patton-cli | patton_client/model.py | PattonResults.dump | def dump(self):
"""Dump to file"""
# NO Dump file selected -> DO NOTHING
if self.running_config.output_file:
# Determinate file format
_, extension = op.splitext(self.running_config.output_file)
extension = extension.replace(".", "")
if extensio... | python | def dump(self):
"""Dump to file"""
# NO Dump file selected -> DO NOTHING
if self.running_config.output_file:
# Determinate file format
_, extension = op.splitext(self.running_config.output_file)
extension = extension.replace(".", "")
if extensio... | Dump to file | https://github.com/BBVA/patton-cli/blob/b31d9a134158d4c15eeeefde305f193d3f01a2de/patton_client/model.py#L173-L206 |
BBVA/patton-cli | patton_client/helpers.py | get_data_from_sources | def get_data_from_sources(patton_config: PattonRunningConfig,
dependency_or_banner: str = "dependency") \
-> List[str]:
"""This function try to get data from different sources:
- command line arguments
- from external input file
- from stdin
Return a list with the... | python | def get_data_from_sources(patton_config: PattonRunningConfig,
dependency_or_banner: str = "dependency") \
-> List[str]:
"""This function try to get data from different sources:
- command line arguments
- from external input file
- from stdin
Return a list with the... | This function try to get data from different sources:
- command line arguments
- from external input file
- from stdin
Return a list with the content of all of collected data. A list element by
each input data found.
:param dependency_or_banner: allowed values are: ["dependency" | "banner"]
... | https://github.com/BBVA/patton-cli/blob/b31d9a134158d4c15eeeefde305f193d3f01a2de/patton_client/helpers.py#L38-L108 |
BBVA/patton-cli | patton_client/banners_services/__init__.py | parse_banners | def parse_banners(banners: List[List[str]],
patton_config: PattonRunningConfig) -> Set:
"""This function try to find the better function to parser input banners
and parse it"""
result = set()
for source_type, source_content in banners:
if source_type == "file":
re... | python | def parse_banners(banners: List[List[str]],
patton_config: PattonRunningConfig) -> Set:
"""This function try to find the better function to parser input banners
and parse it"""
result = set()
for source_type, source_content in banners:
if source_type == "file":
re... | This function try to find the better function to parser input banners
and parse it | https://github.com/BBVA/patton-cli/blob/b31d9a134158d4c15eeeefde305f193d3f01a2de/patton_client/banners_services/__init__.py#L14-L25 |
BBVA/patton-cli | patton_client/libraries_parsers/__init__.py | parse_dependencies | def parse_dependencies(dependencies: List[List[str]],
patton_config: PattonRunningConfig) -> Dict:
"""This function try to find the better function to parser input banners
and parse it"""
result = {}
for source_type, source_content in dependencies:
# Select parser
... | python | def parse_dependencies(dependencies: List[List[str]],
patton_config: PattonRunningConfig) -> Dict:
"""This function try to find the better function to parser input banners
and parse it"""
result = {}
for source_type, source_content in dependencies:
# Select parser
... | This function try to find the better function to parser input banners
and parse it | https://github.com/BBVA/patton-cli/blob/b31d9a134158d4c15eeeefde305f193d3f01a2de/patton_client/libraries_parsers/__init__.py#L22-L44 |
edx/django-user-tasks | docs/conf.py | on_init | def on_init(app): # pylint: disable=unused-argument
"""
Run sphinx-apidoc and swg2rst after Sphinx initialization.
Read the Docs won't run tox or custom shell commands, so we need this to
avoid checking in the generated reStructuredText files.
"""
docs_path = os.path.abspath(os.path.dirname(__... | python | def on_init(app): # pylint: disable=unused-argument
"""
Run sphinx-apidoc and swg2rst after Sphinx initialization.
Read the Docs won't run tox or custom shell commands, so we need this to
avoid checking in the generated reStructuredText files.
"""
docs_path = os.path.abspath(os.path.dirname(__... | Run sphinx-apidoc and swg2rst after Sphinx initialization.
Read the Docs won't run tox or custom shell commands, so we need this to
avoid checking in the generated reStructuredText files. | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/docs/conf.py#L464-L484 |
edx/django-user-tasks | user_tasks/signals.py | create_user_task | def create_user_task(sender=None, body=None, **kwargs): # pylint: disable=unused-argument
"""
Create a :py:class:`UserTaskStatus` record for each :py:class:`UserTaskMixin`.
Also creates a :py:class:`UserTaskStatus` for each chain, chord, or group containing
the new :py:class:`UserTaskMixin`.
"""
... | python | def create_user_task(sender=None, body=None, **kwargs): # pylint: disable=unused-argument
"""
Create a :py:class:`UserTaskStatus` record for each :py:class:`UserTaskMixin`.
Also creates a :py:class:`UserTaskStatus` for each chain, chord, or group containing
the new :py:class:`UserTaskMixin`.
"""
... | Create a :py:class:`UserTaskStatus` record for each :py:class:`UserTaskMixin`.
Also creates a :py:class:`UserTaskStatus` for each chain, chord, or group containing
the new :py:class:`UserTaskMixin`. | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/user_tasks/signals.py#L27-L53 |
edx/django-user-tasks | user_tasks/signals.py | _create_chain_entry | def _create_chain_entry(user_id, task_id, task_class, args, kwargs, callbacks, parent=None):
"""
Create and update status records for a new :py:class:`UserTaskMixin` in a Celery chain.
"""
LOGGER.debug(task_class)
if issubclass(task_class.__class__, UserTaskMixin):
arguments_dict = task_clas... | python | def _create_chain_entry(user_id, task_id, task_class, args, kwargs, callbacks, parent=None):
"""
Create and update status records for a new :py:class:`UserTaskMixin` in a Celery chain.
"""
LOGGER.debug(task_class)
if issubclass(task_class.__class__, UserTaskMixin):
arguments_dict = task_clas... | Create and update status records for a new :py:class:`UserTaskMixin` in a Celery chain. | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/user_tasks/signals.py#L56-L81 |
edx/django-user-tasks | user_tasks/signals.py | _create_chord_entry | def _create_chord_entry(task_id, task_class, message_body, user_id):
"""
Create and update status records for a new :py:class:`UserTaskMixin` in a Celery chord.
"""
args = message_body['args']
kwargs = message_body['kwargs']
arguments_dict = task_class.arguments_as_dict(*args, **kwargs)
name... | python | def _create_chord_entry(task_id, task_class, message_body, user_id):
"""
Create and update status records for a new :py:class:`UserTaskMixin` in a Celery chord.
"""
args = message_body['args']
kwargs = message_body['kwargs']
arguments_dict = task_class.arguments_as_dict(*args, **kwargs)
name... | Create and update status records for a new :py:class:`UserTaskMixin` in a Celery chord. | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/user_tasks/signals.py#L84-L131 |
edx/django-user-tasks | user_tasks/signals.py | _get_or_create_group_parent | def _get_or_create_group_parent(message_body, user_id):
"""
Determine if the given task belongs to a group or not, and if so, get or create a status record for the group.
Arguments:
message_body (dict): The body of the before_task_publish signal for the task in question
user_id (int): The p... | python | def _get_or_create_group_parent(message_body, user_id):
"""
Determine if the given task belongs to a group or not, and if so, get or create a status record for the group.
Arguments:
message_body (dict): The body of the before_task_publish signal for the task in question
user_id (int): The p... | Determine if the given task belongs to a group or not, and if so, get or create a status record for the group.
Arguments:
message_body (dict): The body of the before_task_publish signal for the task in question
user_id (int): The primary key of the user model record for the user who triggered the t... | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/user_tasks/signals.py#L134-L160 |
edx/django-user-tasks | user_tasks/signals.py | _get_user_id | def _get_user_id(arguments_dict):
"""
Get and validate the `user_id` argument to a task derived from `UserTaskMixin`.
Arguments:
arguments_dict (dict): The parsed positional and keyword arguments to the task
Returns
-------
int: The primary key of a user record (may not be an int i... | python | def _get_user_id(arguments_dict):
"""
Get and validate the `user_id` argument to a task derived from `UserTaskMixin`.
Arguments:
arguments_dict (dict): The parsed positional and keyword arguments to the task
Returns
-------
int: The primary key of a user record (may not be an int i... | Get and validate the `user_id` argument to a task derived from `UserTaskMixin`.
Arguments:
arguments_dict (dict): The parsed positional and keyword arguments to the task
Returns
-------
int: The primary key of a user record (may not be an int if using a custom user model) | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/user_tasks/signals.py#L163-L182 |
edx/django-user-tasks | user_tasks/signals.py | task_failed | def task_failed(sender=None, **kwargs):
"""
Update the status record accordingly when a :py:class:`UserTaskMixin` fails.
"""
if isinstance(sender, UserTaskMixin):
exception = kwargs['exception']
if not isinstance(exception, TaskCanceledException):
# Don't include traceback, s... | python | def task_failed(sender=None, **kwargs):
"""
Update the status record accordingly when a :py:class:`UserTaskMixin` fails.
"""
if isinstance(sender, UserTaskMixin):
exception = kwargs['exception']
if not isinstance(exception, TaskCanceledException):
# Don't include traceback, s... | Update the status record accordingly when a :py:class:`UserTaskMixin` fails. | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/user_tasks/signals.py#L195-L204 |
edx/django-user-tasks | user_tasks/signals.py | task_succeeded | def task_succeeded(sender=None, **kwargs): # pylint: disable=unused-argument
"""
Update the status record accordingly when a :py:class:`UserTaskMixin` finishes successfully.
"""
if isinstance(sender, UserTaskMixin):
status = sender.status
# Failed tasks with good exception handling did ... | python | def task_succeeded(sender=None, **kwargs): # pylint: disable=unused-argument
"""
Update the status record accordingly when a :py:class:`UserTaskMixin` finishes successfully.
"""
if isinstance(sender, UserTaskMixin):
status = sender.status
# Failed tasks with good exception handling did ... | Update the status record accordingly when a :py:class:`UserTaskMixin` finishes successfully. | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/user_tasks/signals.py#L217-L226 |
pytroll/trollimage | trollimage/colormap.py | colorize | def colorize(arr, colors, values):
"""Colorize a monochromatic array *arr*, based *colors* given for
*values*. Interpolation is used. *values* must be in ascending order.
"""
hcolors = np.array([rgb2hcl(*i[:3]) for i in colors])
# unwrap colormap in hcl space
hcolors[:, 0] = np.rad2deg(np.unwrap... | python | def colorize(arr, colors, values):
"""Colorize a monochromatic array *arr*, based *colors* given for
*values*. Interpolation is used. *values* must be in ascending order.
"""
hcolors = np.array([rgb2hcl(*i[:3]) for i in colors])
# unwrap colormap in hcl space
hcolors[:, 0] = np.rad2deg(np.unwrap... | Colorize a monochromatic array *arr*, based *colors* given for
*values*. Interpolation is used. *values* must be in ascending order. | https://github.com/pytroll/trollimage/blob/d35a7665ad475ff230e457085523e21f2cd3f454/trollimage/colormap.py#L30-L54 |
pytroll/trollimage | trollimage/colormap.py | palettize | def palettize(arr, colors, values):
"""From start *values* apply *colors* to *data*.
"""
new_arr = np.digitize(arr.ravel(),
np.concatenate((values,
[max(np.nanmax(arr),
values.max()) + 1])))
... | python | def palettize(arr, colors, values):
"""From start *values* apply *colors* to *data*.
"""
new_arr = np.digitize(arr.ravel(),
np.concatenate((values,
[max(np.nanmax(arr),
values.max()) + 1])))
... | From start *values* apply *colors* to *data*. | https://github.com/pytroll/trollimage/blob/d35a7665ad475ff230e457085523e21f2cd3f454/trollimage/colormap.py#L57-L71 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.