/home/lnzliplg/www/macholib.tar
__pycache__/dyld.cpython-38.pyc000064400000011074151730364200012344 0ustar00U

e5d��@s dZddlZddlmZddlmZddlTzddlmZWne	k
rXdd�ZYnXd	d
ddgZ
ej�d
�dddgZ
ej�d�dddgZdd�Zd.dd�Zd/dd�Zd0dd�Zd1dd�Zd2dd �Zd3d!d"�Zd4d#d$�Zd5d%d&�Zd6d'd(�Zd7d)d	�Zd8d*d
�Zd+d,�Zed-k�re�dS)9z
dyld emulation
�N)�framework_info)�
dylib_info)�*)� _dyld_shared_cache_contains_pathcGst�dS)N)�NotImplementedError)�args�r�,/usr/lib64/python3.8/ctypes/macholib/dyld.pyrsr�	dyld_find�framework_findrrz~/Library/Frameworksz/Library/Frameworksz/Network/Library/Frameworksz/System/Library/Frameworksz~/libz/usr/local/libz/libz/usr/libcCs.|dkrtj}|�|�}|dkr$gS|�d�S)N�:)�os�environ�get�split)�env�varZrvalrrr	�dyld_env$s
rcCs|dkrtj}|�d�S)NZDYLD_IMAGE_SUFFIX)r
rr�rrrr	�dyld_image_suffix,srcCs
t|d�S)NZDYLD_FRAMEWORK_PATH�rrrrr	�dyld_framework_path1srcCs
t|d�S)NZDYLD_LIBRARY_PATHrrrrr	�dyld_library_path4srcCs
t|d�S)NZDYLD_FALLBACK_FRAMEWORK_PATHrrrrr	�dyld_fallback_framework_path7srcCs
t|d�S)NZDYLD_FALLBACK_LIBRARY_PATHrrrrr	�dyld_fallback_library_path:srcCs(t|�}|dkr|S||fdd�}|�S)z>For a potential path iterator, add DYLD_IMAGE_SUFFIX semanticsNcssF|D]<}|�d�r0|dtd��|dVn
||V|VqdS)Nz.dylib)�endswith�len)�iterator�suffix�pathrrr	�_injectBs


z)dyld_image_suffix_search.<locals>._inject)r)rrrr rrr	�dyld_image_suffix_search=s
r!ccs\t|�}|dk	r2t|�D]}tj�||d�Vqt|�D]}tj�|tj�|��Vq:dS�N�name)rrr
r�joinr�basename)r#r�	frameworkrrrr	�dyld_override_searchKsr'ccs2|�d�r.|dk	r.tj�||td�d��VdS)Nz@executable_path/)�
startswithr
rr$r)r#�executable_pathrrr	�dyld_executable_path_search\sr*ccs�|Vt|�}|dk	r<t|�}|D]}tj�||d�Vq"t|�}|D]}tj�|tj�|��VqH|dk	r�|s�tD]}tj�||d�Vqv|s�tD]}tj�|tj�|��Vq�dSr")	rrr
rr$rr%�DEFAULT_FRAMEWORK_FALLBACK�DEFAULT_LIBRARY_FALLBACK)r#rr&Zfallback_framework_pathrZfallback_library_pathrrr	�dyld_default_searchcsr-c	Cs|ttt||�t||�t||��|�D]D}tj�|�r<|Szt|�rP|WSWq$t	k
rfYq$Xq$t
d|f��dS)z:
    Find a library or framework using dyld semantics
    zdylib %s could not be foundN)r!�chainr'r*r-r
r�isfilerr�
ValueError)r#r)rrrrr	r
ys��c
Cs�d}zt|||d�WStk
r:}z|}W5d}~XYnX|�d�}|dkr^t|�}|d7}tj�|tj�|d|���}z2zt|||d�WW�Stk
r�|�YnXW5d}XdS)z�
    Find a framework using dyld semantics in a very loose manner.

    Will take input such as:
        Python
        Python.framework
        Python.framework/Versions/Current
    N)r)rz
.framework���)r
r0�rfindrr
rr$r%)�fnr)r�error�eZ
fmwk_indexrrr	r�s	
cCs(i}td�dkst�td�dks$t�dS)NzlibSystem.dylibz/usr/lib/libSystem.dylibzSystem.framework/Systemz2/System/Library/Frameworks/System.framework/System)r
�AssertionErrorrrrr	�test_dyld_find�sr7�__main__)N)N)N)N)N)N)N)N)N)NN)NN)�__doc__r
Zctypes.macholib.frameworkrZctypes.macholib.dylibr�	itertoolsZ_ctypesr�ImportError�__all__r�
expanduserr+r,rrrrrrr!r'r*r-r
rr7�__name__rrrr	�<module>sL�
�
�











__pycache__/framework.cpython-38.opt-1.pyc000064400000003107151730364200014342 0ustar00U

e5d��@s>dZddlZdgZe�d�Zdd�Zdd�Zedkr:e�dS)	z%
Generic framework path manipulation
�N�framework_infoz�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+).framework/
    (?:Versions/(?P<version>[^/]+)/)?
    (?P=shortname)
    (?:_(?P<suffix>[^_]+))?
)$
cCst�|�}|sdS|��S)a}
    A framework name can take one of the following four forms:
        Location/Name.framework/Versions/SomeVersion/Name_Suffix
        Location/Name.framework/Versions/SomeVersion/Name
        Location/Name.framework/Name_Suffix
        Location/Name.framework/Name

    returns None if not found, or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.framework/Versions/SomeVersion/Name_Suffix',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present
    N)�STRICT_FRAMEWORK_RE�match�	groupdict)�filenameZis_framework�r�1/usr/lib64/python3.8/ctypes/macholib/framework.pyrs
cCsddd�}dS)NcSst|||||d�S)N��location�nameZ	shortname�version�suffix)�dictr	rrr�d-s�ztest_framework_info.<locals>.d)NNNNNr)rrrr�test_framework_info,s
r�__main__)�__doc__�re�__all__�compilerrr�__name__rrrr�<module>s

