Debian Codegraph @

Lib/ctypes/macholib/framework.py

raw
1 """
2 Generic framework path manipulation
3 """
4
5 import re
6
7 __all__ = ['framework_info']
8
9 STRICT_FRAMEWORK_RE = re.compile(r"""(?x)
10 (?P<location>^.*)(?:^|/)
11 (?P<name>
12 (?P<shortname>\w+).framework/
13 (?:Versions/(?P<version>[^/]+)/)?
14 (?P=shortname)
15 (?:_(?P<suffix>[^_]+))?
16 )$
17 """)
18
19 def framework_info(filename):
20 """
21 A framework name can take one of the following four forms:
22 Location/Name.framework/Versions/SomeVersion/Name_Suffix
23 Location/Name.framework/Versions/SomeVersion/Name
24 Location/Name.framework/Name_Suffix
25 Location/Name.framework/Name
26
27 returns None if not found, or a mapping equivalent to:
28 dict(
29 location='Location',
30 name='Name.framework/Versions/SomeVersion/Name_Suffix',
31 shortname='Name',
32 version='SomeVersion',
33 suffix='Suffix',
34 )
35
36 Note that SomeVersion and Suffix are optional and may be None
37 if not present
38 """
39 is_framework = STRICT_FRAMEWORK_RE.match(filename)
40 if not is_framework:
41 return None
42 return is_framework.groupdict()