Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(3)  |  Derive(0)  |  Import(0)
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.

        def parse_config_h(fp, g=None):
    """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.
    """
    if g is None:
        g = {}
    define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
    undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
    #
    while 1:
        line = fp.readline()
        if not line:
            break
        m = define_rx.match(line)
        if m:
            n, v = m.group(1, 2)
            try: v = int(v)
            except ValueError: pass
            g[n] = v
        else:
            m = undef_rx.match(line)
            if m:
                g[m.group(1)] = 0
    return g
        


src/4/s/4Suite-XML-1.0.2/Ft/Lib/DistExt/Util.py   4Suite-XML(Download)
                    line = fp.readline()
            else:
                sysconfig.parse_config_h(fp, _config_vars)
        finally:
            fp.close()

src/i/n/IncPy-HEAD/setup.py   IncPy(Download)
 
        config_h = sysconfig.get_config_h_filename()
        config_h_vars = sysconfig.parse_config_h(open(config_h))
 
        platform = self.get_platform()

src/s/l/SlopPy-HEAD/setup.py   SlopPy(Download)
 
        config_h = sysconfig.get_config_h_filename()
        config_h_vars = sysconfig.parse_config_h(open(config_h))
 
        platform = self.get_platform()