Ë
    [^(h¼"  ã                   óä   — d dl Z d dlmZmZ d dlmZmZmZ d dl	m
Z
 d dlmZmZ ddlmZmZmZ g d¢Z G d	„ d
e«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z e«       Z G d„ de«      Zy)é    N)ÚABCÚabstractmethod)Ú_getattributeÚ_PicklerÚwhichmodule)Ú
ModuleType)ÚAnyÚOptionalé   )ÚdemangleÚget_mangle_prefixÚ
is_mangled)ÚObjNotFoundErrorÚObjMismatchErrorÚImporterÚOrderedImporterc                   ó   — e Zd ZdZy)r   zHRaised when an importer cannot find an object by searching for its name.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úT/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/package/importer.pyr   r      s   „ ÚRr   r   c                   ó   — e Zd ZdZy)r   z]Raised when an importer found a different object with the same name as the user-provided one.Nr   r   r   r   r   r      s   „ Úgr   r   c            	       óz   — e Zd ZU dZeeef   ed<   ededefd„«       Z	dde
dee   deeef   fd	„Zde
dedefd
„Zy)r   ad  Represents an environment to import modules from.

    By default, you can figure out what module an object belongs by checking
    __module__ and importing the result using __import__ or importlib.import_module.

    torch.package introduces module importers other than the default one.
    Each PackageImporter introduces a new namespace. Potentially a single
    name (e.g. 'foo.bar') is present in multiple namespaces.

    It supports two main operations:
        import_module: module_name -> module object
        get_name: object -> (parent module name, name of obj within module)

    The guarantee is that following round-trip will succeed or throw an ObjNotFoundError/ObjMisMatchError.
        module_name, obj_name = env.get_name(obj)
        module = env.import_module(module_name)
        obj2 = getattr(module, obj_name)
        assert obj1 is obj2
    ÚmodulesÚmodule_nameÚreturnc                  ó   — y)zvImport `module_name` from this environment.

        The contract is the same as for importlib.import_module.
        Nr   ©Úselfr   s     r   Úimport_modulezImporter.import_module1   s   � r   NÚobjÚnamec                 óh  ‡ ‡— ‰€S|rQt         j                  j                  t        |«      «      €)t	        |dd«      }|�	  |«       }t        |t        «      r|Š‰€t	        |dd«      Š‰€|j                  Š‰ j                  |‰«      }t        |«      }	 ‰ j                  |«      }t        |‰«      \  }}	||u r|‰fS ˆˆ fd„}
 |
|«      \  }}} |
|«      \  }}}d|› d|› d	|› d
|› d|› d|› d�}t#        |«      ‚# t        $ r Y Œ¬w xY w# t        t        t        f$ r t!        |› d|› d‰› �«      d‚w xY w)ai  Given an object, return a name that can be used to retrieve the
        object from this environment.

        Args:
            obj: An object to get the module-environment-relative name for.
            name: If set, use this name instead of looking up __name__ or __qualname__ on `obj`.
                This is only here to match how Pickler handles __reduce__ functions that return a string,
                don't use otherwise.
        Returns:
            A tuple (parent_module_name, attr_name) that can be used to retrieve `obj` from this environment.
            Use it like:
                mod = importer.import_module(parent_module_name)
                obj = getattr(mod, attr_name)

        Raises:
            ObjNotFoundError: we couldn't retrieve `obj by name.
            ObjMisMatchError: we found a different object with the same name as `obj`.
        NÚ
__reduce__r   z was not found as ú.c                 ó’   •— ‰€J ‚‰j                  | ‰«      }t        |«      }|rt        |«      nd}|rdt        |«      › �nd}|||fS )Nzthe current Python environmentzthe importer for z'sys_importer')r   r   r   )r%   r   Úis_mangled_ÚlocationÚimporter_namer&   r#   s        €€r   Úget_obj_infoz'Importer.get_name.<locals>.get_obj_infon   sq   ø€ ØÐ#Ð#Ð#Ø×*Ñ*¨3°Ó5ˆKÜ$ [Ó1ˆKñ ô " +Ô.à5ð ñ ð $Ô$5°kÓ$BÐ#CÑDà%ð ð
  ¨-Ð7Ð7r   z

