web/ldt/ldt_utils/fileimport.py
changeset 62 39b2dab4f939
parent 60 a8ad7ebf5902
child 89 30c6e597a7de
equal deleted inserted replaced
61:cb1b83039bc1 62:39b2dab4f939
   326                 else:
   326                 else:
   327                     contents[id].videopath =settings.STREAM_URL
   327                     contents[id].videopath =settings.STREAM_URL
   328                     
   328                     
   329                 
   329                 
   330         #get annotation of file ldt
   330         #get annotation of file ldt
   331         #result = xml.xpath.Evaluate("/iri/annotations/content", context=con)
       
   332         result = doc.xpath("/iri/annotations/content")
   331         result = doc.xpath("/iri/annotations/content")
   333         
   332         
   334         for contentnode in result:
   333         for contentnode in result:
   335             id = contentnode.attrib['id']
   334             id = contentnode.attrib['id']
   336             # pocketfilms.utils.log.debug("ID : " + str(id))
       
   337             if contents.has_key(id):
   335             if contents.has_key(id):
   338                 if self.author:
   336                 if self.author:
   339                     contentnode.set("author", unicode(self.author))
   337                     contentnode.set("author", unicode(self.author))
   340                 contents[id].annotations = contentnode
   338                 contents[id].annotations = contentnode
   341         
   339         
   370             zipfile = zipfileext.ZipFileExt(self.filepath)
   368             zipfile = zipfileext.ZipFileExt(self.filepath)
   371             zipfile.unzip_into_dir(self.__tempdir)
   369             zipfile.unzip_into_dir(self.__tempdir)
   372             #load ldt
   370             #load ldt
   373             foldersToProcess = [self.__tempdir]
   371             foldersToProcess = [self.__tempdir]
   374             while len(foldersToProcess):
   372             while len(foldersToProcess):
   375                 # pocketfilms.utils.log.debug("folder stack length : "+ str(len(foldersToProcess)))
       
   376                 currentFolder = foldersToProcess.pop()
   373                 currentFolder = foldersToProcess.pop()
   377                 for entry in os.listdir(currentFolder):
   374                 for entry in os.listdir(currentFolder):
   378                     if entry in settings.ZIP_BLACKLIST:
   375                     if entry in settings.ZIP_BLACKLIST:
   379                         continue
   376                         continue
   380                     entryPath = os.path.join(currentFolder, entry)
   377                     entryPath = os.path.join(currentFolder, entry)
   381                     if(os.path.isdir(entryPath)):
   378                     if(os.path.isdir(entryPath)):
   382                         # pocketfilms.utils.log.debug("Push folder : " + entryPath)
       
   383                         foldersToProcess.append(entryPath)
   379                         foldersToProcess.append(entryPath)
   384                     elif fnmatch.fnmatch(entry, "*.ldt"):
   380                     elif fnmatch.fnmatch(entry, "*.ldt"):
   385                         # pocketfilms.utils.log.debug("Process file : " + entryPath)
       
   386                         ldtid = self.processLdt(entryPath)
   381                         ldtid = self.processLdt(entryPath)
   387                         processedids.append(ldtid)
   382                         processedids.append(ldtid)
   388                     elif fnmatch.fnmatch(entry, "*.flv"):
   383                     elif fnmatch.fnmatch(entry, "*.flv"):
   389                         flvfiles.append(entryPath)
   384                         flvfiles.append(entryPath)
   390              
   385