MCPcopy Index your code
hub / github.com/RustPython/RustPython / parse_config_h

Function parse_config_h

Lib/sysconfig/__init__.py:433–464  ·  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

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