Files
Python/screensaver-sushi/bin/build/sushi-screensaver/localpycs/pyimod02_importers.pyc
T

269 lines
33 KiB
Plaintext
Raw Normal View History

§
ãóЗdZddlZddlZddlZddlZddlZddlZejjr ej rd„Z
nd„Z
d„Z da ej
¦«Zdad„ZgZej ej¦«Ze e¦«ej e¦«Zej e¦«ej e¦«kre e¦«dZejdkr­e d ¦«r˜d
Zej ej e¦«d ¦«Ze e¦«ej ej e¦«d ¦«Z e ekre e ¦«d „Z!Gd
„d¦«Z"d„Z#Gd„d¦«Z$Gd„d¦«Z%Gd„d¦«Z&d„Z'd„Z(d„Z)dS)z8
PEP-302 and PEP-451 importers for frozen applications.
éNcóˆ—tj ||z¦«tj d¦«dS)Nú
)ÚsysÚstderrÚwrite)ÚmsgÚas ú(PyInstaller/loader/pyimod02_importers.pyÚtracer s8€Ý Œ
×Ò˜˜q™Ñ!Ô!Ð!Ý Œ
×Ò˜ÑÔÐÐÐócó—dS)N©)rr s r
r r $s€Ø ˆr cóÞ—ddlm}tj|¦«j}||¦«}tjdd¬¦«}| | |d¦«¦«S)a
Decode bytes representing source code and return the string. Universal newline support is used in the decoding.
Based on CPython's implementation of the same functionality:
https://github.com/python/cpython/blob/3.9/Lib/importlib/_bootstrap_external.py#L679-L688
r)Údetect_encodingNT)ÚdecoderÚ translate)ÚtokenizerÚioÚBytesIOÚreadlineÚIncrementalNewlineDecoderÚdecode)Ú source_bytesrÚsource_bytes_readlineÚencodingÚnewline_decoders r
Ú_decode_sourcer(st€ð)Ð(Ð(Ð(Ð(Ð(ÝœJ |Ñ4Ô4Ô=ÐØˆÐ4Ñ5Ô5€HÝÔ2¸4È4ÐPÑPÔP€OØ × !Ò ! ,×"5Ò"5°h¸q´kÑ"BÔ"BÑ CÔ CÐCr cóˆ—t5t€tt¦«atcddd¦«S#1swxYwYdS)N)Ú_pyz_tree_lockÚ _pyz_treeÚ_build_pyz_prefix_treeÚ pyz_archiverr r
Úget_pyz_toc_treer#@s„€õ
ððÝ Ð Ý.­{Ñ;Ô;ˆIÝððððñôððððððøøøððððððs ˆ"7·;¾;FÚdarwinzContents/FrameworksTÚ Resourcescóf—t¦«}|j ¦«D]ˆ\}}| d¦«}|d}|}|tjtjhvr|D]}| |i¦«}ŒŒZ|dd…D]}| |i¦«}Œd||d<Œ‰|S)Nú.réÿÿÿÿÚ)ÚdictÚtocÚitemsÚsplitÚpyimod01_archiveÚ PYZ_ITEM_PKGÚPYZ_ITEM_NSPKGÚ
setdefault)r"ÚtreeÚ
entry_nameÚ
entry_dataÚname_componentsÚtypecodeÚcurrentÚname_components r
r!r!ksÞ€Ý ‰6Œ6€DØ"-¤/×"7Ò"7Ñ"9Ô"9ð .ð .ш
�JØ$×*Ò*¨3Ñ/Ô/ˆØ˜a”=ˆØˆØ Õ(Ô5Õ7GÔ7VÐWÐ WÐ Wà"1ð
Að
A�Ø!×,Ò,¨^¸RÑ@Ô@��ð
Að#2°#°2°#Ô"6ð
Að
A�Ø!×,Ò,¨^¸RÑ@Ô@��Ø+-ˆG�O BÔ'Ñ (Ð (Ø €Kr cóš—eZdZdZd„Zed„¦«Zd„Zd„Ze d„¦«Z
d„Z d„Z dd
„Z
ejd d …d krd
„Zd„Zd Sd S)ÚPyiFrozenFinderaG
PyInstaller's frozen path entry finder for specific search path.
Per-path instances allow us to properly translate the given module name ("fullname") into full PYZ entry name.
For example, with search path being `sys._MEIPASS`, the module "mypackage.mod" would translate to "mypackage.mod"
in the PYZ archive. However, if search path was `sys._MEIPASS/myotherpackage/_vendored` (for example, if
`myotherpacakge` added this path to `sys.path`), then "mypackage.mod" would need to translate to
"myotherpackage._vendored.mypackage.mod" in the PYZ archive.
có0—|jj›d|j›d�S)Nú(ú))Ú __class__Ú__name__Ú_path)Úselfs r
Ú__repr__zPyiFrozenFinder.__repr__‡s €Ø”.Ô)Ð9Ð9¨D¬JÐ9Ð9Ð9Ð9r cóª—td|›�¦« ||¦«}td¦«|S#t$r}td|›�¦«‚d}~wwxYw)Nz0PyInstaller: running path finder hook for path: zPyInstaller: hook succeededzPyInstaller: hook failed: )r Ú Exception)ÚclsÚpathÚfinderÚes r
Ú path_hookzPyiFrozenFinder.path_hookŠsx€å
ÐIÀÐIÐIÑJÔJÐJð Ø�S˜‘Y”YˆFÝ Ð/Ñ 0Ô 0Ð 0؈MøÝð ð ð Ý Ð2¨qÐ2Ð2Ñ 3Ô 3Ð 3Ø øøøøð øøøs”0°
AºA
Á
Acóâ—||_t|_tD]K} tj ||¦«}n#t$rYŒ0wxYw| d¦«rŒJntd¦«‚tj 
|¦«rtd¦«‚|dkr d|_ dSd  | 
tjj¦«¦«|_ dS)Nz..zIFailed to determine relative path w.r.t. top-level application directory.zonly directories are supportedr'r))r@r"Ú _pyz_archiveÚ_TOP_LEVEL_DIRECTORY_PATHSÚosrFÚrelpathÚ
ValueErrorÚ
startswithÚ ImportErrorÚisfileÚ_pyz_entry_prefixÚjoinr-Úsep)rArFÚtop_level_pathÚ
relative_paths r
Ú__init__zPyiFrozenFinder.__init__•sü€ØˆŒ
Ý'ˆÔõ9ð kð kˆNð
Ý "¤§¢°°nÑ EÔ E�
�
øÝð
ð
ð
Ø�ð
øøøð×'Ò'¨Ñ-Ô-ð
Øà ˆEåÐiÑjÔjÐ jõ
Œ7�>Š>˜$Ñ Ô ð @ÝÐ>Ñ?Ô?Ð ?à ˜CÒ Ð Ø%'ˆDÔ "Ð "Ð "à%(§X¢X¨m×.AÒ.AÅ"Ä'Ä+Ñ.NÔ.NÑ%OÔ%OˆDÔ "Ð "Ð "sž ?¿
A Á A cód—| d¦«d}|jr
|jdz|zS|S)zz
Convert module fullname into PYZ entry name, subject to the prefix implied by this finder's search path.
r'é)Ú
rpartitionrS)rAÚfullnameÚ tail_modules r
Ú_compute_pyz_entry_namez'PyiFrozenFinder._compute_pyz_entry_name¶s@€ð×)Ò)¨#Ñ.Ô.¨qÔ1ˆ à Ô !ð ØÔ)¨CÑ/°+Ñ=Ð =àÐ r cóþ—t|d¦«r|jSd}d|_ttj¦«D]=\}}||jkrd}Œ|sŒ ||j¦«|_n#t$rYŒ:wxYw|jS)aB
Opportunistically create a *fallback finder* using `sys.path_hooks` entries that are located *after* our hook.
The main goal of this exercise is to obtain an instance of python's FileFinder, but in theory any other hook
that comes after ours is eligible to be a fallback.
Having this fallback allows our finder to "cooperate" with python's FileFinder, as if the two were a single
finder, which allows us to work around the python's PathFinder permitting only one finder instance per path
without subclassing FileFinder.
Ú_fallback_finderFNT)Úhasattrr`Ú enumeraterÚ
path_hooksrIr@rQ)rAÚour_hook_foundÚidxÚhooks r
Úfallback_finderzPyiFrozenFinder.fallback_finderÁsµ€õ �4Ð+Ñ ,Ô ,ð )ØÔ(Ð (ðˆà $ˆÔÝ"¥3¤>Ñ2Ô2ð ð ‰IˆC�Ø�t”~Ò%Ð%Ø!%�Øà!ð
Øð
Ø(,¨¨T¬ZÑ(8Ô(8�Ô%Ø�øÝð
ð
ð
Ø�ð
øøøðÔ$Ð$sÁA(Á(
A5Á4A5cóœ—t|d¦«s| ¦«|_|j€dS|j ||¦«S)a@
Attempt to find the spec using fallback finder, which is opportunistically created here. Typically, this would
be python's FileFinder, which can discover specs for on-filesystem modules, such as extension modules and
modules that are collected only as source .py files.
Having this fallback allows our finder to "cooperate" with python's FileFinder, as if the two were a single
finder, which allows us to work around the python's PathFinder permitting only one finder instance per path
without subclassing FileFinder.
r`N)raÚ_get_fallback_finderr`Ú find_spec)rAr\Útargets r
Ú_find_fallback_specz#PyiFrozenFinder._find_fallback_specãsS€õ�tÐ/Ñ0Ô0ð @Ø$(×$=Ò$=Ñ$?Ô$?ˆDÔ !à Ô Ð (Ø�4àÔ$×.Ò.¨x¸Ñ@Ô@Ð@r có|—t|dd¦«}|�&t|d¦«r| ¦«dSdSdS)a<
A method which, when called, should invalidate any internal cache used by the finder. Used by
importlib.invalidate_caches() when invalidating the caches of all finders on sys.meta_path.
https://docs.python.org/3/library/importlib.html#importlib.abc.MetaPathFinder.invalidate_caches
r`NÚinvalidate_caches)Úgetattrrarn)rArgs r
rnz!PyiFrozenFinder.invalidate_caches÷sY€õ" $Ð(:¸DÑAÔAˆØ Ð &Ý�Ð(;Ñ<Ô<ð
4Ø×1Ò1Ñ3Ô3Ð3Ð3Ð3ð 'Ð &ð
4ð
4r Nc óº—t|›d|›d|›�¦«| |¦«}|jj |¦«}|€|t|›d|›d�¦«|j�Lt|›d|j›d�¦«|j ||¦«}t|›d|›d�¦«|St|›d �¦«dS|d
}t|›d |›d |›d
|›�¦«|tjkrjtj
|d¦«}tj  
tj| dtj j¦«¦«g|_|S|tjk}t)||j||¬¦«} | j }
tj
|| ||
¬¦«}d|_|r%tj  |
¦«g|_|S)a»
A method for finding a spec for the specified module. The finder will search for the module only within the
path entry to which it is assigned. If a spec cannot be found, None is returned. When passed in, target is a
module object that the finder may use to make a more educated guess about what spec to return.
https://docs.python.org/3/library/importlib.html#importlib.abc.PathEntryFinder.find_spec
z": find_spec: called with fullname=z , target=Nz
: find_spec: z not found in PYZ...z6: find_spec: attempting resolve using fallback finder r'z,: find_spec: fallback finder returned spec: z.: find_spec: fallback finder is not available.rz: find_spec: found z in PYZ as z , typecode=)Únamer"Úpyz_entry_nameÚ
is_package)rsÚoriginT)r r^rKr+Úgetrgrjr.r0Ú_frozen_importlibÚ
ModuleSpecrMrFrTrÚ_MEIPASSÚreplacerUÚsubmodule_search_locationsr/ÚPyiFrozenLoaderÚ has_locationÚdirname) rAr\rkrrr4Ú
fallback_specr6ÚspecrsÚloaderrts r
rjzPyiFrozenFinder.find_specs/€õ �ÐZÐZ¸ÐZÐZÈhÐZÐZÑ[Ô[Ð[ð×5Ò5°hÑ?Ô?ˆðÔ&Ô*×.Ò.¨~Ñ>Ô>ˆ
Ø Ð õ
�TÐHÐH¨ÐHÐHÐHÑ IÔ IÐ IàÔ#Ð/ݘÐnÐnÐUYÔUiÐnÐnÐnÑoÔoÐoØ $Ô 4× >Ò >¸xÈÑ PÔ P�
ݘÐ]Ð]È=Ð]Ð]Ð]Ñ^Ô^Ð^Ø$Ð$å˜ÐMÐMÐMÑNÔNÐNà�4ð˜a”=ˆÝ
�ÐhÐh¨(ÐhÐhÀÐhÐhÐ^fÐhÐhÑiÔiÐià Õ'Ô6Ò 6Ð 6õ%Ô/°¸$Ñ?Ô?ˆDõ”— ’ �Sœ\¨>×+AÒ+AÀ#ÅrÄwÄ{Ñ+SÔ+SÑTÔTð/ˆDÔ +ð
ˆKàÕ!1Ô!>Ò>ˆ
õ!ØØÔ)Ø)Ø!ð 
ñ
ô
ˆð”ˆõ!Ô+Ø Ø Ø!Øð 
ñ
ô
ˆð!ˆÔð ð HÝ/1¬w¯ª¸vÑ/FÔ/FÐ.GˆDÔ +àˆ r rZ)éé cóX—| |¦«}|€dgfS|j|jpgfS)a×
A legacy method for finding a loader for the specified module. Returns a 2-tuple of (loader, portion) where
portion is a sequence of file system locations contributing to part of a namespace package. The loader may
be None while specifying portion to signify the contribution of the file system locations to a namespace
package. An empty list can be used for portion to signify the loader is not part of a namespace package. If
loader is None and portion is the empty list then no loader or location for a namespace package were found
(i.e. failure to find anything for the module).
Deprecated since python 3.4, removed in 3.12.
N)rjr€rz)rAr\rs r
Ú find_loaderzPyiFrozenFinder.find_loaderZs8€ð—>’> (Ñ+Ô+ˆD؈|ؘR�x�Ø”; Ô ?Ð EÀ2ÐEÐ Er có6—| |¦«\}}|S)z¼
A concrete implementation of Finder.find_module() which is equivalent to self.find_loader(fullname)[0].
Deprecated since python 3.4, removed in 3.12.
)r„)rAr\r€Úportionss r
Ú find_modulezPyiFrozenFinder.find_modulels!€ð $×/Ò/°Ñ9Ô9Ñ ˆF�H؈Mr )N)r?Ú
__module__Ú __qualname__Ú__doc__rBÚ classmethodrIrXr^ÚpropertyrgrlrnrjrÚ version_infor„r‡rr r
r:r:}s€€€€€ððð:ð:ð:ðððñ„[ððPðPðPðB ð ð ðð%ð%ñ„Xð%ðBAðAðAð(
4ð
4ð
4ðNðNðNðNðd Ô˜˜˜Ô˜gÒ%Ð%ð Fð Fð Fð$ ð ð ð ð ð)&Ð%r r:có‡—ˆfd„}|S)Ncól•—|j|krtd|j›d|›�|¬¦«‚‰||g|¢Ri|¤ŽS)Nz loader for z cannot handle ©rq)rqrQ)rArqÚargsÚkwargsÚmethods €r
Ú_check_name_wrapperz(_check_name.<locals>._check_name_wrapper|sYø€Ø Œ9˜Ò Ð ÝÐL¨D¬IÐLÐLÀdÐLÐLÐSWÐXÑXÔXÐ X؈v�d˜DÐ2 4Ð2Ð2Ð2¨6Ð2Ð2Ð2r r)r“r”s` r
Ú _check_namer•{s$ø€ð3ð3ð3ð3ð3ð
Ðr có°—eZdZdZd„Zd„Zd„Z ed„¦«Zed„¦«Z ed„¦«Z
ed „¦«Z ed
„¦«Z d „Z
ed „¦«Zd
S)r{aº
PyInstaller's frozen loader for modules in the PYZ archive, which are discovered by PyiFrozenFinder.
Since this loader is instantiated only from PyiFrozenFinder and since each loader instance is tied to a specific
module, the fact that the loader was instantiated serves as the proof that the module exists in the PYZ archive.
Hence, we can avoid any additional validation in the implementation of the loader's methods.
cóŽ—||_||_||_|rOtj t j| dtjj ¦«d¦«}nPtj t j| dtjj ¦«dz¦«}||_
||_dS)Nr'ú __init__.pyú.py) rKÚ_pyz_entry_nameÚ _is_packagerMrFrTrrxryrUrq)rArqr"rrrsÚ module_files r
rXzPyiFrozenLoader.__init__Œs¢€ð(ˆÔØ-ˆÔØ%ˆÔð ð gÝœ'Ÿ,š,¥s¤|°^×5KÒ5KÈCÕQSÔQXÔQ\Ñ5]Ô5]Ð_lÑmÔmˆKˆKåœ'Ÿ,š,¥s¤|°^×5KÒ5KÈCÕQSÔQXÔQ\Ñ5]Ô5]Ð`eÑ5eÑfÔfˆKð
ˆŒ ؈Œ ˆ ˆ r có—dS)a 
A method that returns the module object to use when importing a module. This method may return None, indicating
that default module creation semantics should take place.
https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.create_module
Nr)rArs r
Ú
create_modulezPyiFrozenLoader.create_module¬s €ðˆtr cóð—|j}| |j¦«}|€td|j›d�¦«‚t |d¦«sJ‚|j� |j|_t||j¦«dS)a[
A method that executes the module in its own namespace when a module is imported or reloaded. The module
should already be initialized when exec_module() is called. When this method exists, create_module()
must be defined.
https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.exec_module
Nz Failed to retrieve bytecode for ú!Ú__file__) Ú__spec__Úget_coderqÚ RuntimeErrorrarzÚ__path__ÚexecÚ__dict__)rAÚmodulerÚbytecodes r
Ú exec_modulezPyiFrozenLoader.exec_moduleµs…€ðŒˆØ—=’= ¤Ñ+Ô+ˆØ Ð ÝÐPÀ$Ä)ÐPÐPÐPÑQÔQÐ Qõ�v˜zÑ*Ô*Ð*Ð*Ð*ð Ô *Ð 6Ø"Ô=ˆFŒOå ˆX�v”Ñ'Ô'Ð'Ð'Ð'r Tcó:—ddlm}| ||¦«S)aK
A legacy method for loading a module. If the module cannot be loaded, ImportError is raised, otherwise the
loaded module is returned.
Deprecated since python 3.4, slated for removal in 3.12 (but still present in python's own FileLoader in
both v3.12.4 and v3.13.0rc1).
rN)Úimportlib._bootstrapÚ
_bootstrapÚ_load_module_shim)rAr\r­s r
Ú load_modulezPyiFrozenLoader.load_moduleÐs,€ð
6Ð 5Ð 5Ð 5Ð 5Ð 5Ø×/Ò/°°hÑ?Ô?Ð ?r có—|jS)a 
A method that is to return the value of __file__ for the specified module. If no path is available, ImportError
is raised.
If source code is available, then the method should return the path to the source file, regardless of whether a
bytecode was used to load the module.
https://docs.python.org/3/library/importlib.html#importlib.abc.ExecutionLoader.get_filename
©rF)rAr\s r
Ú get_filenamezPyiFrozenLoader.get_filenameàs €ðŒyÐr có@—|j |j¦«S)aL
Return the code object for a module, or None if the module does not have a code object (as would be the case,
for example, for a built-in module). Raise an ImportError if loader cannot find the requested module.
https://docs.python.org/3/library/importlib.html#importlib.abc.InspectLoader.get_code
)rKÚextractrš)rAr\s r
r£zPyiFrozenLoader.get_codeïs€ðÔ ×(Ò(¨Ô)=Ñ>Ô>Ð>r cóÌ—|j} t|d¦«5}| ¦«}ddd¦«n #1swxYwYt|¦«S#t$rYnwxYwdS)a«
A method to return the source of a module. It is returned as a text string using universal newlines, translating
all recognized line separators into '
' characters. Returns None if no source is available (e.g. a built-in
module). Raises ImportError if the loader cannot find the module specified.
https://docs.python.org/3/library/importlib.html#importlib.abc.InspectLoader.get_source
ÚrbN)rFÚopenÚreadrÚFileNotFoundError)rAr\ÚfilenameÚfprs r
Ú
get_sourcezPyiFrozenLoader.get_sourceùs´€ð”9ˆð å�h Ñ%Ô%ð
)¨Ø!Ÿwšw™yœy� ð
)ð
)ð
)ñ
)ô
)ð
)ð
)ð
)ð
)ð
)ð
)øøøð
)ð
)ð
)ð
)å! ,Ñ/Ô/Ð /øÝ ð ð ð Ø ˆDð øøøðˆts.‰A™:® Aº>¾AÁ>ÁAÁ
A!Á A!có—|jS)a 
A method to return a true value if the module is a package, a false value otherwise. ImportError is raised if
the loader cannot find the module.
https://docs.python.org/3/library/importlib.html#importlib.abc.InspectLoader.is_package
)r›)rAr\s r
rszPyiFrozenLoader.is_packages
€ðÔÐr có~—t|d¦«5}| ¦«cddd¦«S#1swxYwYdS)u

