File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/attr.zip
Back
PK f)�Z M�% % _cmp.pynu �[��� from __future__ import absolute_import, division, print_function import functools from ._compat import new_class from ._make import _make_ne _operation_names = {"eq": "==", "lt": "<", "le": "<=", "gt": ">", "ge": ">="} def cmp_using( eq=None, lt=None, le=None, gt=None, ge=None, require_same_type=True, class_name="Comparable", ): """ Create a class that can be passed into `attr.ib`'s ``eq``, ``order``, and ``cmp`` arguments to customize field comparison. The resulting class will have a full set of ordering methods if at least one of ``{lt, le, gt, ge}`` and ``eq`` are provided. :param Optional[callable] eq: `callable` used to evaluate equality of two objects. :param Optional[callable] lt: `callable` used to evaluate whether one object is less than another object. :param Optional[callable] le: `callable` used to evaluate whether one object is less than or equal to another object. :param Optional[callable] gt: `callable` used to evaluate whether one object is greater than another object. :param Optional[callable] ge: `callable` used to evaluate whether one object is greater than or equal to another object. :param bool require_same_type: When `True`, equality and ordering methods will return `NotImplemented` if objects are not of the same type. :param Optional[str] class_name: Name of class. Defaults to 'Comparable'. See `comparison` for more details. .. versionadded:: 21.1.0 """ body = { "__slots__": ["value"], "__init__": _make_init(), "_requirements": [], "_is_comparable_to": _is_comparable_to, } # Add operations. num_order_functions = 0 has_eq_function = False if eq is not None: has_eq_function = True body["__eq__"] = _make_operator("eq", eq) body["__ne__"] = _make_ne() if lt is not None: num_order_functions += 1 body["__lt__"] = _make_operator("lt", lt) if le is not None: num_order_functions += 1 body["__le__"] = _make_operator("le", le) if gt is not None: num_order_functions += 1 body["__gt__"] = _make_operator("gt", gt) if ge is not None: num_order_functions += 1 body["__ge__"] = _make_operator("ge", ge) type_ = new_class(class_name, (object,), {}, lambda ns: ns.update(body)) # Add same type requirement. if require_same_type: type_._requirements.append(_check_same_type) # Add total ordering if at least one operation was defined. if 0 < num_order_functions < 4: if not has_eq_function: # functools.total_ordering requires __eq__ to be defined, # so raise early error here to keep a nice stack. raise ValueError( "eq must be define is order to complete ordering from " "lt, le, gt, ge." ) type_ = functools.total_ordering(type_) return type_ def _make_init(): """ Create __init__ method. """ def __init__(self, value): """ Initialize object with *value*. """ self.value = value return __init__ def _make_operator(name, func): """ Create operator method. """ def method(self, other): if not self._is_comparable_to(other): return NotImplemented result = func(self.value, other.value) if result is NotImplemented: return NotImplemented return result method.__name__ = "__%s__" % (name,) method.__doc__ = "Return a %s b. Computed by attrs." % ( _operation_names[name], ) return method def _is_comparable_to(self, other): """ Check whether `other` is comparable to `self`. """ for func in self._requirements: if not func(self, other): return False return True def _check_same_type(self, other): """ Return True if *self* and *other* are of the same type, False otherwise. """ return other.value.__class__ is self.value.__class__ PK f)�ZQ";�� � _next_gen.pynu �[��� """ These are Python 3.6+-only and keyword-only APIs that call `attr.s` and `attr.ib` with different default values. """ from functools import partial from attr.exceptions import UnannotatedAttributeError from . import setters from ._make import NOTHING, _frozen_setattrs, attrib, attrs def define( maybe_cls=None, *, these=None, repr=None, hash=None, init=None, slots=True, frozen=False, weakref_slot=True, str=False, auto_attribs=None, kw_only=False, cache_hash=False, auto_exc=True, eq=None, order=False, auto_detect=True, getstate_setstate=None, on_setattr=None, field_transformer=None, ): r""" The only behavioral differences are the handling of the *auto_attribs* option: :param Optional[bool] auto_attribs: If set to `True` or `False`, it behaves exactly like `attr.s`. If left `None`, `attr.s` will try to guess: 1. If any attributes are annotated and no unannotated `attr.ib`\ s are found, it assumes *auto_attribs=True*. 2. Otherwise it assumes *auto_attribs=False* and tries to collect `attr.ib`\ s. and that mutable classes (``frozen=False``) validate on ``__setattr__``. .. versionadded:: 20.1.0 """ def do_it(cls, auto_attribs): return attrs( maybe_cls=cls, these=these, repr=repr, hash=hash, init=init, slots=slots, frozen=frozen, weakref_slot=weakref_slot, str=str, auto_attribs=auto_attribs, kw_only=kw_only, cache_hash=cache_hash, auto_exc=auto_exc, eq=eq, order=order, auto_detect=auto_detect, collect_by_mro=True, getstate_setstate=getstate_setstate, on_setattr=on_setattr, field_transformer=field_transformer, ) def wrap(cls): """ Making this a wrapper ensures this code runs during class creation. We also ensure that frozen-ness of classes is inherited. """ nonlocal frozen, on_setattr had_on_setattr = on_setattr not in (None, setters.NO_OP) # By default, mutable classes validate on setattr. if frozen is False and on_setattr is None: on_setattr = setters.validate # However, if we subclass a frozen class, we inherit the immutability # and disable on_setattr. for base_cls in cls.__bases__: if base_cls.__setattr__ is _frozen_setattrs: if had_on_setattr: raise ValueError( "Frozen classes can't use on_setattr " "(frozen-ness was inherited)." ) on_setattr = setters.NO_OP break if auto_attribs is not None: return do_it(cls, auto_attribs) try: return do_it(cls, True) except UnannotatedAttributeError: return do_it(cls, False) # maybe_cls's type depends on the usage of the decorator. It's a class # if it's used as `@attrs` but ``None`` if used as `@attrs()`. if maybe_cls is None: return wrap else: return wrap(maybe_cls) mutable = define frozen = partial(define, frozen=True, on_setattr=None) def field( *, default=NOTHING, validator=None, repr=True, hash=None, init=True, metadata=None, converter=None, factory=None, kw_only=False, eq=None, order=None, on_setattr=None, ): """ Identical to `attr.ib`, except keyword-only and with some arguments removed. .. versionadded:: 20.1.0 """ return attrib( default=default, validator=validator, repr=repr, hash=hash, init=init, metadata=metadata, converter=converter, factory=factory, kw_only=kw_only, eq=eq, order=order, on_setattr=on_setattr, ) PK f)�Z��> > setters.pyinu �[��� from typing import Any, NewType, NoReturn, TypeVar, cast from . import Attribute, _OnSetAttrType _T = TypeVar("_T") def frozen( instance: Any, attribute: Attribute[Any], new_value: Any ) -> NoReturn: ... def pipe(*setters: _OnSetAttrType) -> _OnSetAttrType: ... def validate(instance: Any, attribute: Attribute[_T], new_value: _T) -> _T: ... # convert is allowed to return Any, because they can be chained using pipe. def convert( instance: Any, attribute: Attribute[Any], new_value: Any ) -> Any: ... _NoOpType = NewType("_NoOpType", object) NO_OP: _NoOpType PK f)�Z_-^5 _config.pynu �[��� from __future__ import absolute_import, division, print_function __all__ = ["set_run_validators", "get_run_validators"] _run_validators = True def set_run_validators(run): """ Set whether or not validators are run. By default, they are run. """ if not isinstance(run, bool): raise TypeError("'run' must be bool.") global _run_validators _run_validators = run def get_run_validators(): """ Return whether or not validators are run. """ return _run_validators PK f)�Z���� � # __pycache__/_config.cpython-310.pycnu �[��� o ��` � @ s4 d dl mZmZmZ ddgZdadd� Zdd� ZdS )� )�absolute_import�division�print_function�set_run_validators�get_run_validatorsTc C s t | t�s td��| adS )zK Set whether or not validators are run. By default, they are run. z'run' must be bool.N)� isinstance�bool� TypeError�_run_validators)�run� r �./usr/lib/python3/dist-packages/attr/_config.pyr s c C s t S )z3 Return whether or not validators are run. )r r r r r r s N)� __future__r r r �__all__r r r r r r r �<module> s PK f)�Z��I % __pycache__/_next_gen.cpython-310.pycnu �[��� o ��`� � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZm Z m Z mZ ddddddd dd dd d ddd ddddd �dd�ZeZ eeddd �Zedddddddd dddd�dd�ZdS )zr These are Python 3.6+-only and keyword-only APIs that call `attr.s` and `attr.ib` with different default values. � )�partial)�UnannotatedAttributeError� )�setters)�NOTHING�_frozen_setattrs�attrib�attrsNTF)�these�repr�hash�init�slots�frozen�weakref_slot�str�auto_attribs�kw_only� cache_hash�auto_exc�eq�order�auto_detect�getstate_setstate� on_setattr�field_transformerc sR �������� � ��� �����fdd��� ���fdd�}| du r%|S || �S )aD The only behavioral differences are the handling of the *auto_attribs* option: :param Optional[bool] auto_attribs: If set to `True` or `False`, it behaves exactly like `attr.s`. If left `None`, `attr.s` will try to guess: 1. If any attributes are annotated and no unannotated `attr.ib`\ s are found, it assumes *auto_attribs=True*. 2. Otherwise it assumes *auto_attribs=False* and tries to collect `attr.ib`\ s. and that mutable classes (``frozen=False``) validate on ``__setattr__``. .. versionadded:: 20.1.0 c s� t di d| �d��d��d��d��d� �d��d��d ��d |�d� �d��d ��d��d��d� �dd�d��d� �d���S )N� maybe_clsr r r r r r r r r r r r r r r �collect_by_mroTr r r � )r )�clsr )r r r r r r r r r r r r r r r r r r �0/usr/lib/python3/dist-packages/attr/_next_gen.py�do_it5 sR �������� � ��� ��������zdefine.<locals>.do_itc s� �dt jfv}�du r�du rt j�| jD ]}|jtu r'|r"td��t j� nq� dur1�| � �S z�| d�W S tyE �| d� Y S w )z� Making this a wrapper ensures this code runs during class creation. We also ensure that frozen-ness of classes is inherited. NFz@Frozen classes can't use on_setattr (frozen-ness was inherited).T)r �NO_OP�validate� __bases__�__setattr__r � ValueErrorr )r �had_on_setattr�base_cls)r r! r r r r �wrapM s&