
    rh=>                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKJr  SSKJr  \" \" S5      5      r\\\4r\\\1r\\\\\" S5      1r\	R:                  \	R<                  \	R>                  \	R@                  \	RB                  1r"\\#\\\$\%1\-  \"-  r&\\#\\\%1\-  r'S r(S r)S	 r*S
 r+S r,S r-S r.S r/S r0S r1S r2S r3S r4S r5S r6S r7S r8S r9S r:S r;S r<S r=S r>S r?S r@S  rAS! rBS" rCS0S# jrDS0S$ jrES% rFS& rGS' rHS( rIS) rJS* rKS+ rLS, rMS- rN\R                  " S5      4S. jrOS1S/ jrPg)2zkHelper functions for pickling and unpickling.  Most functions assist in
determining the type of an object.
    N)Iterator   )tags c                 "    [        U [        5      $ )zReturns True is obj is a reference to a type.

>>> is_type(1)
False

>>> is_type(object)
True

>>> class Klass: pass
>>> is_type(Klass)
True
)
isinstancetypeobjs    I/home/james-whalen/.local/lib/python3.13/site-packages/jsonpickle/util.pyis_typer   9   s     c4      c                 l   [        X5      (       d  g[        X5      n[        U[        R                  5      (       a  g[        U[        R
                  [        R                  45      (       d  g[        U 5      (       a  U OU R                  nS n[        R                  " U5       H"  n[        U5      R                  U5      nUc  M"    O   Uc  g[        U[        5      (       a  g[        US5      (       d  g[        US5      n[        U[        5      (       a  [        X65      $ [        U [!        U5      5      $ )NFT__self__)hasattrgetattrr   typesBuiltinMethodType
MethodTypeFunctionTyper   	__class__inspectgetmrovarsgetstaticmethodclassmethod
issubclassr	   )r   namefunc	base_typeoriginalsubtypebound_tos          r   
has_methodr%   J   s   33D $//00 dU--u/A/ABCC s||IH>>),=$$T* -  (L)) 4$$tZ(H (K(().. c4>**r   c                     [        U [        5      =(       a4    [        U [        [        R                  [        R
                  45      (       + $ )zReturns True is obj is a reference to an object instance.

>>> is_object(1)
True

>>> is_object(object())
True

>>> is_object(lambda x: 1)
False
)r   objectr	   r   r   BuiltinFunctionTyper
   s    r   	is_objectr)   y   s<     c6" :dE&&(A(AB, ( r   c                 &    [        U 5      [        ;   $ )z^Determines if the object is not a class or a class instance.
Used for serializing properties.
)r	   NON_CLASS_TYPESr
   s    r   is_not_classr,      s     9''r   c                 &    [        U 5      [        ;   $ )zHelper method to see if the object is a basic data type. Unicode strings,
integers, longs, floats, booleans, and None are considered primitive
and will return True when passed into *is_primitive()*

>>> is_primitive(3)
True
>>> is_primitive([4,4])
False
)r	   
PRIMITIVESr
   s    r   is_primitiver/      s     9
""r   c                     S[         R                  ;   =(       a'    [        U [         R                  S   R                  5      $ )zIs the object an enum?enum)sysmodulesr   Enumr
   s    r   is_enumr5      s,    S[[ NZS[[5H5M5M%NNr   c                 Z    [         R                  " S[        5        [        U 5      [        L $ )zcHelper method for testing if the object is a dictionary.

>>> is_dictionary({'key':'value'})
True

[This function will be removed in the next release of jsonpickle, 5.0.0! Please migrate now.)warningswarnDeprecationWarningr	   dictr
   s    r   is_dictionaryr<      s'     MMe 9r   c                 &    [        U 5      [        ;   $ )zdHelper method to see if the object is a sequence (list, set, or tuple).

>>> is_sequence([4])
True

)r	   SEQUENCES_SETr
   s    r   is_sequencer?      s     9%%r   c                 Z    [         R                  " S[        5        [        U 5      [        L $ )zLHelper method to see if the object is a Python list.

>>> is_list([4])
True
r7   )r8   r9   r:   r	   listr
   s    r   is_listrB      s'     MMe 9r   c                 Z    [         R                  " S[        5        [        U 5      [        L $ )zLHelper method to see if the object is a Python set.

>>> is_set(set())
True
r7   )r8   r9   r:   r	   setr
   s    r   is_setrE      s'     MMe 9r   c                 Z    [         R                  " S[        5        [        U 5      [        L $ )zOHelper method to see if the object is a bytestring.

>>> is_bytes(b'foo')
True
r7   )r8   r9   r:   r	   bytesr
   s    r   is_bytesrH      '     MMe 9r   c                 Z    [         R                  " S[        5        [        U 5      [        L $ )zBDEPRECATED: Helper method to see if the object is a unicode stringr7   )r8   r9   r:   r	   strr
   s    r   
is_unicoderL      s%    MMe 9r   c                 Z    [         R                  " S[        5        [        U 5      [        L $ )zOHelper method to see if the object is a Python tuple.

>>> is_tuple((1,))
True
r7   )r8   r9   r:   r	   tupler
   s    r   is_tuplerO      rI   r   c                     [        U S5      =(       a2    [        U R                  [        5      =(       a    [	        U 5      [        L$ )zReturns True if *obj* is a subclass of the dict type. *obj* must be
a subclass and not the actual builtin dict.

>>> class Temp(dict): pass
>>> is_dictionary_subclass(Temp())
True
r   )r   r   r   r;   r	   r
   s    r   is_dictionary_subclassrQ      s7     	[! 	"s}}d+	"IT!r   c                     [        U S5      =(       a1    [        U R                  [        5      =(       a    [	        U 5      (       + $ )zReturns True if *obj* is a subclass of list, set or tuple.

*obj* must be a subclass and not the actual builtin, such
as list, set, tuple, etc..

>>> class Temp(list): pass
>>> is_sequence_subclass(Temp())
True
r   )r   r   r   	SEQUENCESr?   r
   s    r   is_sequence_subclassrT     s6     	[! 	!s}}i0	!C  r   c                 >    [        U 5      [        R                  L a  gg)zReturns True if *obj* is a special (weird) class, that is more complex
than primitive data types, but is not a full object. Including:

    * :class:`~time.struct_time`
TF)r	   timestruct_timer
   s    r   is_noncomplexrX     s     CyD$$$r   c                 &    [        U 5      [        ;   $ )zReturns true if passed a function

>>> is_function(lambda x: 1)
True

>>> is_function(locals)
True

>>> def method(): pass
>>> is_function(method)
True

>>> is_function(1)
False
)r	   FUNCTION_TYPESr
   s    r   is_functionr[   $  s      9&&r   c                    [        U S5      =(       af    [        U [        R                  [        R                  45      =(       a5    [        U S5      =(       a"    [        U S5      =(       a    U R
                  S:g  =(       d    [        U 5      $ )zReturn True if `obj` is a module-global function

>>> import os
>>> is_module_function(os.path.exists)
True

>>> is_module_function(lambda: None)
False

r   
__module____name__z<lambda>)r   r   r   r   r(   r^   is_cython_functionr
   s    r   is_module_functionr`   7  su     	[! 	'sU//1J1JKL	'C&	' C$	' LLJ&! 
C	 !r   c                 l    [         R                  " S[        5        [        U [        R
                  5      $ )zGReturns True if passed a module

>>> import os
>>> is_module(os)
True

r7   )r8   r9   r:   r   r   
ModuleTyper
   s    r   	is_modulerc   L  s+     MMe c5++,,r   c                 p    U [         R                  ;   a  g[        U5      =(       d    [        U5      (       + $ )zReturn True if an object can be pickled

>>> import os
>>> is_picklable('os', os)
True

>>> def foo(): pass
>>> is_picklable('foo', foo)
True

>>> is_picklable('foo', lambda: None)
False

F)r   RESERVEDr`   r[   )r   values     r   is_picklablerg   [  s+     t}}e$>K,>(>>r   c                 <     [        U 5        g! [         a     gf = f)zTests to see if ``module`` is available on the sys.path

>>> is_installed('sys')
True
>>> is_installed('hopefullythisisnotarealmodule')
False

TF)
__import__ImportErrormodules    r   is_installedrm   o  s$    6 s    
c                 @    [        U S5      =(       a    [        U S5      $ )N__getitem__append)r   r
   s    r   is_list_likerq     s    3&A73+AAr   c                 n    [        U [        5      =(       a    [        U [        R                  5      (       + $ N)r   abc_iteratorioIOBaser
   s    r   is_iteratorrw     s"    c<(KC1K-KKr   c                 T     [        U 5      R                  S:H  $ ! [         a     gf = f)NcollectionsF)r	   r]   	Exceptionr
   s    r   is_collectionsr{     s.    Cy##}44 s    
''c                 \    [        U S5      =(       a    [        U R                  [        5      $ )Nr   )r   r   r   rS   r
   s    r   is_reducible_sequence_subclassr}     s    3$MCMM9)MMr   c                    [        U 5      (       a   [        U [        R                  5      (       d  g[	        U 5      [
        ;   d  U [        L d  [        U 5      (       d  [        U [        R                  5      (       d`  [        U 5      (       dP  [        U 5      (       d@  [        [        U SS5      [        5      (       d   [        U 5      (       a  U R                  S:X  a  gg)zi
Returns false if of a type which have special casing,
and should not have their __reduce__ methods used
T	__slots__NdatetimeF)r{   r   ry   defaultdictr	   NON_REDUCIBLE_TYPESr'   rQ   r   rb   r}   rq   r   _ITERATOR_TYPEr   r]   r
   s    r   is_reducibler     s     c:c;3J3J#K#KS	((&=!#&&c5++,,)#..gc;5~FFCLLS^^z9r   c                     [        U 5      =(       a-    [        U S5      =(       a    [        U 5      R                  S5      $ )z>Returns true if the object is a reference to a Cython function__repr__z<cyfunction )callabler   repr
startswithr
   s    r   r_   r_     s6     	 	1C$	1I  0r   c                 T     [        XU5        g! [         a     g[         a     gf = f)NFT)setattrAttributeError	TypeError)r   attrrf   s      r   is_readonlyr     s3    	5!   s    
'	''c                 F    [        U SS5      (       a  XR                  ;   $ U$ )zh
Returns true if key exists in obj.__dict__; false if not in.
If obj.__dict__ is absent, return default
__dict__N)r   r   r   keydefaults      r   in_dictr     s$    
 %,CT$B$BC<<OOr   c                 F    [        U SS5      (       a  XR                  ;   $ U$ )zj
Returns true if key exists in obj.__slots__; false if not in.
If obj.__slots__ is absent, return default
r   N)r   r   r   s      r   in_slotsr     s$    
 &-S+t%D%DC== Q'Qr   c                 |   [        U 5      (       a  [        U 5      (       a  g[        U 5      (       a  gSnSnSnSn[        X5      =(       d    [	        X5      n[        X5      =(       d    [	        X5      n[        U 5      R                   HP  n[        U5      (       a(  U=(       d    [        XS5      nU=(       d    [        XT5      nU(       d  MD  U(       d  MM  X4s  $    [        U 5      n[        [        U5      n[        [        U5      nU(       d  [        XcS5      n	XLa  U	nU(       d  [        XdS5      n
XLa  U
nX4$ )z
Tests if __reduce__ or __reduce_ex__ exists in the object dict or
in the class dicts of every class in the MRO *except object*.

Returns a tuple of booleans (has_reduce, has_reduce_ex)
)FF)FTF
__reduce____reduce_ex__)	r   r   rX   r   r   r	   __mro__r   r'   )r   
has_reducehas_reduce_exREDUCE	REDUCE_EXbaseclsobject_reduceobject_reduce_exhas_reduce_clshas_reduce_ex_clss              r   r   r     s    
 SJMFI %>#)>JC+Gx/GM S	!!#<wt'<J)EWT-EM:--.. " s)CFF+Mvy1 e4.'J#CE:4-M&&r   c                 8    [        SSS9nUR                  X 5      $ )a  Rename builtin modules to a consistent module name.

Prefer the more modern naming.

This is used so that references to Python's `builtins` module can
be loaded in both Python 2 and 3.  We remap to the "__builtin__"
name and unmap it when importing.

Map the Python2 `exceptions` module to `builtins` because
`builtins` is a superset and contains everything that is
available in `exceptions`, which makes the translation simpler.

See untranslate_module_name() for the reverse operation.
builtins__builtin__
exceptionsr;   r   rl   lookups     r   translate_module_namer     s     jZ@F::f%%r   c                 8    [        SSS9nUR                  X 5      $ )zProvide compatibility for pickles created with jsonpickle 0.9.6 and
earlier, remapping `exceptions` and `__builtin__` to `builtins`.
r   r   r   r   s     r   _0_9_6_compat_untranslater     s     jZ@F::f%%r   c                     [        U 5      $ )zRename module names mention in JSON to names that we can import

This reverses the translation applied by translate_module_name() to
a module name available to the current version of Python.

)r   rk   s    r   untranslate_module_namer     s     %V,,r   c                 <   [        U SU R                  5      n[        U R                  5      nU(       dc  [	        U S5      (       aR  [	        U R
                  S5      (       a  U R
                  R                  nO U R
                  R                  R                  nU SU 3$ )az  
>>> class Example(object):
...     pass

>>> ex = Example()
>>> importable_name(ex.__class__) == 'jsonpickle.util.Example'
True
>>> importable_name(type(25)) == 'builtins.int'
True
>>> importable_name(None.__class__) == 'builtins.NoneType'
True
>>> importable_name(False.__class__) == 'builtins.bool'
True
>>> importable_name(AttributeError) == 'builtins.AttributeError'
True

__qualname__r   r]   .)r   r^   r   r]   r   r   r   )r   r   rl   s      r   importable_namer   )  sz    & 35D"3>>2F3
##s||\2200//::XQtfr   c                 L    [         R                  " U 5      R                  S5      $ )zA
Encode binary data to ascii text in base64. Data must be bytes.
ascii)base64	b64encodedecodedatas    r   r   r   G        D!((11r   c                 p     [         R                  " U 5      $ ! [        [        R                  4 a     gf = fz&
Decode payload - must be ascii text.
r   )r   	b64decoder   binasciiErrorpayloads    r   r   r   N  s3    ((x~~& s    55c                 L    [         R                  " U 5      R                  S5      $ )zA
Encode binary data to ascii text in base85. Data must be bytes.
r   )r   	b85encoder   r   s    r   r   r   X  r   r   c                 \     [         R                  " U 5      $ ! [        [        4 a     gf = fr   )r   	b85decoder   
ValueErrorr   s    r   r   r   _  s/    ((z" s    ++c                 $    [        U" U 5      5      $ rs   )rK   )r   getters     r   
itemgetterr   i  s    vc{r   c              #   V   #    U R                  5        H  u  p#X!;   a  M  X#4v   M     g7f)zh
This can't be easily replaced by dict.items() because this has the exclude parameter.
Keep it for now.
N)items)r   excludekvs       r   r   r   m  s(     
 		<d
 s   '))F) )Q__doc__r   r   ry   r   ru   operatorr2   rV   r   r8   collections.abcr   rt   r   r   r	   iterr   rA   rD   rN   rS   r>   rK   boolintfloatr.   r   r   
LambdaTyper(   r   rZ   r;   r'   rG   r   r+   r   r%   r)   r,   r/   r5   r<   r?   rB   rE   rH   rL   rO   rQ   rT   rX   r[   r`   rc   rg   rm   rq   rw   r{   r}   r   r_   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s       	  
    4 d2h3	sE"4eT$Z0
					 	  	  			 !",+^"(
#O
&



 "'&!*-?( BLN,PR2'j&&&-<22 $..q1 r   