Пример #1
0
def initConf(confFile=None):
    global CONFIG

    conf = SafeConfigParser()
    with open("./data/conf/defaultconfig.txt", "r") as configFile:
        conf.readfp(configFile)

    if confFile is None:
        confFile = os.environ.get('CARTOGRAPH_CONF', 'conf.txt')
    logger.info('using configuration file %s' % (`confFile`))

    if os.path.isfile(confFile):
        with open(confFile, "r") as updateFile:
            conf.readfp(updateFile)
    else:
        logger.warn('configuration file %s does not exist' % (`confFile`))

    def confSample(target, section, key, n=None):
        if n is None:
            n = target.getint('PreprocessingConstants', 'sample_size')
        return samplePath(target.get(section, key), n)

    conf.getSample = types.MethodType(confSample, conf)

    CONFIG = conf
Пример #2
0
def initConf(confFile=None):
    global CONFIG

    conf = SafeConfigParser()
    with open("./data/conf/defaultconfig.txt", "r") as configFile:
        conf.readfp(configFile)

    if confFile is None:
        confFile = os.environ.get('CARTOGRAPH_CONF', 'conf.txt')
    logger.info('using configuration file %s' % ( ` confFile `))

    if os.path.isfile(confFile):
        with open(confFile, "r") as updateFile:
            conf.readfp(updateFile)
    else:
        logger.warn('configuration file %s does not exist' % ( ` confFile `))

    def confSample(target, section, key, n=None):
        if n is None:
            n = target.getint('PreprocessingConstants', 'sample_size')
        return samplePath(target.get(section, key), n)

    conf.getSample = types.MethodType(confSample, conf)

    CONFIG = conf