golf/views/view_export.py
def createFileResponse(context, name, archiveName, classModuleName, classModule, readme=None):
    """
    Helper function to limit the redundancy
    Make a temporary directory and a data subdirectory which we will add module and json
    TODO: Add README.txt file which explains the format and how the file can be used to import
    """
    retObject = {}
    with tempfile.TemporaryDirectory() as tmpdir:
        datadir = os.path.join(tmpdir, 'data')
        os.mkdir(datadir)
        with open(os.path.join(datadir, 'context.json'), 'w') as outfile:
            json.dump(context, outfile)
        if readme:
            with open(os.path.join(datadir, 'readme.txt'), 'w') as outfile:
                outfile.write(readme)
            with zipfile.ZipFile(os.path.join(tmpdir, 'data.zip'), 'a') as datazip:
                datazip.write(os.path.join(datadir, 'readme.txt'), arcname='readme.txt')
        with zipfile.ZipFile(os.path.join(tmpdir, 'data.zip'), 'a') as datazip:
            datazip.write(os.path.join(datadir, 'context.json'), arcname='context.json')
        with zipfile.ZipFile(os.path.join(tmpdir, 'data.zip'), 'a') as datazip:
            datazip.write(classModule, arcname=classModuleName+'.py')
        retObject = FileResponse(open(os.path.join(tmpdir, 'data.zip'), 'rb'))
        retObject['Content-Disposition'] = ('attachment; filename="'+name+'.zip"')
    return retObject

    Helper function to limit the redundancy
    Make a temporary directory and a data subdirectory which we will add module and json
    TODO: Add README.txt file which explains the format and how the file can be used to import
    
Helper function to limit the redundancy
Make a temporary directory and a data subdirectory which we will add module and json
TODO: Add README.txt file which explains the format and how the file can be used to import
Helper function to limit the redundancy Make a temporary directory and a data subdirectory which we will add module and json TODO : Add README . txt file which explains the format and how the file can be used to import
def createFileResponse(context, name, archiveName, classModuleName, classModule, readme=None):
    retObject = {}
    with tempfile.TemporaryDirectory() as tmpdir:
        datadir = os.path.join(tmpdir, 'data')
        os.mkdir(datadir)
        with open(os.path.join(datadir, 'context.json'), 'w') as outfile:
            json.dump(context, outfile)
        if readme:
            with open(os.path.join(datadir, 'readme.txt'), 'w') as outfile:
                outfile.write(readme)
            with zipfile.ZipFile(os.path.join(tmpdir, 'data.zip'), 'a') as datazip:
                datazip.write(os.path.join(datadir, 'readme.txt'), arcname='readme.txt')
        with zipfile.ZipFile(os.path.join(tmpdir, 'data.zip'), 'a') as datazip:
            datazip.write(os.path.join(datadir, 'context.json'), arcname='context.json')
        with zipfile.ZipFile(os.path.join(tmpdir, 'data.zip'), 'a') as datazip:
            datazip.write(classModule, arcname=classModuleName+'.py')
        retObject = FileResponse(open(os.path.join(tmpdir, 'data.zip'), 'rb'))
        retObject['Content-Disposition'] = ('attachment; filename="'+name+'.zip"')
    return retObject
def createFileResponse ( context , name , archiveName , classModuleName , classModule , readme = None ) : retObject = { } with tempfile . TemporaryDirectory ( ) as tmpdir : datadir = os . path . join ( tmpdir , 'data' ) os . mkdir ( datadir ) with open ( os . path . join ( datadir , 'context.json' ) , 'w' ) as outfile : json . dump ( context , outfile ) if readme : with open ( os . path . join ( datadir , 'readme.txt' ) , 'w' ) as outfile : outfile . write ( readme ) with zipfile . ZipFile ( os . path . join ( tmpdir , 'data.zip' ) , 'a' ) as datazip : datazip . write ( os . path . join ( datadir , 'readme.txt' ) , arcname = 'readme.txt' ) with zipfile . ZipFile ( os . path . join ( tmpdir , 'data.zip' ) , 'a' ) as datazip : datazip . write ( os . path . join ( datadir , 'context.json' ) , arcname = 'context.json' ) with zipfile . ZipFile ( os . path . join ( tmpdir , 'data.zip' ) , 'a' ) as datazip : datazip . write ( classModule , arcname = classModuleName + '.py' ) retObject = FileResponse ( open ( os . path . join ( tmpdir , 'data.zip' ) , 'rb' ) ) retObject [ 'Content-Disposition' ] = ( 'attachment; filename="' + name + '.zip"' ) return retObject
Helper function to limit the redundancy
Make a temporary directory and a data subdirectory which we will add module and json
TODO: Add README.txt file which explains the format and how the file can be used to import
Helper function to limit the redundancy Make a temporary directory and a data subdirectory which we will add module and json TODO : Add README . txt file which explains the format and how the file can be used to import
"""
    Helper function to limit the redundancy
    Make a temporary directory and a data subdirectory which we will add module and json
    TODO: Add README.txt file which explains the format and how the file can be used to import
    """
context
name
archiveName
classModuleName
classModule
readme