File: //usr/lib64/python3.6/__pycache__/pkgutil.cpython-36.pyc
3
\CS @ sx d Z ddlmZ ddlmZ ddlZddlZddlZddl Z ddl
Z ddlZddlm
Z
ddlZdddd d
ddd
ddddgZeddZde_ dd Zdd Zd+dd
Zd,ddZed-ddZd.ddZejejje dd ZG d d
d
ZG d!d dZy.ddlZdd"lmZ d/d#d$Zejee W n e k
r@ Y nX d%d Z!d0d&dZ"d'd Z#d(d Z$d)d Z%d*d Z&dS )1zUtilities to support packages. )
namedtuple)singledispatchN)
ModuleTypeget_importeriter_importers
get_loaderfind_loader
walk_packagesiter_modulesget_dataImpImporter ImpLoader read_codeextend_path
ModuleInfozmodule_finder name ispkgz.A namedtuple with minimal info about a module.c C sL y
| j }W n4 tk
r> | j|}|dkr0dS tjj||S X ||S dS )z'Return the finder-specific module spec.N) find_specAttributeErrorfind_module importlibutilspec_from_loader)findernamer loader r /usr/lib64/python3.6/pkgutil.py _get_spec s
r c C s6 dd l }| jd}|tjjkr"d S | jd |j| S )Nr )marshalreadr r MAGIC_NUMBERload)streamr magicr r r r ( s
c
# s i fdd xt | |D ]}|V |jryt|j W nN tk
r\ |dk rX||j Y q tk
r |dk r~||j n Y qX ttj|j ddpg } fdd| D } t | |jd |E dH qW dS )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 | |krdS d|| <