The object provided is from 'z', which is coming from z.
However, when we import 'z', it's coming from z@.
To fix this, make sure this 'PackageExporter's importer lists z before )r   ÚdispatchÚgetÚtypeÚgetattrÚ
isinstanceÚstrÚ	Exceptionr   r   r   r$   r   ÚImportErrorÚKeyErrorÚAttributeErrorr   r   )r#   r%   r&   ÚreduceÚrvÚorig_module_namer   ÚmoduleÚobj2Ú_r.   Úobj_module_nameÚobj_locationÚobj_importer_nameÚobj2_module_nameÚobj2_locationÚobj2_importer_nameÚmsgs   ` `               r   Úget_namezImporter.get_name8   s¦  ù€ ð& ˆ<™C¤H×$5Ñ$5×$9Ñ$9¼$¸s»)Ó$DÐ$Lô ˜S ,°Ó5ˆFØÐ!ðÙ›�BÜ! "¤cÔ*Ø!˜ð ˆ<Ü˜3 °Ó5ˆDØˆ<Ø—<‘<ˆDà×+Ñ+¨C°Ó6Ðô Ð/Ó0ˆð	Ø×'Ñ'¨Ó4ˆFÜ# F¨DÓ1‰GˆD�!ð �$‰;Ø Ð$Ð$õ	8ñ  <HÈÓ;LÑ8ˆ˜Ð'8Ù>JÈ4Ó>PÑ;Ð˜-Ð);à/°Ð/@ð A$Ø$0 >ð 2*Ø*:Ð);Ð;OÐP]Èð _Oà Ð! Ð*<Ð)=¸Qð	@ð 	ô ˜sÓ#Ð#øôe !ò Ùðûô" œX¤~Ð6ò 	Ü"Ø�%Ð)¨+¨°a¸°vÐ>óàðð	ús   ¿C9 Â D Ã9	DÄDÄ)D1c                 óê   — t        |dd«      }|�|S | j                  j                  «       j                  «       D ](  \  }}|dk(  s|dk(  s|€Œ	 t	        ||«      d   |u r|c S Œ* y# t
        $ r Y Œ7w xY w)a  Find the module name an object belongs to.

        This should be considered internal for end-users, but developers of
        an importer can override it to customize the behavior.

        Taken from pickle.py, but modified to exclude the search into sys.modules
        r   NÚ__main__Ú__mp_main__r   )r2   r   ÚcopyÚitemsr   r8   )r#   r%   r&   r   r<   s        r   r   zImporter.whichmodule‰   sŸ   € ô ˜c <°Ó6ˆØÐ"ØÐð $(§<¡<×#4Ñ#4Ó#6×#<Ñ#<Ó#>ò 	ÑˆK˜à˜zÒ)Ø -Ò/Ø�>àðÜ  ¨Ó.¨qÑ1°SÑ8Ø&Ò&ð 9ð	ð øô "ò Ùðús   ÁA&Á&	A2Á1A2©N)r   r   r   r   Údictr4   r   Ú__annotations__r   r$   r	   r
   ÚtuplerF   r   r   r   r   r   r      s}   … ñð( �#�z�/Ñ"Ó"àð¨ð °ò ó ðñO$˜Cð O$ x°¡}ð O$ÀÀcÈ3ÀhÁó O$ðb˜sð ¨#ð °#ô r   r   c                   ó0   — e Zd ZdZdefd„Zdededefd„Zy)	Ú_SysImporterz;An importer that implements the default behavior of Python.r   c                 ó,   — t        j                  |«      S rL   )Ú	importlibr$   r"   s     r   r$   z_SysImporter.import_moduleª   s   € Ü×&Ñ& {Ó3Ð3r   r%   r&   r    c                 ó   — t        ||«      S rL   )Ú_pickle_whichmodule)r#   r%   r&   s      r   r   z_SysImporter.whichmodule­   s   € Ü" 3¨Ó-Ð-r   N)r   r   r   r   r4   r$   r	   r   r   r   r   rQ   rQ   §   s+   „ ÙEð4¨ó 4ð.˜sð .¨#ð .°#ô .r   rQ   c                   ó@   — e Zd ZdZd„ Zd„ Zdedefd„Zde	dedefd	„Z
y
)r   z—A compound importer that takes a list of importers and tries them one at a time.

    The first importer in the list that returns a result "wins".
    c                 ó$   — t        |«      | _        y rL   )ÚlistÚ
