def list_files(self, subdir=None, patterns=[]): path = self.path(subdir) patterns = '*' if not patterns else ';'.join(patterns) return map( lambda f: f[len(self.location) + 1:], filter(lambda f: os.path.split(f)[1][0] != ".", all_files(path, patterns=patterns, single_level=True)))
def migrate_files(request): path = os.path.join(settings.JMUTUBE_MEDIA_ROOT, request.user.username) if request.method == 'POST': for file in request.POST.getlist('file'): shutil.copy2(os.path.join(path, file), os.path.join(path, 'video')) get_jmutube_storage().storage_system.sync_files(request.user) return HttpResponseRedirect(reverse('jmutube-media', args=['video'])) files = map(lambda f: {'name': os.path.split(f)[1], 'exists': os.path.exists(os.path.join(path, 'video', os.path.split(f)[1])) }, filter(lambda f: os.path.split(f)[1][0] != ".", all_files(path, patterns=';'.join(FILE_TYPES['video']), single_level=True))) return render_to_response('media/jmutube-migrate.html', { 'files': files, 'path': path }, context_instance = RequestContext(request))
def list_files(self, subdir=None, patterns=[]): path = self.path(subdir) patterns = '*' if not patterns else ';'.join(patterns) return map(lambda f: f[len(self.location) + 1:], filter(lambda f: os.path.split(f)[1][0] != ".", all_files(path, patterns=patterns, single_level=True)))