֦i r d dl mZ d dlmZ ddlmZ G d d Z G d d Zdd Z G d
d Z d Z
y
) )suppress)
TextIOWrapper )abcc " e Zd ZdZd fdZd Zy)SpecLoaderAdapterz>
Adapt a package spec to adapt the underlying loader.
c | j S N)loaderspecs 6/usr/lib64/python3.12/importlib/resources/_adapters.pyzSpecLoaderAdapter. s $++ c , || _ || | _ y r
)r
r )selfr
adapters r __init__zSpecLoaderAdapter.__init__ s dmr c . t | j | S r
)getattrr
r names r __getattr__zSpecLoaderAdapter.__getattr__ s tyy$''r N)__name__
__module____qualname____doc__r r r r r r s &> $(r r c e Zd ZdZd Zd Zy)TraversableResourcesLoaderz9
Adapt a loader to provide TraversableResources.
c || _ y r
r r r
s r r z#TraversableResourcesLoader.__init__ r c H t | j j S r
)CompatibilityFilesr
_nativer s r get_resource_readerz.TraversableResourcesLoader.get_resource_reader s !$)),4466r N)r r r r r r' r r r r r s 7r r c V |dk( rt | g|i |S |dk( r| S t d| d )NrrbzInvalid mode value 'z"', only 'r' and 'rb' are supported)r
ValueError)filemodeargskwargss r _io_wrapperr0 s@ s{T3D3F33
+D61ST
UUr c e Zd ZdZ G d dej
Z G d dej
Z G d dej
Zd Z e
d Zd
Zd Z
d Zy
)r% zj
Adapter for an existing or non-existent resource reader
to provide a compatibility .files().
c D e Zd ZdZd Zd Zd ZeZd Ze d Z
d dZy)
CompatibilityFiles.SpecPathzk
Path tied to a module spec.
Can be read and exposes the resource reader children.
c || _ || _ y r
)_spec_reader)r r
readers r r z$CompatibilityFiles.SpecPath.__init__4 s DJ!DLr c j st d S t fd j j D S )Nr c 3 ^ K | ]$ }t j j | & y wr
)r% ChildPathr6 ).0pathr s r z6CompatibilityFiles.SpecPath.iterdir..; s* 3D #,,T\\4@3s *-)r6 itercontentsr s `r iterdirz#CompatibilityFiles.SpecPath.iterdir8 s: <<Bx LL113
r c yNFr r@ s r is_filez#CompatibilityFiles.SpecPath.is_file@ r c | j st j | S t j | j | S r
)r6 r%
OrphanPathr: r others r joinpathz$CompatibilityFiles.SpecPath.joinpathE s1 <<)44U;;%//eDDr c . | j j S r
)r5 r r@ s r r z CompatibilityFiles.SpecPath.nameJ s ::??"r c T t | j j d |g|i |S r
)r0 r6
open_resourcer r- r. r/ s r openz CompatibilityFiles.SpecPath.openN s) t||99$?WWPVWWr Nr) r r r r r rA rD is_dirrJ propertyr rO r r r SpecPathr3 . s=
" E
#
# Xr rT c F e Zd ZdZd Zd Zd Zd Zd Ze d Z
d
dZy )CompatibilityFiles.ChildPathzw
Path tied to a resource reader child.
Can be read but doesn't expose any meaningful children.
c || _ || _ y r
)r6 _name)r r7 r s r r z%CompatibilityFiles.ChildPath.__init__W s !DLDJr c t d S Nr r> r@ s r rA z$CompatibilityFiles.ChildPath.iterdir[ 8Or c L | j j | j S r
)r6 is_resourcer r@ s r rD z$CompatibilityFiles.ChildPath.is_file^ s <<++DII66r c $ | j S r
)rD r@ s r rR z#CompatibilityFiles.ChildPath.is_dira s ||~%%r c B t j | j | S r
)r% rG r rH s r rJ z%CompatibilityFiles.ChildPath.joinpathd s %00EBBr c | j S r
)rX r@ s r r z!CompatibilityFiles.ChildPath.nameg s ::r c h t | j j | j |g|i |S r
)r0 r6 rM r rN s r rO z!CompatibilityFiles.ChildPath.openk s7 **4995t>BFL
r NrP rQ r r r r: rV Q s:
7 & C
r r: c D e Zd ZdZd Zd Zd ZeZd Ze d Z
d dZy)
CompatibilityFiles.OrphanPathz
Orphan path, not tied to a module spec or resource reader.
Can't be read and doesn't expose any meaningful children.
c D t | dk rt d || _ y )Nr z/Need at least one path part to construct a path)lenr+ _path)r
path_partss r r z&CompatibilityFiles.OrphanPath.__init__v