__pycache__/framework.cpython-38.opt-2.pyc000064400000001617151730364200014347 0ustar00U

e5d��@s:ddlZdgZe�d�Zdd�Zdd�Zedkr6e�dS)�N�framework_infoz�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+).framework/
    (?:Versions/(?P<version>[^/]+)/)?
    (?P=shortname)
    (?:_(?P<suffix>[^_]+))?
)$
cCst�|�}|sdS|��S)N)�STRICT_FRAMEWORK_RE�match�	groupdict)�filenameZis_framework�r�1/usr/lib64/python3.8/ctypes/macholib/framework.pyrs
cCsddd�}dS)NcSst|||||d�S)N��location�nameZ	shortname�version�suffix)�dictr	rrr�d-s�ztest_framework_info.<locals>.d)NNNNNr)rrrr�test_framework_info,s
r�__main__)�re�__all__�compilerrr�__name__rrrr�<module>s

__pycache__/dyld.cpython-38.opt-1.pyc000064400000010622151730364210013302 0ustar00U

e5d��@s dZddlZddlmZddlmZddlTzddlmZWne	k
rXdd�ZYnXd	d
ddgZ
ej�d
�dddgZ
ej�d�dddgZdd�Zd.dd�Zd/dd�Zd0dd�Zd1dd�Zd2dd �Zd3d!d"�Zd4d#d$�Zd5d%d&�Zd6d'd(�Zd7d)d	�Zd8d*d
�Zd+d,�Zed-k�re�dS)9z
dyld emulation
�N)�framework_info)�
dylib_info)�*)� _dyld_shared_cache_contains_pathcGst�dS�N)�NotImplementedError)�args�r	�,/usr/lib64/python3.8/ctypes/macholib/dyld.pyrsr�	dyld_find�framework_findrrz~/Library/Frameworksz/Library/Frameworksz/Network/Library/Frameworksz/System/Library/Frameworksz~/libz/usr/local/libz/libz/usr/libcCs.|dkrtj}|�|�}|dkr$gS|�d�S)N�:)�os�environ�get�split)�env�varZrvalr	r	r
�dyld_env$s
rcCs|dkrtj}|�d�S)NZDYLD_IMAGE_SUFFIX)rrr�rr	r	r
�dyld_image_suffix,srcCs
t|d�S)NZDYLD_FRAMEWORK_PATH�rrr	r	r
�dyld_framework_path1srcCs
t|d�S)NZDYLD_LIBRARY_PATHrrr	r	r
�dyld_library_path4srcCs
t|d�S)NZDYLD_FALLBACK_FRAMEWORK_PATHrrr	r	r
�dyld_fallback_framework_path7srcCs
t|d�S)NZDYLD_FALLBACK_LIBRARY_PATHrrr	r	r
�dyld_fallback_library_path:srcCs(t|�}|dkr|S||fdd�}|�S)z>For a potential path iterator, add DYLD_IMAGE_SUFFIX semanticsNcssF|D]<}|�d�r0|dtd��|dVn
||V|VqdS)Nz.dylib)�endswith�len)�iterator�suffix�pathr	r	r
�_injectBs


z)dyld_image_suffix_search.<locals>._inject)r)rrrr!r	r	r
�dyld_image_suffix_search=s
r"ccs\t|�}|dk	r2t|�D]}tj�||d�Vqt|�D]}tj�|tj�|��Vq:dS�N�name)rrrr �joinr�basename)r$r�	frameworkr r	r	r
�dyld_override_searchKsr(ccs2|�d�r.|dk	r.tj�||td�d��VdS)Nz@executable_path/)�
startswithrr r%r)r$�executable_pathr	r	r
�dyld_executable_path_search\sr+ccs�|Vt|�}|dk	r<t|�}|D]}tj�||d�Vq"t|�}|D]}tj�|tj�|��VqH|dk	r�|s�tD]}tj�||d�Vqv|s�tD]}tj�|tj�|��Vq�dSr#)	rrrr r%rr&�DEFAULT_FRAMEWORK_FALLBACK�DEFAULT_LIBRARY_FALLBACK)r$rr'Zfallback_framework_pathr Zfallback_library_pathr	r	r
�dyld_default_searchcsr.c	Cs|ttt||�t||�t||��|�D]D}tj�|�r<|Szt|�rP|WSWq$t	k
rfYq$Xq$t
d|f��dS)z:
    Find a library or framework using dyld semantics
    zdylib %s could not be foundN)r"�chainr(r+r.rr �isfilerr�
ValueError)r$r*rr r	r	r
rys��c
Cs�d}zt|||d�WStk
r:}z|}W5d}~XYnX|�d�}|dkr^t|�}|d7}tj�|tj�|d|���}z2zt|||d�WW�Stk
r�|�YnXW5d}XdS)z�
    Find a framework using dyld semantics in a very loose manner.

    Will take input such as:
        Python
        Python.framework
        Python.framework/Versions/Current
    N)r*rz
.framework���)rr1�rfindrrr r%r&)�fnr*r�error�eZ
fmwk_indexr	r	r
r�s	
cCsi}dSrr	rr	r	r
�test_dyld_find�sr7�__main__)N)N)N)N)N)N)N)N)N)NN)NN)�__doc__rZctypes.macholib.frameworkrZctypes.macholib.dylibr�	itertoolsZ_ctypesr�ImportError�__all__r �
expanduserr,r-rrrrrrr"r(r+r.rrr7�__name__r	r	r	r
�<module>sL�
�
�











__pycache__/__init__.cpython-38.opt-2.pyc000064400000000236151730364210014106 0ustar00U

e5d��@sdZdS)z1.0N)�__version__�rr�0/usr/lib64/python3.8/ctypes/macholib/__init__.py�<module>	�__pycache__/dylib.cpython-38.pyc000064400000003576151730364210012524 0ustar00U

