(function)
return decorated_function
open the logfile when running the function and close it afterwards.

    >>> @logfile
    >>> def function(survey_dir, *args, **kwargs):
    >>>     pass

    @logfile will open survey_dir/log as a logfile when function is called and
    close it, when function finishes.
open the logfile when running the function and close it afterwards.
open the logfile when running the function and close it afterwards .
def logfile(function):
    '''open the logfile when running the function and close it afterwards.

    >>> @logfile
    >>> def function(survey_dir, *args, **kwargs):
    >>>     pass

    @logfile will open survey_dir/log as a logfile when function is called and
    close it, when function finishes.
    '''
    def decorated_function(cmdline):
        log.logfile.open(os.path.join(cmdline['project'], 'log'))
        result = function(cmdline)
        log.logfile.close()
        return result

    functools.update_wrapper(decorated_function, function)

    return decorated_function
def logfile ( function ) : def decorated_function ( cmdline ) : log . logfile . open ( os . path . join ( cmdline [ 'project' ] , 'log' ) ) result = function ( cmdline ) log . logfile . close ( ) return result functools . update_wrapper ( decorated_function , function ) return decorated_function