(upload_file, extension='.shp', tempdir=None)
return absolute_base_file
Unzips a zipfile into a temporary directory and returns the full path of the .shp file inside (if any)
Unzips a zipfile into a temporary directory and returns the full path of the .shp file inside (if any)
Unzips a zipfile into a temporary directory and returns the full path of the . shp file inside ( if any )
def unzip_file(upload_file, extension='.shp', tempdir=None):
    """
    Unzips a zipfile into a temporary directory and returns the full path of the .shp file inside (if any)
    """
    absolute_base_file = None
    if tempdir is None:
        tempdir = tempfile.mkdtemp(dir=settings.STATIC_ROOT)
    if not os.path.isdir(tempdir):
        os.makedirs(tempdir)

    the_zip = ZipFile(upload_file, allowZip64=True)
    the_zip.extractall(tempdir)
    for item in the_zip.namelist():
        if item.endswith(extension):
            absolute_base_file = os.path.join(tempdir, item)

    return absolute_base_file
def unzip_file ( upload_file , extension = '.shp' , tempdir = None ) : absolute_base_file = None if tempdir is None : tempdir = tempfile . mkdtemp ( dir = settings . STATIC_ROOT ) if not os . path . isdir ( tempdir ) : os . makedirs ( tempdir ) the_zip = ZipFile ( upload_file , allowZip64 = True ) the_zip . extractall ( tempdir ) for item in the_zip . namelist ( ) : if item . endswith ( extension ) : absolute_base_file = os . path . join ( tempdir , item ) return absolute_base_file