e5d$�@s>dZddlZdgZe�d�Zdd�Zdd�Zedkr:e�dS)	z!
Generic dylib path manipulation
�N�
dylib_infoz�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+?)
    (?:\.(?P<version>[^._]+))?
    (?:_(?P<suffix>[^._]+))?
    \.dylib$
)
cCst�|�}|sdS|��S)a1
    A dylib name can take one of the following four forms:
        Location/Name.SomeVersion_Suffix.dylib
        Location/Name.SomeVersion.dylib
        Location/Name_Suffix.dylib
        Location/Name.dylib

    returns None if not found or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.SomeVersion_Suffix.dylib',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present.
    N)�DYLIB_RE�match�	groupdict)�filenameZis_dylib�r�-/usr/lib64/python3.8/ctypes/macholib/dylib.pyrs
cCs�ddd�}td�dkst�td�dks*t�td�|ddd�ksBt�td	�|dd
ddd�ks^t�td
�|dddd�ksxt�td�|dddd�ks�t�td�|ddddd�ks�t�dS)NcSst|||||d�S)N��location�nameZ	shortname�version�suffix)�dictr	rrr�d.s�ztest_dylib_info.<locals>.dzcompletely/invalidzcompletely/invalide_debugzP/Foo.dylib�Pz	Foo.dylibZFoozP/Foo_debug.dylibzFoo_debug.dylib�debug)r
z
P/Foo.A.dylibzFoo.A.dylib�AzP/Foo_debug.A.dylibzFoo_debug.A.dylibZ	Foo_debugzP/Foo.A_debug.dylibzFoo.A_debug.dylib)NNNNN)r�AssertionError)rrrr�test_dylib_info-s
r�__main__)�__doc__�re�__all__�compilerrr�__name__rrrr�<module>s

__pycache__/dylib.cpython-38.opt-2.pyc000064400000001531151730364210013451 0ustar00U

e5d$�@s:ddlZdgZe�d�Zdd�Zdd�Zedkr6e�dS)�N�
dylib_infoz�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+?)
    (?:\.(?P<version>[^._]+))?
    (?:_(?P<suffix>[^._]+))?
    \.dylib$
)
cCst�|�}|sdS|��S)N)�DYLIB_RE�match�	groupdict)�filenameZis_dylib�r�-/usr/lib64/python3.8/ctypes/macholib/dylib.pyrs
cCsddd�}dS)NcSst|||||d�S)N��location�nameZ	shortname�version�suffix)�dictr	rrr�d.s�ztest_dylib_info.<locals>.d)NNNNNr)rrrr�test_dylib_info-s
r�__main__)�re�__all__�compilerrr�__name__rrrr�<module>s

__pycache__/__init__.cpython-38.pyc000064400000000455151730364210013151 0ustar00U

e5d��@sdZdZdS)z~
Enough Mach-O to make your head spin.

See the relevant header files in /usr/include/mach-o

And also Apple's documentation.
z1.0N)�__doc__�__version__�rr�0/usr/lib64/python3.8/ctypes/macholib/__init__.py�<module>s__pycache__/framework.cpython-38.pyc000064400000004226151730364210013407 0ustar00U

e5d��@s>dZddlZdgZe�d�Zdd�Zdd�Zedkr:e�dS)	z%
Generic framework path manipulation
�N�framework_infoz�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+).framework/
    (?:Versions/(?P<version>[^/]+)/)?
    (?P=shortname)
    (?:_(?P<suffix>[^_]+))?
)$
cCst�|�}|sdS|��S)a}
    A framework name can take one of the following four forms:
        Location/Name.framework/Versions/SomeVersion/Name_Suffix
        Location/Name.framework/Versions/SomeVersion/Name
        Location/Name.framework/Name_Suffix
        Location/Name.framework/Name

    returns None if not found, or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.framework/Versions/SomeVersion/Name_Suffix',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present
    N)�STRICT_FRAMEWORK_RE�match�	groupdict)�filenameZis_framework�r�1/usr/lib64/python3.8/ctypes/macholib/framework.pyrs
cCs�ddd�}td�dkst�td�dks*t�td�dks:t�td�dksJt�td�|dd	d
�ksbt�td�|ddd
d
d�ks~t�td�dks�t�td�dks�t�td�|ddd
d�ks�t�td�|ddd
dd
�ks�t�dS)NcSst|||||d�S)N��location�nameZ	shortname�version�suffix)�dictr	rrr�d-s�ztest_framework_info.<locals>.dzcompletely/invalidzcompletely/invalid/_debugz
P/F.frameworkzP/F.framework/_debugzP/F.framework/F�Pz
F.framework/F�FzP/F.framework/F_debugzF.framework/F_debug�debug)r
zP/F.framework/VersionszP/F.framework/Versions/AzP/F.framework/Versions/A/FzF.framework/Versions/A/F�Az P/F.framework/Versions/A/F_debugzF.framework/Versions/A/F_debug)NNNNN)r�AssertionError)rrrr�test_framework_info,s
r�__main__)�__doc__�re�__all__�compilerrr�__name__rrrr�<module>s

__pycache__/__init__.cpython-38.opt-1.pyc000064400000000455151730364220014111 0ustar00U

e5d��@sdZdZdS)z~
Enough Mach-O to make your head spin.

See the relevant header files in /usr/include/mach-o

And also Apple's documentation.
z1.0N)�__doc__�__version__�rr�0/usr/lib64/python3.8/ctypes/macholib/__init__.py�<module>s__pycache__/dylib.cpython-38.opt-1.pyc000064400000002701151730364220013451 0ustar00U

e5d$�@s>dZddlZdgZe�d�Zdd�Zdd�Zedkr:e�dS)	z!
Generic dylib path manipulation
�N�
dylib_infoz�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+?)
    (?:\.(?P<version>[^._]+))?
    (?:_(?P<suffix>[^._]+))?
    \.dylib$
)
cCst�|�}|sdS|��S)a1
    A dylib name can take one of the following four forms:
        Location/Name.SomeVersion_Suffix.dylib
        Location/Name.SomeVersion.dylib
        Location/Name_Suffix.dylib
        Location/Name.dylib

    returns None if not found or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.SomeVersion_Suffix.dylib',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present.
    N)�DYLIB_RE�match�	groupdict)�filenameZis_dylib�r�-/usr/lib64/python3.8/ctypes/macholib/dylib.pyrs
