MCPcopy Create free account
hub / github.com/numpy/numpy / parse_flags

Function parse_flags

numpy/distutils/npy_pkg_config.py:31–71  ·  view source on GitHub ↗

Parse a line from a config file containing compile flags. Parameters ---------- line : str A single line containing one or more compile flags. Returns ------- d : dict Dictionary of parsed flags, split into relevant categories. These categories

(line)

Source from the content-addressed store, hash-verified

29 return self.msg
30
31def parse_flags(line):
32 """
33 Parse a line from a config file containing compile flags.
34
35 Parameters
36 ----------
37 line : str
38 A single line containing one or more compile flags.
39
40 Returns
41 -------
42 d : dict
43 Dictionary of parsed flags, split into relevant categories.
44 These categories are the keys of `d`:
45
46 * 'include_dirs'
47 * 'library_dirs'
48 * 'libraries'
49 * 'macros'
50 * 'ignored'
51
52 """
53 d = {'include_dirs': [], 'library_dirs': [], 'libraries': [],
54 'macros': [], 'ignored': []}
55
56 flags = (' ' + line).split(' -')
57 for flag in flags:
58 flag = '-' + flag
59 if len(flag) > 0:
60 if flag.startswith('-I'):
61 d['include_dirs'].append(flag[2:].strip())
62 elif flag.startswith('-L'):
63 d['library_dirs'].append(flag[2:].strip())
64 elif flag.startswith('-l'):
65 d['libraries'].append(flag[2:].strip())
66 elif flag.startswith('-D'):
67 d['macros'].append(flag[2:].strip())
68 else:
69 d['ignored'].append(flag)
70
71 return d
72
73def _escape_backslash(val):
74 return val.replace('\\', '\\\\')

Callers 3

get_infoFunction · 0.90
test_simple_cflagsMethod · 0.90
test_simple_lflagsMethod · 0.90

Calls 3

startswithMethod · 0.80
stripMethod · 0.80
splitMethod · 0.45

Tested by 2

test_simple_cflagsMethod · 0.72
test_simple_lflagsMethod · 0.72