_importers)r#   Úargss     r   Ú__init__zOrderedImporter.__init__º   s   € Ü*.¨t«*ˆ�r   c                 ón   — t        |dd«      syt        |d«      syt        |d«      sy|j                  du S )aà  Returns true iff this module is an empty PackageNode in a torch.package.

        If you intern `a.b` but never use `a` in your code, then `a` will be an
        empty module with no source. This can break cases where we are trying to
        re-package an object after adding a real dependency on `a`, since
        OrderedImportere will resolve `a` to the dummy package and stop there.

        See: https://github.com/pytorch/pytorch/pull/71520#issuecomment-1029603769
        Ú__torch_package__FÚ__path__Ú__file__TN)r2   Úhasattrr_   )r#   r<   s     r   Ú_is_torchpackage_dummyz&OrderedImporter._is_torchpackage_dummy½   s=   € ô �vÐ2°EÔ:ØÜ�v˜zÔ*ØÜ�v˜zÔ*ØØ�‰ $Ð&Ð&r   r   r    c                 ó   — d }| j                   D ]G  }t        |t        «      st        |› d�«      ‚	 |j	                  |«      }| j                  |«      rŒE|c S  |�|‚t        |«      ‚# t        $ r}|}Y d }~Œid }~ww xY w)NzP is not a Importer. All importers in OrderedImporter must inherit from Importer.)rY   r3   r   Ú	TypeErrorr$   ra   ÚModuleNotFoundError)r#   r   Úlast_errÚimporterr<   Úerrs         r   r$   zOrderedImporter.import_moduleÏ   sœ   € ØˆØŸ™ò 	ˆHÜ˜h¬Ô1ÜØ�jð !Sð Sóð ðØ!×/Ñ/°Ó<�Ø×.Ñ.¨vÔ6ØØ’ð	ð ÐØˆNä% kÓ2Ð2øô 'ò Ø•ûðús   ±"A(ÁA(Á(	A=Á1A8Á8A=r%   r&   c                 ó\   — | j                   D ]  }|j                  ||«      }|dk7  sŒ|c S  y)NrH   )rY   r   )r#   r%   r&   rf   r   s        r   r   zOrderedImporter.whichmoduleä   s:   € ØŸ™ò 	#ˆHØ"×.Ñ.¨s°DÓ9ˆKØ˜jÓ(Ø"Ò"ð	#ð
 r   N)r   r   r   r   r[   ra   r4   r   r$   r	   r   r   r   r   r   r   ´   s>   „ ñò
5ò'ð$3¨ð 3°ó 3ð*˜sð ¨#ð °#ô r   r   )rS   Úabcr   r   Úpickler   r   r   rU   Útypesr   Útypingr	   r
   Ú	_manglingr   r   r   Ú__all__r5   r   r   r   rQ   Úsys_importerr   r   r   r   ú<module>rp      sw   ðã ß #÷ñ õ
 ß  ç >Ñ >ò R€ôS�yô Sôh�yô hôJˆsô JôZ.�8ô .ñ ‹~€ô6�hõ 6r   