cCsddd�}dS)NcSst|||||d�S)N��location�nameZ	shortname�version�suffix)�dictr	rrr�d.s�ztest_dylib_info.<locals>.d)NNNNNr)rrrr�test_dylib_info-s
r�__main__)�__doc__�re�__all__�compilerrr�__name__rrrr�<module>s

__pycache__/dyld.cpython-38.opt-2.pyc000064400000010074151730364220013305 0ustar00U

e5d��@sddlZddlmZddlmZddlTzddlmZWnek
rTdd�ZYnXdd	d
dgZ	ej
�d�d
ddgZej
�d�dddgZ
dd�Zd-dd�Zd.dd�Zd/dd�Zd0dd�Zd1dd�Zd2d d!�Zd3d"d#�Zd4d$d%�Zd5d&d'�Zd6d(d�Zd7d)d	�Zd*d+�Zed,k�re�dS)8�N)�framework_info)�
dylib_info)�*)� _dyld_shared_cache_contains_pathcGst�dS�N)�NotImplementedError)�args�r	�,/usr/lib64/python3.8/ctypes/macholib/dyld.pyrsr�	dyld_find�framework_findrrz~/Library/Frameworksz/Library/Frameworksz/Network/Library/Frameworksz/System/Library/Frameworksz~/libz/usr/local/libz/libz/usr/libcCs.|dkrtj}|�|�}|dkr$gS|�d�S)N�:)�os�environ�get�split)�env�varZrvalr	r	r
�dyld_env$s
rcCs|dkrtj}|�d�S)NZDYLD_IMAGE_SUFFIX)rrr�rr	r	r
�dyld_image_suffix,srcCs
t|d�S)NZDYLD_FRAMEWORK_PATH�rrr	r	r
�dyld_framework_path1srcCs
t|d�S)NZDYLD_LIBRARY_PATHrrr	r	r
�dyld_library_path4srcCs
t|d�S)NZDYLD_FALLBACK_FRAMEWORK_PATHrrr	r	r
�dyld_fallback_framework_path7srcCs
t|d�S)NZDYLD_FALLBACK_LIBRARY_PATHrrr	r	r
�dyld_fallback_library_path:srcCs(t|�}|dkr|S||fdd�}|�S)NcssF|D]<}|�d�r0|dtd��|dVn
||V|VqdS)Nz.dylib)�endswith�len)�iterator�suffix�pathr	r	r
�_injectBs


z)dyld_image_suffix_search.<locals>._inject)r)rrrr!r	r	r
�dyld_image_suffix_search=s
r"ccs\t|�}|dk	r2t|�D]}tj�||d�Vqt|�D]}tj�|tj�|��Vq:dS�N�name)rrrr �joinr�basename)r$r�	frameworkr r	r	r
�dyld_override_searchKsr(ccs2|�d�r.|dk	r.tj�||td�d��VdS)Nz@executable_path/)�
startswithrr r%r)r$�executable_pathr	r	r
�dyld_executable_path_search\sr+ccs�|Vt|�}|dk	r<t|�}|D]}tj�||d�Vq"t|�}|D]}tj�|tj�|��VqH|dk	r�|s�tD]}tj�||d�Vqv|s�tD]}tj�|tj�|��Vq�dSr#)	rrrr r%rr&�DEFAULT_FRAMEWORK_FALLBACK�DEFAULT_LIBRARY_FALLBACK)r$rr'Zfallback_framework_pathr Zfallback_library_pathr	r	r
�dyld_default_searchcsr.c	Cs|ttt||�t||�t||��|�D]D}tj�|�r<|Szt|�rP|WSWq$t	k
rfYq$Xq$t
d|f��dS)Nzdylib %s could not be found)r"�chainr(r+r.rr �isfilerr�
ValueError)r$r*rr r	r	r
rys��c
Cs�d}zt|||d�WStk
r:}z|}W5d}~XYnX|�d�}|dkr^t|�}|d7}tj�|tj�|d|���}z2zt|||d�WW�Stk
r�|�YnXW5d}XdS)N)r*rz
.framework���)rr1�rfindrrr r%r&)�fnr*r�error�eZ
fmwk_indexr	r	r
r�s	
cCsi}dSrr	rr	r	r
�test_dyld_find�sr7�__main__)N)N)N)N)N)N)N)N)N)NN)NN)rZctypes.macholib.frameworkrZctypes.macholib.dylibr�	itertoolsZ_ctypesr�ImportError�__all__r �
expanduserr,r-rrrrrrr"r(r+r.rrr7�__name__r	r	r	r
�<module>sJ�
�
�











__init__.py000064400000000232151730364220006655 0ustar00"""
Enough Mach-O to make your head spin.

See the relevant header files in /usr/include/mach-o

And also Apple's documentation.
"""

__version__ = '1.0'
dyld.py000064400000012010151730364220006047 0ustar00"""
dyld emulation
"""

import os
from framework import framework_info
from dylib import dylib_info
from itertools import *

__all__ = [
    'dyld_find', 'framework_find',
    'framework_info', 'dylib_info',
]

# These are the defaults as per man dyld(1)
#
DEFAULT_FRAMEWORK_FALLBACK = [
    os.path.expanduser("~/Library/Frameworks"),
    "/Library/Frameworks",
    "/Network/Library/Frameworks",
    "/System/Library/Frameworks",
]

DEFAULT_LIBRARY_FALLBACK = [
    os.path.expanduser("~/lib"),
    "/usr/local/lib",
    "/lib",
    "/usr/lib",
]

def ensure_utf8(s):
    """Not all of PyObjC and Python understand unicode paths very well yet"""
    if isinstance(s, unicode):
        return s.encode('utf8')
    return s

def dyld_env(env, var):
    if env is None:
        env = os.environ
    rval = env.get(var)
    if rval is None:
        return []
    return rval.split(':')

def dyld_image_suffix(env=None):
    if env is None:
        env = os.environ
    return env.get('DYLD_IMAGE_SUFFIX')

