Mercurial > repos > guerler > dbkit
diff dbkit_extract.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_extract.py Wed Dec 16 12:02:48 2020 +0000 +++ b/dbkit_extract.py Wed Dec 16 13:11:35 2020 +0000 @@ -1,31 +1,26 @@ #! /usr/bin/env python3 import argparse -from os import system -from os.path import getsize -from dbkit_package.DBKit import DBKit +from dbkit_package.DBKit import DBKit, writeEntry def main(args): logFile = open(args.log, "w") - outIndex = args.outindex - outData = args.outdata + outputIndex = args.outputindex + outputDatabase = args.outputdatabase entries = list() with open(args.list, "r") as f: for line in f: name = line.split()[0] entries.append(name) logFile.write("Detected %s entries.\n" % len(entries)) - tempFile = "temp.dat" + fileName = "temp.dat" count = 0 dbkit = DBKit(args.index, args.database) for entry in sorted(entries): - success = dbkit.createFile(entry, tempFile) + success = dbkit.createFile(entry, fileName) if success: - currentSize = getsize(outData) - entrySize = getsize(tempFile) - system("cat %s >> %s" % (tempFile, outData)) - system("echo '%s\t%s\t%s' >> %s" % (entry, currentSize, entrySize, outIndex)) + writeEntry(entry, fileName, outputIndex, outputDatabase) count = count + 1 else: logFile.write("Entry %s not found.\n" % entry) @@ -38,8 +33,8 @@ parser.add_argument('-l', '--list', help='List of entries to be extracted', required=True) parser.add_argument('-i', '--index', help='Database Index file (ffindex)', required=True) parser.add_argument('-d', '--database', help='Database Data file (ffdata)', required=True) - parser.add_argument('-oi', '--outindex', help='Output Index file', required=True) - parser.add_argument('-od', '--outdata', help='Output Data file', required=True) + parser.add_argument('-oi', '--outputindex', help='Output Index file', required=True) + parser.add_argument('-od', '--outputdatabase', help='Output Data file', required=True) parser.add_argument('-g', '--log', help='Log file', required=True) args = parser.parse_args() main(args)