Skip to content

Commit d562545

Browse files
committed
Fix importOldDatabase.py script
- Create argparse usage for input and output database paths
1 parent 22a185b commit d562545

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

scripts/importOldDatabase.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,42 @@
33

44
"""
55
This script imports an RMG-Java database from the output directory and saves
6-
it in the input directory.
6+
it in the user-specified database directory.
7+
8+
The outputDirectory can then be used to overwrite the existing RMG-database files.
79
"""
810

9-
import math
10-
import os.path
11-
import sys
12-
import time
13-
import subprocess
1411
import os
12+
import argparse
1513

16-
from rmgpy.kinetics import KineticsData
17-
from rmgpy.data.kinetics import KineticsDatabase, KineticsGroups
1814
from rmgpy.data.rmg import RMGDatabase
1915

2016
################################################################################
2117

2218

2319
if __name__ == '__main__':
2420

25-
26-
# Set the import and export paths
27-
oldPath = 'output/RMG_database'
21+
parser = argparse.ArgumentParser()
22+
parser.add_argument('inputPath', metavar='INPUT', type=str, nargs=1,
23+
help='the input path of the RMG-Java database directory')
24+
parser.add_argument('outputPath', metavar='OUTPUT', type=str, nargs=1,
25+
help='output path for the desired RMG-Py database directory')
26+
27+
args = parser.parse_args()
28+
inputPath = args.inputPath[0]
29+
outputPath = args.outputPath[0]
30+
2831
newPath = 'input'
2932

3033
print 'Loading old RMG-Java database...'
3134
database = RMGDatabase()
32-
database.loadOld(oldPath)
33-
35+
database.loadOld(inputPath)
36+
37+
try:
38+
os.makedirs(outputPath)
39+
except:
40+
pass
41+
3442
print 'Saving the new RMG-Py database...'
35-
database.save(newPath)
43+
database.save(outputPath)
3644
print "Done!"

0 commit comments

Comments
 (0)