def dyld_framework_path(env=None):
    return dyld_env(env, 'DYLD_FRAMEWORK_PATH')

def dyld_library_path(env=None):
    return dyld_env(env, 'DYLD_LIBRARY_PATH')

def dyld_fallback_framework_path(env=None):
    return dyld_env(env, 'DYLD_FALLBACK_FRAMEWORK_PATH')

def dyld_fallback_library_path(env=None):
    return dyld_env(env, 'DYLD_FALLBACK_LIBRARY_PATH')

def dyld_image_suffix_search(iterator, env=None):
    """For a potential path iterator, add DYLD_IMAGE_SUFFIX semantics"""
    suffix = dyld_image_suffix(env)
    if suffix is None:
        return iterator
    def _inject(iterator=iterator, suffix=suffix):
        for path in iterator:
            if path.endswith('.dylib'):
                yield path[:-len('.dylib')] + suffix + '.dylib'
            else:
                yield path + suffix
            yield path
    return _inject()

def dyld_override_search(name, env=None):
    # If DYLD_FRAMEWORK_PATH is set and this dylib_name is a
    # framework name, use the first file that exists in the framework
    # path if any.  If there is none go on to search the DYLD_LIBRARY_PATH
    # if any.

    framework = framework_info(name)

    if framework is not None:
        for path in dyld_framework_path(env):
            yield os.path.join(path, framework['name'])

    # If DYLD_LIBRARY_PATH is set then use the first file that exists
    # in the path.  If none use the original name.
    for path in dyld_library_path(env):
        yield os.path.join(path, os.path.basename(name))

def dyld_executable_path_search(name, executable_path=None):
    # If we haven't done any searching and found a library and the
    # dylib_name starts with "@executable_path/" then construct the
    # library name.
    if name.startswith('@executable_path/') and executable_path is not None:
        yield os.path.join(executable_path, name[len('@executable_path/'):])

def dyld_default_search(name, env=None):
    yield name

    framework = framework_info(name)

    if framework is not None:
        fallback_framework_path = dyld_fallback_framework_path(env)
        for path in fallback_framework_path:
            yield os.path.join(path, framework['name'])

    fallback_library_path = dyld_fallback_library_path(env)
    for path in fallback_library_path:
        yield os.path.join(path, os.path.basename(name))

    if framework is not None and not fallback_framework_path:
        for path in DEFAULT_FRAMEWORK_FALLBACK:
            yield os.path.join(path, framework['name'])

    if not fallback_library_path:
        for path in DEFAULT_LIBRARY_FALLBACK:
            yield os.path.join(path, os.path.basename(name))

def dyld_find(name, executable_path=None, env=None):
    """
    Find a library or framework using dyld semantics
    """
    name = ensure_utf8(name)
    executable_path = ensure_utf8(executable_path)
    for path in dyld_image_suffix_search(chain(
                dyld_override_search(name, env),
                dyld_executable_path_search(name, executable_path),
                dyld_default_search(name, env),
            ), env):
        if os.path.isfile(path):
            return path
    raise ValueError("dylib %s could not be found" % (name,))

def framework_find(fn, executable_path=None, env=None):
    """
    Find a framework using dyld semantics in a very loose manner.

    Will take input such as:
        Python
        Python.framework
        Python.framework/Versions/Current
    """
    try:
        return dyld_find(fn, executable_path=executable_path, env=env)
    except ValueError, e:
        pass
    fmwk_index = fn.rfind('.framework')
    if fmwk_index == -1:
        fmwk_index = len(fn)
        fn += '.framework'
    fn = os.path.join(fn, os.path.basename(fn[:fmwk_index]))
    try:
        return dyld_find(fn, executable_path=executable_path, env=env)
    except ValueError:
        raise e

def test_dyld_find():
    env = {}
    assert dyld_find('libSystem.dylib') == '/usr/lib/libSystem.dylib'
    assert dyld_find('System.framework/System') == '/System/Library/Frameworks/System.framework/System'

if __name__ == '__main__':
    test_dyld_find()
dylib.py000064400000003444151730364220006231 0ustar00"""
Generic dylib path manipulation
"""

import re

__all__ = ['dylib_info']

DYLIB_RE = re.compile(r"""(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+?)
    (?:\.(?P<version>[^._]+))?
    (?:_(?P<suffix>[^._]+))?
    \.dylib$
)
""")

def dylib_info(filename):
    """
    A dylib name can take one of the following four forms:
        Location/Name.SomeVersion_Suffix.dylib
        Location/Name.SomeVersion.dylib
        Location/Name_Suffix.dylib
        Location/Name.dylib

    returns None if not found or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.SomeVersion_Suffix.dylib',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present.
    """
    is_dylib = DYLIB_RE.match(filename)
    if not is_dylib:
        return None
    return is_dylib.groupdict()


def test_dylib_info():
    def d(location=None, name=None, shortname=None, version=None, suffix=None):
        return dict(
            location=location,
            name=name,
            shortname=shortname,
            version=version,
            suffix=suffix
        )
    assert dylib_info('completely/invalid') is None
    assert dylib_info('completely/invalide_debug') is None
    assert dylib_info('P/Foo.dylib') == d('P', 'Foo.dylib', 'Foo')
    assert dylib_info('P/Foo_debug.dylib') == d('P', 'Foo_debug.dylib', 'Foo', suffix='debug')
    assert dylib_info('P/Foo.A.dylib') == d('P', 'Foo.A.dylib', 'Foo', 'A')
    assert dylib_info('P/Foo_debug.A.dylib') == d('P', 'Foo_debug.A.dylib', 'Foo_debug', 'A')
    assert dylib_info('P/Foo.A_debug.dylib') == d('P', 'Foo.A_debug.dylib', 'Foo', 'A', 'debug')

if __name__ == '__main__':
    test_dylib_info()
fetch_macholib000075500000000124151730364220007421 0ustar00#!/bin/sh
svn export --force http://svn.red-bean.com/bob/macholib/trunk/macholib/ .
framework.py000064400000004231151730364220007116 0ustar00"""
Generic framework path manipulation
"""

