MCPcopy Create free account
hub / github.com/python/cpython / getsetupinfo

Function getsetupinfo

Tools/freeze/parsesetup.py:48–78  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

46setupvardef = re.compile('^([a-zA-Z0-9_]+)=(.*)')
47
48def getsetupinfo(filename):
49 modules = {}
50 variables = {}
51 fp = open(filename)
52 pendingline = ""
53 try:
54 while 1:
55 line = fp.readline()
56 if pendingline:
57 line = pendingline + line
58 pendingline = ""
59 if not line:
60 break
61 # Strip comments
62 i = line.find('#')
63 if i >= 0:
64 line = line[:i]
65 if line.endswith('\\\n'):
66 pendingline = line[:-2]
67 continue
68 matchobj = setupvardef.match(line)
69 if matchobj:
70 (name, value) = matchobj.group(1, 2)
71 variables[name] = value.strip()
72 else:
73 words = line.split()
74 if words:
75 modules[words[0]] = words[1:]
76 finally:
77 fp.close()
78 return modules, variables
79
80
81# Test the above functions.

Callers 1

testFunction · 0.85

Calls 9

openFunction · 0.70
readlineMethod · 0.45
findMethod · 0.45
endswithMethod · 0.45
matchMethod · 0.45
groupMethod · 0.45
stripMethod · 0.45
splitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…