view spring_package/DBKit.py @ 37:0be0af9e695d draft

"planemo upload commit c716195a2cc1ed30ff8c4936621091296a93b2fc"
author guerler
date Wed, 25 Nov 2020 14:35:35 +0000
parents
children 172398348efd
line wrap: on
line source

def createFile(identifier, databaseIndex, database, outputName):
    start = -1
    size = 0
    with open(databaseIndex) as file:
        for line in file:
            cols = line.split()
            if identifier == cols[0]:
                start = int(cols[1])
                size = int(cols[2])
                break
    if start != -1 and size > 0:
        with open(database) as file:
            file.seek(start)
            content = file.read(size)
            outputFile = open(outputName, "w")
            outputFile.write(content)
            outputFile.close()
        return True
    else:
        return False