import re

__all__ = ['framework_info']

STRICT_FRAMEWORK_RE = re.compile(r"""(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+).framework/
    (?:Versions/(?P<version>[^/]+)/)?
    (?P=shortname)
    (?:_(?P<suffix>[^_]+))?
)$
""")

def framework_info(filename):
    """
    A framework name can take one of the following four forms:
        Location/Name.framework/Versions/SomeVersion/Name_Suffix
        Location/Name.framework/Versions/SomeVersion/Name
        Location/Name.framework/Name_Suffix
        Location/Name.framework/Name

    returns None if not found, or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.framework/Versions/SomeVersion/Name_Suffix',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present
    """
    is_framework = STRICT_FRAMEWORK_RE.match(filename)
    if not is_framework:
        return None
    return is_framework.groupdict()

def test_framework_info():
    def d(location=None, name=None, shortname=None, version=None, suffix=None):
        return dict(
            location=location,
            name=name,
            shortname=shortname,
            version=version,
            suffix=suffix
        )
    assert framework_info('completely/invalid') is None
    assert framework_info('completely/invalid/_debug') is None
    assert framework_info('P/F.framework') is None
    assert framework_info('P/F.framework/_debug') is None
    assert framework_info('P/F.framework/F') == d('P', 'F.framework/F', 'F')
    assert framework_info('P/F.framework/F_debug') == d('P', 'F.framework/F_debug', 'F', suffix='debug')
    assert framework_info('P/F.framework/Versions') is None
    assert framework_info('P/F.framework/Versions/A') is None
    assert framework_info('P/F.framework/Versions/A/F') == d('P', 'F.framework/Versions/A/F', 'F', 'A')
    assert framework_info('P/F.framework/Versions/A/F_debug') == d('P', 'F.framework/Versions/A/F_debug', 'F', 'A', 'debug')

if __name__ == '__main__':
    test_framework_info()
README.ctypes000064400000000450151730364220006734 0ustar00Files in this directory come from Bob Ippolito's py2app.

License: Any components of the py2app suite may be distributed under
the MIT or PSF open source licenses.

