generic dylib path manipulation def dylibinfofilename isdylib dylibre matchfilename if not isdylib return none return isdylib groupdict x p location p name p shortname w p version _ _ p suffix _ dylib 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
import re

__all__ = ['dylib_info']

DYLIB_RE = re.compile(r)

def dylib_info(filename):
    
    is_dylib = DYLIB_RE.match(filename)
    if not is_dylib:
        return None
    return is_dylib.groupdict()