def configure(filename=None):
    """This function gives to the user application a chance to define where
    configuration file should live. Subsequent calls to this function will have
    no effect, unless you call :func:`reconfigure`.

    :param str filename: Full path to configuration file.

    """
    global retry

    if getattr(configure, '_configured', False):
        return

    filename = filename or DEFAULT_CONFIG_FILENAME
    _ensure_directory(filename)

    parser = SafeConfigParser()

    if os.path.isfile(filename):
        with open(filename, 'r') as fp:
            parser.readfp(fp)

    if not parser.has_section(RETRY_SECTION):
        parser.add_section(RETRY_SECTION)
        parser.set(RETRY_SECTION, 'max_tries', str(constants.BACKOFF_DEFAULT_MAXTRIES))
        parser.set(RETRY_SECTION, 'delay', str(constants.BACKOFF_DEFAULT_DELAY))
        parser.set(RETRY_SECTION, 'factor', str(constants.BACKOFF_DEFAULT_FACTOR))

        with open(filename, 'wb') as fp:
            parser.write(fp)

    retry = RetrySettings(
            max_tries=parser.getint(RETRY_SECTION, 'max_tries'),
            delay=parser.getint(RETRY_SECTION, 'delay'),
            factor=parser.getint(RETRY_SECTION, 'factor'))

    setattr(configure, '_configured', True)
    setattr(configure, '_configured_filename', filename)
def configure ( filename = None ) : global retry if getattr ( configure , '_configured' , False ) : return filename = filename or DEFAULT_CONFIG_FILENAME _ensure_directory ( filename ) parser = SafeConfigParser ( ) if os . path . isfile ( filename ) : with open ( filename , 'r' ) as fp : parser . readfp ( fp ) if not parser . has_section ( RETRY_SECTION ) : parser . add_section ( RETRY_SECTION ) parser . set ( RETRY_SECTION , 'max_tries' , str ( constants . BACKOFF_DEFAULT_MAXTRIES ) ) parser . set ( RETRY_SECTION , 'delay' , str ( constants . BACKOFF_DEFAULT_DELAY ) ) parser . set ( RETRY_SECTION , 'factor' , str ( constants . BACKOFF_DEFAULT_FACTOR ) ) with open ( filename , 'wb' ) as fp : parser . write ( fp ) retry = RetrySettings ( max_tries = parser . getint ( RETRY_SECTION , 'max_tries' ) , delay = parser . getint ( RETRY_SECTION , 'delay' ) , factor = parser . getint ( RETRY_SECTION , 'factor' ) ) setattr ( configure , '_configured' , True ) setattr ( configure , '_configured_filename' , filename )
This function gives to the user application a chance to define where
    configuration file should live. Subsequent calls to this function will have
    no effect, unless you call :func:`reconfigure`.

    :param str filename: Full path to configuration file.