Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
utils.cpython-313.pyc119 linesDownload Raw Back to __pycache__
1�

2��j�.���SrSSKJr SSKrSSKrSSKrSSKrSSKrSSK	r	SSK3r4SSKrSSKJ
r
 SSKJrJr SSKJr SSKJr SSKJr SS	KJr \5R2(aSS6KJr SrSrS
r\\\1r"SS5r \ "5r!S3Sjr"S3Sjr#S3Sjr$S3Sjr%S3Sjr&S4SjrS5Sjr'S6Sjr(S7Sjr)\	RT"S5r+\	RT"S5r,\	RT"S5r-S8Sjr.Sr/Sr0Sr1S9S jr2S9S!jr3S:S"jr4S:S#jr5S7S$jr6S;S%jr7S<S&jr8S=S'jr9S>S(jr:\!4S?S)jjr;S*r<S+r=S@S,jr>S-r?SAS.jr@SAS/jrASBS0jrBSCS1jrCSDS2jrDg)Ez Utility methods for marshmallow.�)�annotationsN)�Mapping)�format_datetime�parsedate_to_datetime)�pprint)�FieldABC)�FieldInstanceResolutionError)�RemovedInMarshmallow4Warning)�Field�exclude�include�raisec�,�\rSrSrSrSrSrSrSrg)�_Missing� c��g)NF���selfs �WD:\code\apps\devtools\python\user_packages\Python313\site-packages\marshmallow/utils.py�__bool__�_Missing.__bool__!s���c��U$�Nrrs r�__copy__�_Missing.__copy__$����rc��U$rr)r�_s  r�__deepcopy__�_Missing.__deepcopy__'rrc��g)Nz<marshmallow.missing>rrs r�__repr__�_Missing.__repr__*s��&rrN)	�__name__�7__module__�__qualname__�__firstlineno__rrr!r$�__static_attributes__rrrrr s�����'rrc�h�[R"U5=(d [R"U5$)z%Return True if ``obj`` is a generator)�inspect�isgeneratorfunction�isgenerator��objs r�is_generatorr14s#���&�&�s�+�G�w�/B�/B�3�/G�Grc�n�[US5=(a [US5(+=(d [U5$)zAReturn True if ``obj`` is an iterable object that isn't a string.�__iter__�strip)�hasattrr1r/s r�is_iterable_but_not_stringr69s)���C��$�B�W�S�'�-B�)B�X�|�TW�GX�Xrc�P�[U5=(a [U[5(+$)zGReturn True if ``obj`` is a collection type, e.g list, tuple, queryset.)r6�8isinstancerr/s r�
is_collectionr9>s��%�c�*�K�:�c�7�3K�/K�Krc�P�[X5$![a [X5s$f=f)zFReturn True if ``val`` is either a subclass or instance of ``class_``.)�9issubclass�	TypeErrorr8)�val�class_s  r�is_instance_or_subclassr?Cs,��'��#�&�&���'��#�&�&�'�s�10
�%�%c�H�[U[5=(a [US5$)zbReturn True if ``obj`` has keyed tuple behavior, such as11namedtuples or SQLAlchemy's KeyedTuples.12�_fields)r8�tupler5r/s r�is_keyed_tuplerCKs���c�5�!�=�g�c�9�&=�=rc���[R"S[SS9 [U[R135(a$[
[R"U/UQ70UD65 g[U/UQ70UD6 g)z�Pretty-printing function that can pretty-print OrderedDicts14like regular dictionaries. Useful for printing the output of15:meth:`marshmallow.Schema.dump`.16 17.. deprecated:: 3.7.018    marshmallow.pprint will be removed in marshmallow 4.19zQmarshmallow's pprint function is deprecated and will be removed in marshmallow 4.�)�20stacklevelN)21�warnings�warnr22r8�collections�OrderedDict�print�json�dumps�	py_pprint)r0�args�kwargss   rrrRs[��
�M�M�[�$���23�#�{�.�.�/�/�
�d�j�j��.�t�.�v�.�/��#�'��'��'rc�f�URSL=(a URRU5SL$r)�tzinfo�	utcoffset��datetimes r�is_awarerVfs-�����t�#�W����(A�(A�(�(K�SW�(W�rc��[U5$)z�Parse a RFC822-formatted datetime string and return a datetime object.24 25https://stackoverflow.com/questions/885015/how-to-parse-a-rfc-2822-date-time-into-a-python-datetime  # noqa: B95026)r)�27datestrings r�from_rfcrYls��28!��,�,rc��[U5$)zaReturn the RFC822-formatted representation of a datetime object.29 30:param datetime: The datetime.31)rrTs r�	rfcformatr[ts��32�8�$�$rz�(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})[T ](?P<hour>\d{1,2}):(?P<minute>\d{1,2})(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$z4(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})$zd(?P<hour>\d{1,2}):(?P<minute>\d{1,2})(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?c��[U[R5(aUR5S-nUS:aSOSnSR"[[
U5S56nX-n[R"[R"US9U5$)z6Return a tzinfo instance with a fixed offset from UTC.�<r�-�+z{:02d}{:02d})�minutes)r8�dt�	timedelta�
total_seconds�format�divmod�abs�timezone)�offset�sign�hhmm�names    r�get_fixed_timezonerl�so���&�"�,�,�'�'��%�%�'�2�-���1�*�3�#�D�� � �&��V��b�"9�:�D��;�D�
�;�;�r�|�|�F�3�T�:�:rc�\�[RU5nU(d[S5eUR5nUS=(a USR	SS5US'URS5nUS:Xa[RRnOMUbJ[U5S:�a[US	S5OS33nS[USS5-U-nUS34S
:XaU*n[U5nUR5VVs0sHupgUcM35U[U5_M nnnX2S'[R"S0UD6$s snnf)z�Parse a string and return a datetime.datetime.36 37This function supports time zone offsets. When the input contains one,38the output uses a timezone with a fixed offset from UTC.39z-Not a valid ISO8601-formatted datetime string�microsecond��0rR�ZN������rr]�r^r)�_iso8601_datetime_re�match�40ValueError�	groupdict�ljust�poprarg�utc�len�intrl�itemsrU)�valuerv�kwrR�offset_minsrh�k�vs        r�from_iso_datetimer��s��
!�&�&�u�-�E���H�I�I�	���	�B��=�)�M�b��.?�.E�.E�a��.M�B�}��
�V�V�H�
�F�
��}�������	�	�*-�f�+��/�c�&���+�&�q���c�&��1�+�&�&��4���!�9����W�F�#�F�+�� "���41�	<�42���a�)�!�S��V�)�43�B�	<��x�L�
�;�;������44=s�.	D(�;D(c�V�[RU5nU(d[S5eUR5nUS=(a USR	SS5US'UR5VVs0sHup4UcM45U[
U5_M nnn[R"S0UD6$s snnf)z]Parse a string and return a datetime.time.46 47This function doesn't support time zone offsets.48z)Not a valid ISO8601-formatted time stringrnrorpr)	�_iso8601_time_rervrwrxryr~r}ra�time)rrvr�r�r�s     r�
from_iso_timer��s���49
�"�"�5�)�E���D�E�E�	���	�B��=�)�M�b��.?�.E�.E�a��.M�B�}�� "���50�	<�51���a�)�!�S��V�)�52�B�	<�
�7�7�=�R�=���53=s�/	B%�<B%c��[RU5nU(d[S5eUR5R	5VVs0sHup#U[U5_M nnn[R"S0UD6$s snnf)z*Parse a string and return a datetime.date.z)Not a valid ISO8601-formatted date stringr)�_iso8601_date_rervrwrxr~r}ra�date)rrvr�r�r�s     r�
from_iso_dater��sf���"�"�5�)�E���D�E�E� %��� 1� 7� 7� 9�	:� 9���!�S��V�)� 9�B�	:�
�7�7�=�R�=���54;s�	A:c�Z�USLdUSLa[S5e[U5nUS:a[S5e[RR	U[R55RS9RSS9$![an[S5UeSnAf[an[S5UeSnAff=f)	NTFzNot a valid POSIX timestampr)�tz�rRzTimestamp is too largez"Error converting value to datetime)56rw�floatrarU�
fromtimestamprgr{�replace�
OverflowError�OSError)r�excs  r�from_timestampr��s�����}�����6�7�7��%�L�E��q�y��6�7�7�H��{�{�(�(��2�;�;�?�?�(�C�K�K�SW�K�X�X���<��1�2��;���H��=�>�C�G��H�s$�AA6�657B*�B�
B*�B%�%B*c�4�[U5n[US-5$�Ni�)r�r��rs r�from_timestamp_msr��s���%�L�E��%�$�,�'�'rc��[U5(d'UR[RRS9nUR5$)Nr�)rVr�rargr{�	timestampr�s rr�r��s2���E�?�?��
�
�R�[�[�_�_�
�5���?�?��rc��[U5S-$r�)r�r�s r�timestamp_msr��s���U��d�"�"rc�"�UR5$)zbReturn the ISO8601-formatted representation of a datetime object.58 59:param datetime: The datetime.60)�	isoformatrTs rr�r��s��61����rc�@�[RRU5$r)rar�r�)r�s r�to_iso_timer�����
�7�7���T�"�"rc�@�[RRU5$r)rar�r�)r�s r�to_iso_dater��r�rc�d�[U[5(aURS5n[U5$)Nzutf-8)r8�bytes�decode�str)r=s r�ensure_text_typer��s&���#�u����j�j��!���s�8�Orc�6�UVs/sHo"UPM	 sn$s snf)z�Extracts a list of dictionary values from a list of dictionaries.62::63 64    >>> dlist = [{'id': 1, 'name': 'foo'}, {'id': 2, 'name': 'bar'}]65    >>> pluck(dlist, 'id')66    [1, 2]67r)�dictlist�key�ds   r�pluckr�s��%�%�H�q�c�F�H�%�%��%s�c��[U[5(d!SU;a[XRS5U5$[	XU5$)a�Helper for pulling a keyed value off various types of objects. Fields use68this method by default to access attributes of the source object. For object `x`69and attribute `i`, this method first tries to access `x[i]`, and then falls back to70`x.i` if an exception is raised.71 72.. warning::73    If an object `x` does not raise an exception when `x[i]` does not exist,74    `get_value` will never check the value `x.i`. Consider overriding75    `marshmallow.fields.Field.get_value` in this case.76�.)r8r}�_get_value_for_keys�split�_get_value_for_key�r0r��defaults   r�	get_valuer�s9���c�3���C�3�J�"�3�	�	�#���@�@��c��0�0rc�x�[U5S:Xa[XSU5$[[XSU5USSU5$)Nrtr)r|r�r�)r0�keysr�s   rr�r�sC��77�4�y�A�~�!�#�A�w��8�8���3�Q���1�4���8�W��rc��[US5(d[XU5$X$![[[[784a [XU5s$f=f)N�__getitem__)r5�getattr�KeyError�79IndexErrorr<�AttributeErrorr�s   rr�r�&sM���3�
�&�&��s��)�)�*��x����j�)�^�<�*��s��)�)�*�s�#�&A�Ac���SU;a\URSS5up4URU05n[U[5(d[	SUSUSU35e[XTU5 gX U'g)z�Set a value in a dict. If `key` contains a '.', it is assumed80be a path (i.e. dot-delimited string) to the value's location.81 82::83 84    >>> d = {}85    >>> set_value(d, 'foo.bar', 42)86    >>> d87    {'foo': {'bar': 42}}88r�rtzCannot set z in z due to existing value: N)r��89setdefaultr8�dictrw�	set_value)�dctr�r�head�rest�targets      rr�r�0sq���c�z��Y�Y�s�A�&�90������b�)���&�$�'�'���c�U�$�t�f�,D�V�H�M��
�	�&��&��C�rc�F�[U5(d[SU<S35eU$)z@Check that an object is callable, else raise a :exc:`TypeError`.�Object z is not callable.)�callabler<r/s r�callable_or_raiser�Gs%���C�=�=��'�#��(9�:�;�;��Jrc�p�[[R"U5RR	55$r)�listr,�	signature�91parametersr���funcs r�92_signaturer�Ns'����!�!�$�'�2�2�7�7�9�:�:rc��[R"U5(d"U5(a[U5$[	U[93R5(a[UR5$[U5$)z�Given a callable, return a list of argument names. Handles94`functools.partial` objects and class-based callables.95 96.. versionchanged:: 3.0.0a197    Do not return bound arguments, eg. ``self``.98)r,�99isfunction�ismethodr�r8�	functools�partialr�r�s r�
get_func_argsr�Rs]�����$���7�#3�#3�D�#9�#9��$����$�	�)�)�*�*��$�)�)�$�$��d��rc��[U[5(a"[U[5(d[eU"5$[U[5(d[eU$)zjReturn a field instance from a field class or instance.100 101:param cls_or_instance: Field class or instance.102)r8�typer;rr	)�cls_or_instances r�resolve_field_instancer�asF��103�/�4�(�(��/�8�4�4�.�.�� � ��o�x�0�0�*�*��rc�Z�URS-UR-S-UR-$)z�Compute the total microseconds of a timedelta104 105https://github.com/python/cpython/blob/bb3e0c240bc60fe08d332ff5955d54197f79751c/Lib/datetime.py#L665-L667  # noqa: B950106i�Qi@B)�days�seconds�microsecondsr�s r�timedelta_to_microsecondsr�os,��107
�J�J�)�$�u�}�}�4��?�%�BT�BT�T�Trc�:�U[;a[SU<S35eU$)Nr�z1 is not a valid value for the 'unknown' parameter)�_UNKNOWN_VALUESrwr/s r� validate_unknown_parameter_valuer�ws+��108�/�!���c�W�M�N�109�	110��Jr)�return�bool)r��None)rU�dt.datetimer�r�)rXr�r�r�)rUr�r�r�)rhzfloat | dt.timedeltar�zdt.timezone)r�111typing.Anyr�r�)rr�r�r�)r�zdt.timer�r�)r�zdt.dater�r�)r=zstr | bytesr�r�)r�zlist[dict[str, typing.Any]]r�r�)r�z	int | str)r�zdict[str, typing.Any]r�r�rr�)r�ztyping.Callabler�z	list[str])r�ztype[Field] | Fieldr�r)rzdt.timedeltar�r})r0r�r�r�)E�__doc__�112__future__rrIrUrar�r,rL�re�typingrG�collections.abcr�email.utilsrrrrN�marshmallow.baser�marshmallow.exceptionsr	�marshmallow.warningsr113�
TYPE_CHECKING�marshmallow.fieldsr�EXCLUDE�INCLUDE�RAISEr�r�missingr1r6r9r?rCrVrYr[�compilerur�r�rlr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�<module>r�sj��&�#������	�
��#�>�&�%�?�=�	���(���114�����G�U�+��'�'�"�*��H�115Y�116L�117'�>�(�(�-�%��z�z�-����:�:�U�V���:�:�G���;��2��H�"(�118���119��#� �#�#��&�,3�
1� �*��.�;���U�r
codekingpro/portable-devtools · Team Ai