def __getFilename(self, data, scene=1):
        """To get the data from different scenarios in the filename, scene value see `remote_download` in 1, 2, 3, 4"""
        try:
            filename = None
            if scene == 1:
                plugin_filename = [i for i in parse_qs(urlsplit(data).query).get("plugin_filename") or [] if i]
                if plugin_filename and len(plugin_filename) == 1:
                    filename = plugin_filename[0]
            elif scene == 2:
                filename = basename(urlsplit(data).path)
            elif scene == 3:
                if PY2:
                    cd = data.headers.getheader("Content-Disposition", "")
                else:
                    cd = data.getheader("Content-Disposition", "")
                filename = parse_header(cd)[-1].get("filename")
            elif scene == 4:
                if PY2:
                    cd = data.info().subtype
                else:
                    cd = data.info().get_content_subtype()
                mt = {'zip': 'zip', 'x-compressed-tar': 'tar.gz', 'x-gzip': 'tar.gz'}
                subtype = mt.get(cd)
                if subtype:
                    filename = "." + subtype
        except Exception as e:
            self.logger.warning(e)
        else:
            if self.__isValidFilename(filename):
                return filename
def __getFilename ( self , data , scene = 1 ) : try : filename = None if scene == 1 : plugin_filename = [ i for i in parse_qs ( urlsplit ( data ) . query ) . get ( "plugin_filename" ) or [ ] if i ] if plugin_filename and len ( plugin_filename ) == 1 : filename = plugin_filename [ 0 ] elif scene == 2 : filename = basename ( urlsplit ( data ) . path ) elif scene == 3 : if PY2 : cd = data . headers . getheader ( "Content-Disposition" , "" ) else : cd = data . getheader ( "Content-Disposition" , "" ) filename = parse_header ( cd ) [ - 1 ] . get ( "filename" ) elif scene == 4 : if PY2 : cd = data . info ( ) . subtype else : cd = data . info ( ) . get_content_subtype ( ) mt = { 'zip' : 'zip' , 'x-compressed-tar' : 'tar.gz' , 'x-gzip' : 'tar.gz' } subtype = mt . get ( cd ) if subtype : filename = "." + subtype except Exception as e : self . logger . warning ( e ) else : if self . __isValidFilename ( filename ) : return filename
To get the data from different scenarios in the filename, scene value see `remote_download` in 1, 2, 3, 4