# Path: src/core/def_tools.py
# def keys_sorted(dictionary, n_top=None):
#     import heapq
#     if n_top is None:
#         n_top = len(dictionary.keys())
#     else:
#         n_top = int(n_top)
#     return heapq.nlargest(n_top, dictionary, key = lambda k:dictionary[k])
# 
# Path: src/ct/ck2cti_GPS.py
# def ck2cti(folder):
# 
#     ok = True
# 
#     options = dict()
#     options['--input'] = os.path.join(folder,'chem.inp')
#     options['--thermo'] = os.path.join(folder,'therm.dat')
#     try:
#         open(os.path.join(folder,'tran.dat'))
#         options['--transport'] = folder + 'tran.dat'
#     except IOError:
#         pass
#     options['--permissive'] = True
#     main(options)
# 
#     return ok


import sys, copy
import os
import cantera as ct
import json
import time
import shutil
import copy
import os
from PyQt4 import uic
from PyQt4.QtGui import * 
from PyQt4.QtCore import * 
from def_dialog import common
from src.core.def_tools import keys_sorted
from src.ct.ck2cti_GPS import ck2cti








def fun_cleanck(dir_desk_mech):

	# ========= chem.inp ====================

	p0 = os.path.join(dir_desk_mech,'chem0.inp')
	f0 = open(p0,'r')
	f = open(os.path.join(dir_desk_mech,'chem.inp'),'w')

	for ln0 in f0:
		ln = ln0
		if 'TROE' in ln.upper() or 'LOW' in ln.upper():
			#print 'TROE or LOW found'
			ln = ln.replace(',',' ')

		ln = ln.replace(',',';')
		f.write(ln)

	f.close()
	f0.close()

# Path: src/core/def_tools.py
# def keys_sorted(dictionary, n_top=None):
#     import heapq
#     if n_top is None:
#         n_top = len(dictionary.keys())
#     else:
#         n_top = int(n_top)
#     return heapq.nlargest(n_top, dictionary, key = lambda k:dictionary[k])
# 
# Path: src/ct/ck2cti_GPS.py
# def ck2cti(folder):
# 
#     ok = True
# 
#     options = dict()
#     options['--input'] = os.path.join(folder,'chem.inp')
#     options['--thermo'] = os.path.join(folder,'therm.dat')
#     try:
#         open(os.path.join(folder,'tran.dat'))
#         options['--transport'] = folder + 'tran.dat'
#     except IOError:
#         pass
#     options['--permissive'] = True
#     main(options)
# 
#     return ok


# Path: src/gui/dialog_mech.py
import sys, copy
import os
import cantera as ct
import json
import time
import shutil
import copy
import os
from PyQt4 import uic
from PyQt4.QtGui import * 
from PyQt4.QtCore import * 
from def_dialog import common
from src.core.def_tools import keys_sorted
from src.ct.ck2cti_GPS import ck2cti









def fun_cleanck(dir_desk_mech):

	# ========= chem.inp ====================

	p0 = os.path.join(dir_desk_mech,'chem0.inp')
	f0 = open(p0,'r')
	f = open(os.path.join(dir_desk_mech,'chem.inp'),'w')

	for ln0 in f0:
		ln = ln0
		if 'TROE' in ln.upper() or 'LOW' in ln.upper():
			#print 'TROE or LOW found'
			ln = ln.replace(',',' ')

		ln = ln.replace(',',';')
		f.write(ln)

	f.close()
	f0.close()

	os.remove(p0)