A method to return the bytes for the data located at path. Loaders that have a file-like storage back-end that
allows storing arbitrary data can implement this abstract method to give direct access to the data stored.
OSError is to be raised if the path cannot be found. The path is expected to be constructed using a module’s
__file__ attribute or an item from a package’s __path__.
https://docs.python.org/3/library/importlib.html#importlib.abc.ResourceLoader.get_data
r¶N)r·r¸)rArFr»s r
Úget_datazPyiFrozenLoader.get_datas€€õ�$˜Ñ
Ô
ð  Ø—7’7‘9”9ð ð ð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð ð s ‘2²6¹6có —t|¦«S)zO
Return resource reader compatible with `importlib.resources`.
)ÚPyiFrozenResourceReader)rAr\s r
Úget_resource_readerz#PyiFrozenLoader.get_resource_reader,s€õ
' tÑ,Ô,Ð,r N)r?rˆr‰rŠrXržrªr•r¯r²r£r¼rsr¿rÂrr r
r{r{„s€€€€€ððð ð ð ð@ððð(ð(ð(ð2@à ð @ð @ñ
Œð @ðð
ð
ñ„[ð
ðð?ð?ñ„[ð?ðððñ„[ðð.ð ð ñ„[ð ð ð ð ðð-ð-ñ„[ð-ð-ð-r r{có6—eZdZdZd„Zd„Zd„Zd„Zd„Zd„Z dS) rÁa®
Resource reader for importlib.resources / importlib_resources support.
Supports only on-disk resources, which should cover the typical use cases, i.e., the access to data files;
PyInstaller collects data files onto filesystem, and as of v6.0.0, the embedded PYZ archive is guaranteed
to contain only .pyc modules.