|
@@ -5,6 +5,8 @@ from icopy2xls import Mover
|
|
|
import os
|
|
|
import xlrd
|
|
|
from icopy2xls.FilesOpen import FilesOpen
|
|
|
+import json
|
|
|
+from time import sleep
|
|
|
|
|
|
class MainWindow(Ui_MainWindow):
|
|
|
""" BaangtUI : Logic implementation file for uidesign
|
|
@@ -30,6 +32,7 @@ class MainWindow(Ui_MainWindow):
|
|
|
self.filterButton.clicked.connect(self.filterDialog)
|
|
|
self.runButton.clicked.connect(self.runMain)
|
|
|
self.openResultFilePushButton.clicked.connect(self.openResultFile)
|
|
|
+ self.loadJsonFile()
|
|
|
|
|
|
def sourceBrowsePathSlot(self):
|
|
|
""" Browse Folder Containing *.xlsx file for execution. And
|
|
@@ -262,6 +265,10 @@ class MainWindow(Ui_MainWindow):
|
|
|
mover = Mover(source, source_sheet, destination, destination_sheet, lines)
|
|
|
mover.move(self.filters, self.addMissingCheckBox.isChecked())
|
|
|
self.statusbar.showMessage("Completed...", 3000)
|
|
|
+ self.saveJsonFile(
|
|
|
+ source, source_sheet, destination, destination_sheet,
|
|
|
+ lines, self.filters, self.addMissingCheckBox.isChecked()
|
|
|
+ )
|
|
|
|
|
|
def check_fields(self):
|
|
|
source = self.sourceFiles
|
|
@@ -288,6 +295,33 @@ class MainWindow(Ui_MainWindow):
|
|
|
else:
|
|
|
self.statusbar.showMessage(f"No destination File selected")
|
|
|
|
|
|
+ def saveJsonFile(self, source, source_sht, dest, dest_sht, lines, filters, addMissing):
|
|
|
+ path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "settings.json")
|
|
|
+ js = {"source": source, "source_sheet": source_sht,
|
|
|
+ "destination": dest, "destination_sheet": dest_sht,
|
|
|
+ "lines": lines, "filters": filters, "addMissingColumn": addMissing}
|
|
|
+ with open(path, 'w') as file:
|
|
|
+ file.write(json.dumps(js))
|
|
|
+
|
|
|
+ def loadJsonFile(self):
|
|
|
+ path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "settings.json")
|
|
|
+ if not os.path.exists(path):
|
|
|
+ return
|
|
|
+ js = json.load(open(path))
|
|
|
+ self.sourceFiles = js["source"]
|
|
|
+ self.sourcePathLineEdit.setText(", ".join(self.sourceFiles))
|
|
|
+ self.getSheetsSource(self.sourceFiles[0])
|
|
|
+ index_source = self.sourceSheetComboBox.findText(js["source_sheet"], QtCore.Qt.MatchFixedString)
|
|
|
+ if index_source >= 0:
|
|
|
+ self.sourceSheetComboBox.setCurrentIndex(index_source)
|
|
|
+ self.destinationPathLineEdit.setText(js["destination"])
|
|
|
+ self.getSheetsDestination(js["destination"])
|
|
|
+ index_destination = self.destinationSheetComboBox.findText(js["destination_sheet"], QtCore.Qt.MatchFixedString)
|
|
|
+ if index_destination >= 0:
|
|
|
+ self.destinationSheetComboBox.setCurrentIndex(index_destination)
|
|
|
+ self.linesInput.setText(js["lines"])
|
|
|
+ self.filters = js["filters"]
|
|
|
+ self.addMissingCheckBox.setChecked(js["addMissingColumn"])
|
|
|
|
|
|
|
|
|
class MainController:
|