comparison 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
comparison
equal deleted inserted replaced
2:81c7d4668a7e 3:03e124ff7e26
1 from os.path import isfile, getsize
2
3
1 class DBKit: 4 class DBKit:
2 def __init__(self, indexFile, databaseFile): 5 def __init__(self, indexFile, databaseFile):
3 self.databaseFile = databaseFile 6 self.databaseFile = databaseFile
4 self.index = dict() 7 self.index = dict()
5 with open(indexFile) as file: 8 with open(indexFile) as file:
28 else: 31 else:
29 return False 32 return False
30 33
31 def getIndex(self): 34 def getIndex(self):
32 return self.index 35 return self.index
36
37
38 def writeEntry(identifier, fileName, outputIndex, outputDatabase):
39 if isfile(outputDatabase):
40 currentSize = getsize(outputDatabase)
41 else:
42 currentSize = 0
43 if isfile(fileName):
44 entrySize = getsize(fileName)
45 else:
46 entrySize = 0
47 if entrySize > 0:
48 outputIndexFile = open(outputIndex, "a+")
49 outputIndexFile.write("%s\t%s\t%s\n" % (identifier, currentSize, entrySize))
50 tempFile = open(fileName, "r")
51 databaseFile = open(outputDatabase, "a+")
52 databaseFile.write(tempFile.read())
53 databaseFile.close()
54 tempFile.close()
55 outputIndexFile.close()
56 return True
57 else:
58 return False