# 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
				self.parent.soln_in[self.data['name']] = self.soln_in

			self.w.accept()




	def act_set(self):

		if self.read_path():
			dir_desk = self.data['desk']
			path_cti = os.path.join(dir_desk,'mech','chem.cti')
			if not os.path.exists(path_cti):

				dir_desk = self.data['desk']
				dir_desk_mech = os.path.join(dir_desk,'mech')
				path_cti = os.path.join(dir_desk_mech,'chem.cti')

				if not os.path.exists(dir_desk_mech):
					os.makedirs(dir_desk_mech)

				shutil.copy(self.data['chem'],os.path.join(dir_desk_mech,'chem0.inp'))
				shutil.copy(self.data['therm'],os.path.join(dir_desk_mech,'therm0.dat'))

				fun_cleanck(dir_desk_mech)

				self.w.btn_save.setEnabled(False)
				self.w.btn_save.setText('setting...')
				self.parent.app.processEvents()


# 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

				self.parent.soln_in[self.data['name']] = self.soln_in

			self.w.accept()




	def act_set(self):

		if self.read_path():
			dir_desk = self.data['desk']
			path_cti = os.path.join(dir_desk,'mech','chem.cti')
			if not os.path.exists(path_cti):

				dir_desk = self.data['desk']
				dir_desk_mech = os.path.join(dir_desk,'mech')
				path_cti = os.path.join(dir_desk_mech,'chem.cti')

				if not os.path.exists(dir_desk_mech):
					os.makedirs(dir_desk_mech)

				shutil.copy(self.data['chem'],os.path.join(dir_desk_mech,'chem0.inp'))
				shutil.copy(self.data['therm'],os.path.join(dir_desk_mech,'therm0.dat'))

				fun_cleanck(dir_desk_mech)

				self.w.btn_save.setEnabled(False)
				self.w.btn_save.setText('setting...')
				self.parent.app.processEvents()


				if ck2cti(dir_desk_mech):