a
´iÔ^ ã @ s” d Z ddlmZ ddlmZ ddlZddlZddlZddl Z ddl
Z ddlZddlZddl
mZ ddlZg d¢ZeddƒZd e_ d
d„ Zdd
„ Zd2dd„Zd3dd„Zed4dd„ƒZd5dd„Ze ejje¡ dd„ ZG dd„ dƒZG dd„ dƒZz.ddlZddlmZ d6dd„Z e ee ¡ W n e!�y2 Y n0 d d!„ Z"d7d"d#„Z#d$d%„ Z$d&d'„ Z%d(d)„ Z&d*d+„ Z'd,Z(e )d-e(› d.e(› d/�ej*¡Z+[(d0d1„ Z,dS )8zUtilities to support packages.é )Ú
namedtuple)ÚsingledispatchN)Ú
ModuleType)Úget_importerÚiter_importersÚ
get_loaderÚfind_loaderÚ
walk_packagesÚiter_modulesÚget_dataÚImpImporterÚ ImpLoaderÚ read_codeÚextend_pathÚ
ModuleInfor zmodule_finder name ispkgz.A namedtuple with minimal info about a module.c C sP z
| j }W n8 tyB | |¡}|du r0Y dS tj ||¡ Y S 0 ||ƒS dS )z'Return the finder-specific module spec.N)Ú find_specÚAttributeErrorÚfind_moduleÚ importlibÚutilÚspec_from_loader)ÚfinderÚnamer Úloader© r ú/usr/lib64/python3.9/pkgutil.pyÚ _get_spec s
r c C s6 dd l }| d¡}|tjjkr"d S | d¡ | | ¡S )Nr é é )ÚmarshalÚreadr r ÚMAGIC_NUMBERÚload)Ústreamr Úmagicr r r r ) s
r Ú c # sÈ i fdd„‰ t | |ƒD ]¬}|V |jrzt|jƒ W nJ tyX |durT||jƒ Y q ty~ |durx||jƒ n‚ Y q0 ttj|j ddƒp–g } ‡ fdd„| D ƒ} t | |jd |ƒE dH qdS )a« Yields ModuleInfo for all modules recursively
on path, or, if path is None, all accessible modules.
'path' should be either None or a list of paths to look for
modules in.
'prefix' is a string to output on the front of every module name
on output.
Note that this function must import all *packages* (NOT all
modules!) on the given path, in order to access the __path__
attribute to find submodules.
'onerror' is a function which gets called with one argument (the
name of the package which was being imported) if any exception
occurs while trying to import a package. If no onerror function is
supplied, ImportErrors are caught and ignored, while all other
exceptions are propagated, terminating the search.
Examples:
# list all modules python can access
walk_packages()
# list all submodules of ctypes
walk_packages(ctypes.__path__, ctypes.__name__+'.')
c S s | |v rdS d|| <