Пример #1
0
def insertPDFChunks(startPos,contador,secuencia,totalElements,lsContent,json_documento,done):
    if done==0:
        json_documento['lspdfcontent'].clear()
        json_documento['id']=str(uuid.uuid4())
        for i in range(startPos,totalElements):
            if i!=totalElements-1:
                if contador<=20:
                    json_documento['lspdfcontent'].append(lsContent[i])
                    contador=contador+1
                else:
                    currentSeq=secuencia+1
                    json_documento['secuencia']=currentSeq
                    res=bd.insertPDF(json_documento) 
                    if res:
                        print('Chunk of pdf added:',str(i),'from ',str(totalElements),' sequence:',str(currentSeq))  
                    else:
                        print('Chunk of pdf already existed:',str(i),'from ',str(totalElements),' sequence:',str(currentSeq)) 

                    return insertPDFChunks(i,0,currentSeq,totalElements,lsContent,json_documento,0) 
            else:
                json_documento['lspdfcontent'].append(lsContent[i])
                currentSeq=secuencia+1
                json_documento['secuencia']=currentSeq
                res=bd.insertPDF(json_documento) 
                if res:
                    print('Last Chunk of pdf added:',str(i),'from ',str(totalElements),' sequence:',str(currentSeq))
                else:
                    print('Last Chunk of pdf already existed:',str(i),'from ',str(totalElements),' sequence:',str(currentSeq))

                return  insertPDFChunks(i,0,currentSeq,totalElements,lsContent,json_documento,1)
    else:
        return False            
Пример #2
0
def insertPDFChunks(startPos, contador, secuencia, totalElements, lsContent,
                    json_documento):
    json_documento['lspdfcontent'].clear()
    json_documento['id'] = str(uuid.uuid4())
    for i in range(startPos, totalElements):
        if contador <= 20:
            json_documento['lspdfcontent'].append(lsContent[i])
            contador = contador + 1
        else:
            currentSeq = secuencia = secuencia + 1
            json_documento['secuencia'] = currentSeq
            res = bd.insertPDF(json_documento)
            if res:
                print('Chunk of pdf added')
            insertPDFChunks(i, 0, currentSeq, totalElements, lsContent,
                            json_documento)
    print('PDF COMPLETE')