Back to index

python3.2  3.2.2
Functions | Variables
ctypes.macholib.dylib Namespace Reference

Functions

def dylib_info
def test_dylib_info

Variables

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

Detailed Description

Generic dylib path manipulation

Function Documentation

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.

Definition at line 19 of file dylib.py.

00019 
00020 def dylib_info(filename):
00021     """
00022     A dylib name can take one of the following four forms:
00023         Location/Name.SomeVersion_Suffix.dylib
00024         Location/Name.SomeVersion.dylib
00025         Location/Name_Suffix.dylib
00026         Location/Name.dylib
00027 
00028     returns None if not found or a mapping equivalent to:
00029         dict(
00030             location='Location',
00031             name='Name.SomeVersion_Suffix.dylib',
00032             shortname='Name',
00033             version='SomeVersion',
00034             suffix='Suffix',
00035         )
00036 
00037     Note that SomeVersion and Suffix are optional and may be None
00038     if not present.
00039     """
00040     is_dylib = DYLIB_RE.match(filename)
00041     if not is_dylib:
00042         return None
00043     return is_dylib.groupdict()
00044 

Here is the caller graph for this function:

Definition at line 45 of file dylib.py.

00045 
00046 def test_dylib_info():
00047     def d(location=None, name=None, shortname=None, version=None, suffix=None):
00048         return dict(
00049             location=location,
00050             name=name,
00051             shortname=shortname,
00052             version=version,
00053             suffix=suffix
00054         )
00055     assert dylib_info('completely/invalid') is None
00056     assert dylib_info('completely/invalide_debug') is None
00057     assert dylib_info('P/Foo.dylib') == d('P', 'Foo.dylib', 'Foo')
00058     assert dylib_info('P/Foo_debug.dylib') == d('P', 'Foo_debug.dylib', 'Foo', suffix='debug')
00059     assert dylib_info('P/Foo.A.dylib') == d('P', 'Foo.A.dylib', 'Foo', 'A')
00060     assert dylib_info('P/Foo_debug.A.dylib') == d('P', 'Foo_debug.A.dylib', 'Foo_debug', 'A')
00061     assert dylib_info('P/Foo.A_debug.dylib') == d('P', 'Foo.A_debug.dylib', 'Foo', 'A', 'debug')

Here is the call graph for this function:


Variable Documentation

Definition at line 7 of file dylib.py.

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

Definition at line 9 of file dylib.py.