Mercurial > repos > guerler > dbkit
diff dbkit_package/DBKit.py @ 3:03e124ff7e26 draft
"planemo upload commit bd03b7888eab0b010acfc3affd38bf4d4e2bb1ef-dirty"
author | guerler |
---|---|
date | Wed, 16 Dec 2020 13:11:35 +0000 |
parents | 81c7d4668a7e |
children |
line wrap: on
line diff
--- a/dbkit_package/DBKit.py Wed Dec 16 12:02:48 2020 +0000 +++ b/dbkit_package/DBKit.py Wed Dec 16 13:11:35 2020 +0000 @@ -1,3 +1,6 @@ +from os.path import isfile, getsize + + class DBKit: def __init__(self, indexFile, databaseFile): self.databaseFile = databaseFile @@ -30,3 +33,26 @@ def getIndex(self): return self.index + + +def writeEntry(identifier, fileName, outputIndex, outputDatabase): + if isfile(outputDatabase): + currentSize = getsize(outputDatabase) + else: + currentSize = 0 + if isfile(fileName): + entrySize = getsize(fileName) + else: + entrySize = 0 + if entrySize > 0: + outputIndexFile = open(outputIndex, "a+") + outputIndexFile.write("%s\t%s\t%s\n" % (identifier, currentSize, entrySize)) + tempFile = open(fileName, "r") + databaseFile = open(outputDatabase, "a+") + databaseFile.write(tempFile.read()) + databaseFile.close() + tempFile.close() + outputIndexFile.close() + return True + else: + return False