This is version 1.0, SVN revision 789, from 2006/01/25.
The main repository is http://svn.red-bean.com/bob/macholib/trunk/macholib/dyld.pyo000064400000012715151734567510006255 0ustar00�
{fc@sIdZddlZddlmZddlmZddlTdddd	gZejj	d
�ddd
gZ
ejj	d�dddgZd�Zd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zddd�Zddd�Zd�Zed krEe�ndS(!s
dyld emulation
i����N(tframework_info(t
dylib_info(t*t	dyld_findtframework_findRRs~/Library/Frameworkss/Library/Frameworkss/Network/Library/Frameworkss/System/Library/Frameworkss~/libs/usr/local/libs/libs/usr/libcCs t|t�r|jd�S|S(sCNot all of PyObjC and Python understand unicode paths very well yettutf8(t
isinstancetunicodetencode(ts((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytensure_utf8s
cCsD|dkrtj}n|j|�}|dkr7gS|jd�S(Nt:(tNonetostenvirontgettsplit(tenvtvartrval((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_env%scCs%|dkrtj}n|jd�S(NtDYLD_IMAGE_SUFFIX(RR
RR(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_image_suffix-scCs
t|d�S(NtDYLD_FRAMEWORK_PATH(R(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_framework_path2scCs
t|d�S(NtDYLD_LIBRARY_PATH(R(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_library_path5scCs
t|d�S(NtDYLD_FALLBACK_FRAMEWORK_PATH(R(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_fallback_framework_path8scCs
t|d�S(NtDYLD_FALLBACK_LIBRARY_PATH(R(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_fallback_library_path;scCs2t|�}|dkr|S||d�}|�S(s>For a potential path iterator, add DYLD_IMAGE_SUFFIX semanticscssMxF|D]>}|jd�r7|td� |dVn	||V|VqWdS(Ns.dylib(tendswithtlen(titeratortsuffixtpath((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyt_injectCs

	N(RR(R!RR"R$((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_image_suffix_search>s
ccs�t|�}|dk	rJx/t|�D]}tjj||d�Vq%Wnx4t|�D]&}tjj|tjj|��VqWWdS(Ntname(RRRR
R#tjoinRtbasename(R&Rt	frameworkR#((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_override_searchLsccs@|jd�r<|dk	r<tjj||td��VndS(Ns@executable_path/(t
startswithRR
R#R'R (R&texecutable_path((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_executable_path_search]sccs|Vt|�}|dk	rUt|�}x)|D]}tjj||d�Vq0Wnt|�}x.|D]&}tjj|tjj|��VqhW|dk	r�|r�x)tD]}tjj||d�Vq�Wn|sx1t	D]&}tjj|tjj|��Vq�WndS(NR&(
RRRR
R#R'RR(tDEFAULT_FRAMEWORK_FALLBACKtDEFAULT_LIBRARY_FALLBACK(R&RR)tfallback_framework_pathR#tfallback_library_path((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_default_searchds

$

cCs�t|�}t|�}xTttt||�t||�t||��|�D]}tjj|�rO|SqOWt	d|f��dS(s:
    Find a library or framework using dyld semantics
    sdylib %s could not be foundN(
R
R%tchainR*R-R2R
R#tisfilet
ValueError(R&R,RR#((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyRzs	
cCs�yt|d|d|�SWntk
r/}nX|jd�}|dkrdt|�}|d7}ntjj|tjj|| ��}yt|d|d|�SWntk
r�|�nXdS(s�
    Find a framework using dyld semantics in a very loose manner.

    Will take input such as:
        Python
        Python.framework
        Python.framework/Versions/Current
    R,Rs
.frameworki����N(RR5trfindR R
R#R'R((tfnR,Rtet
fmwk_index((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyR�s	
%
cCs
i}dS(N((R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyttest_dyld_find�st__main__(t__doc__R
R)RtdylibRt	itertoolst__all__R#t
expanduserR.R/R
RRRRRRRR%R*R-R2RRR:t__name__(((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyt<module>s<
					__init__.pyo000064400000000474151734567520007060 0ustar00�
{fc@sdZdZdS(s~
Enough Mach-O to make your head spin.

See the relevant header files in /usr/include/mach-o

And also Apple's documentation.
s1.0N(t__doc__t__version__(((s0/usr/lib64/python2.7/ctypes/macholib/__init__.pyt<module>sframework.pyo000064400000003523151734567520007314 0ustar00�
{fc@sVdZddlZdgZejd�Zd�Zd�ZedkrRe�ndS(s%
Generic framework path manipulation
i����Ntframework_infos�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+).framework/
    (?:Versions/(?P<version>[^/]+)/)?
    (?P=shortname)
    (?:_(?P<suffix>[^_]+))?
)$
cCs#tj|�}|sdS|j�S(s}
    A framework name can take one of the following four forms:
        Location/Name.framework/Versions/SomeVersion/Name_Suffix
        Location/Name.framework/Versions/SomeVersion/Name
        Location/Name.framework/Name_Suffix
        Location/Name.framework/Name

    returns None if not found, or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.framework/Versions/SomeVersion/Name_Suffix',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present
    N(tSTRICT_FRAMEWORK_REtmatchtNonet	groupdict(tfilenametis_framework((s1/usr/lib64/python2.7/ctypes/macholib/framework.pyRscCsdddddd�}dS(NcSs%td|d|d|d|d|�S(Ntlocationtnamet	shortnametversiontsuffix(tdict(RRR	R
R((s1/usr/lib64/python2.7/ctypes/macholib/framework.pytd-s(R(R
((s1/usr/lib64/python2.7/ctypes/macholib/framework.pyttest_framework_info,st__main__(t__doc__tret__all__tcompileRRRt__name__(((s1/usr/lib64/python2.7/ctypes/macholib/framework.pyt<module>s				__init__.pyc000064400000000474151734567520007044 0ustar00�
{fc@sdZdZdS(s~
Enough Mach-O to make your head spin.

See the relevant header files in /usr/include/mach-o

And also Apple's documentation.
s1.0N(t__doc__t__version__(((s0/usr/lib64/python2.7/ctypes/macholib/__init__.pyt<module>sdylib.pyo000064400000003305151734567520006420 0ustar00�
{fc@sVdZddlZdgZejd�Zd�Zd�ZedkrRe�ndS(s!
Generic dylib path manipulation
i����Nt
dylib_infos�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+?)
    (?:\.(?P<version>[^._]+))?
    (?:_(?P<suffix>[^._]+))?
    \.dylib$
)
cCs#tj|�}|sdS|j�S(s1
    A dylib name can take one of the following four forms:
        Location/Name.SomeVersion_Suffix.dylib
        Location/Name.SomeVersion.dylib
        Location/Name_Suffix.dylib
        Location/Name.dylib

    returns None if not found or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.SomeVersion_Suffix.dylib',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present.
    N(tDYLIB_REtmatchtNonet	groupdict(tfilenametis_dylib((s-/usr/lib64/python2.7/ctypes/macholib/dylib.pyRscCsdddddd�}dS(NcSs%td|d|d|d|d|�S(Ntlocationtnamet	shortnametversiontsuffix(tdict(RRR	R
R((s-/usr/lib64/python2.7/ctypes/macholib/dylib.pytd.s(R(R
((s-/usr/lib64/python2.7/ctypes/macholib/dylib.pyttest_dylib_info-st__main__(t__doc__tret__all__tcompileRRRt__name__(((s-/usr/lib64/python2.7/ctypes/macholib/dylib.pyt<module>s				dylib.pyc000064400000004413151734567520006405 0ustar00�
{fc@sVdZddlZdgZejd�Zd�Zd�ZedkrRe�ndS(s!
Generic dylib path manipulation
i����Nt
dylib_infos�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+?)
    (?:\.(?P<version>[^._]+))?
    (?:_(?P<suffix>[^._]+))?
    \.dylib$
)
cCs#tj|�}|sdS|j�S(s1
    A dylib name can take one of the following four forms:
        Location/Name.SomeVersion_Suffix.dylib
        Location/Name.SomeVersion.dylib
        Location/Name_Suffix.dylib
        Location/Name.dylib

    returns None if not found or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.SomeVersion_Suffix.dylib',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present.
    N(tDYLIB_REtmatchtNonet	groupdict(tfilenametis_dylib((s-/usr/lib64/python2.7/ctypes/macholib/dylib.pyRscCsdddddd�}td�dks0t�td�dksHt�td�|ddd�kslt�td�|dd	dd
d�ks�t�td�|dd
dd�ks�t�td�|dddd�ks�t�td�|ddddd�kst�dS(NcSs%td|d|d|d|d|�S(Ntlocationtnamet	shortnametversiontsuffix(tdict(RRR	R
R((s-/usr/lib64/python2.7/ctypes/macholib/dylib.pytd.sscompletely/invalidscompletely/invalide_debugsP/Foo.dylibtPs	Foo.dylibtFoosP/Foo_debug.dylibsFoo_debug.dylibRtdebugs
P/Foo.A.dylibsFoo.A.dylibtAsP/Foo_debug.A.dylibsFoo_debug.A.dylibt	Foo_debugsP/Foo.A_debug.dylibsFoo.A_debug.dylib(RRtAssertionError(R
((s-/usr/lib64/python2.7/ctypes/macholib/dylib.pyttest_dylib_info-s$*''t__main__(t__doc__tret__all__tcompileRRRt__name__(((s-/usr/lib64/python2.7/ctypes/macholib/dylib.pyt<module>s				framework.pyc000064400000005101151734567520007272 0ustar00�
{fc@sVdZddlZdgZejd�Zd�Zd�ZedkrRe�ndS(s%
Generic framework path manipulation
i����Ntframework_infos�(?x)
(?P<location>^.*)(?:^|/)
(?P<name>
    (?P<shortname>\w+).framework/
    (?:Versions/(?P<version>[^/]+)/)?
    (?P=shortname)
    (?:_(?P<suffix>[^_]+))?
)$
cCs#tj|�}|sdS|j�S(s}
    A framework name can take one of the following four forms:
        Location/Name.framework/Versions/SomeVersion/Name_Suffix
        Location/Name.framework/Versions/SomeVersion/Name
        Location/Name.framework/Name_Suffix
        Location/Name.framework/Name

    returns None if not found, or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.framework/Versions/SomeVersion/Name_Suffix',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )

    Note that SomeVersion and Suffix are optional and may be None
    if not present
    N(tSTRICT_FRAMEWORK_REtmatchtNonet	groupdict(tfilenametis_framework((s1/usr/lib64/python2.7/ctypes/macholib/framework.pyRscCsKdddddd�}td�dks0t�td�dksHt�td�dks`t�td�dksxt�td�|ddd	�ks�t�td
�|ddd	dd
�ks�t�td�dks�t�td�dks�t�td�|ddd	d�kst�td�|ddd	dd
�ksGt�dS(NcSs%td|d|d|d|d|�S(Ntlocationtnamet	shortnametversiontsuffix(tdict(RRR	R
R((s1/usr/lib64/python2.7/ctypes/macholib/framework.pytd-sscompletely/invalidscompletely/invalid/_debugs
P/F.frameworksP/F.framework/_debugsP/F.framework/FtPs
F.framework/FtFsP/F.framework/F_debugsF.framework/F_debugRtdebugsP/F.framework/VersionssP/F.framework/Versions/AsP/F.framework/Versions/A/FsF.framework/Versions/A/FtAs P/F.framework/Versions/A/F_debugsF.framework/Versions/A/F_debug(RRtAssertionError(R
((s1/usr/lib64/python2.7/ctypes/macholib/framework.pyttest_framework_info,s$*'t__main__(t__doc__tret__all__tcompileRRRt__name__(((s1/usr/lib64/python2.7/ctypes/macholib/framework.pyt<module>s				dyld.pyc000064400000013233151734567520006236 0ustar00�
{fc@sIdZddlZddlmZddlmZddlTdddd	gZejj	d
�ddd
gZ
ejj	d�dddgZd�Zd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zddd�Zddd�Zd�Zed krEe�ndS(!s
dyld emulation
i����N(tframework_info(t
dylib_info(t*t	dyld_findtframework_findRRs~/Library/Frameworkss/Library/Frameworkss/Network/Library/Frameworkss/System/Library/Frameworkss~/libs/usr/local/libs/libs/usr/libcCs t|t�r|jd�S|S(sCNot all of PyObjC and Python understand unicode paths very well yettutf8(t
isinstancetunicodetencode(ts((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytensure_utf8s
cCsD|dkrtj}n|j|�}|dkr7gS|jd�S(Nt:(tNonetostenvirontgettsplit(tenvtvartrval((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_env%scCs%|dkrtj}n|jd�S(NtDYLD_IMAGE_SUFFIX(RR
RR(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_image_suffix-scCs
t|d�S(NtDYLD_FRAMEWORK_PATH(R(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_framework_path2scCs
t|d�S(NtDYLD_LIBRARY_PATH(R(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_library_path5scCs
t|d�S(NtDYLD_FALLBACK_FRAMEWORK_PATH(R(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_fallback_framework_path8scCs
t|d�S(NtDYLD_FALLBACK_LIBRARY_PATH(R(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_fallback_library_path;scCs2t|�}|dkr|S||d�}|�S(s>For a potential path iterator, add DYLD_IMAGE_SUFFIX semanticscssMxF|D]>}|jd�r7|td� |dVn	||V|VqWdS(Ns.dylib(tendswithtlen(titeratortsuffixtpath((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyt_injectCs

	N(RR(R!RR"R$((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_image_suffix_search>s
ccs�t|�}|dk	rJx/t|�D]}tjj||d�Vq%Wnx4t|�D]&}tjj|tjj|��VqWWdS(Ntname(RRRR
R#tjoinRtbasename(R&Rt	frameworkR#((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_override_searchLsccs@|jd�r<|dk	r<tjj||td��VndS(Ns@executable_path/(t
startswithRR
R#R'R (R&texecutable_path((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_executable_path_search]sccs|Vt|�}|dk	rUt|�}x)|D]}tjj||d�Vq0Wnt|�}x.|D]&}tjj|tjj|��VqhW|dk	r�|r�x)tD]}tjj||d�Vq�Wn|sx1t	D]&}tjj|tjj|��Vq�WndS(NR&(
RRRR
R#R'RR(tDEFAULT_FRAMEWORK_FALLBACKtDEFAULT_LIBRARY_FALLBACK(R&RR)tfallback_framework_pathR#tfallback_library_path((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pytdyld_default_searchds

$

cCs�t|�}t|�}xTttt||�t||�t||��|�D]}tjj|�rO|SqOWt	d|f��dS(s:
    Find a library or framework using dyld semantics
    sdylib %s could not be foundN(
R
R%tchainR*R-R2R
R#tisfilet
ValueError(R&R,RR#((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyRzs	
cCs�yt|d|d|�SWntk
r/}nX|jd�}|dkrdt|�}|d7}ntjj|tjj|| ��}yt|d|d|�SWntk
r�|�nXdS(s�
    Find a framework using dyld semantics in a very loose manner.

    Will take input such as:
        Python
        Python.framework
        Python.framework/Versions/Current
    R,Rs
.frameworki����N(RR5trfindR R
R#R'R((tfnR,Rtet
fmwk_index((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyR�s	
%
cCs:i}td�dkst�td�dks6t�dS(NslibSystem.dylibs/usr/lib/libSystem.dylibsSystem.framework/Systems2/System/Library/Frameworks/System.framework/System(RtAssertionError(R((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyttest_dyld_find�st__main__(t__doc__R
R)RtdylibRt	itertoolst__all__R#t
expanduserR.R/R
RRRRRRRR%R*R-R2RRR;t__name__(((s,/usr/lib64/python2.7/ctypes/macholib/dyld.pyt<module>s<