MCPcopy Index your code
hub / github.com/python/cpython / parse_config_h

Function parse_config_h

Lib/sysconfig/__init__.py:428–459  ·  view source on GitHub ↗

Parse a config.h-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary.

(fp, vars=None)

Source from the content-addressed store, hash-verified

426
427
428def parse_config_h(fp, vars=None):
429 """Parse a config.h-style file.
430
431 A dictionary containing name/value pairs is returned. If an
432 optional dictionary is passed in as the second argument, it is
433 used instead of a new dictionary.
434 """
435 if vars is None:
436 vars = {}
437 import re
438 define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
439 undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
440
441 while True:
442 line = fp.readline()
443 if not line:
444 break
445 m = define_rx.match(line)
446 if m:
447 n, v = m.group(1, 2)
448 try:
449 if n in _ALWAYS_STR:
450 raise ValueError
451 v = int(v)
452 except ValueError:
453 pass
454 vars[n] = v
455 else:
456 m = undef_rx.match(line)
457 if m:
458 vars[m.group(1)] = 0
459 return vars
460
461
462def get_config_h_filename():

Callers 1

_generate_posix_varsFunction · 0.90

Calls 4

compileMethod · 0.45
readlineMethod · 0.45
matchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…