Exemplo n.º 1
0
def generic_handle_file(file, original_filename):
    """
    Handels a file, regardless if a package or a single file and returns 
    a list of files. can recursively unpack packages.
    """
    #print "entering generic_handle_file(file=%s, original_filename=%s)" % (file, original_filename)
    files = []
    filetype = os.path.splitext(original_filename)[1].lower()
    #print filetype
    if filetype=='.zip' and settings.FILER_UNZIP_FILES:
        unpacked_files = unzip(file)
        for ufile, ufilename in unpacked_files:
            files += generic_handle_file(ufile, ufilename)
    else:
        files.append( (file,original_filename) )
    #print "result of generic_handle_file: ", files
    return files
Exemplo n.º 2
0
def generic_handle_file(file, original_filename):
    """
    Handels a file, regardless if a package or a single file and returns 
    a list of files. can recursively unpack packages.
    """
    #print "entering generic_handle_file(file=%s, original_filename=%s)" % (file, original_filename)
    files = []
    filetype = os.path.splitext(original_filename)[1].lower()
    #print filetype
    if filetype == '.zip':
        unpacked_files = unzip(file)
        for ufile, ufilename in unpacked_files:
            files += generic_handle_file(ufile, ufilename)
    else:
        files.append((file, original_filename))
    #print "result of generic_handle_file: ", files
    return files
Exemplo n.º 3
0
 def test_unzipping_works(self):
     result = unzip(self.zipfilename)
     self.assertEqual(result[0][0].name, self.file.name)
Exemplo n.º 4
0
 def test_unzipping_works(self):
     self.create_fixtures()
     result = unzip(self.zipfilename)
     self.assertEqual(result[0][0].name, self.file.name)
Exemplo n.º 5
0
 def test_unzipping_works(self):
     result = unzip(self.zipfilename)
     self.assertEqual(result[0][0].name, self.file.name)
Exemplo n.º 6
0
 def test_unzipping_works(self):
     self.create_fixtures()
     result = unzip(self.zipfilename)
     self.assertEqual(result[0][0].name, self.file.name)