Skip to content

Commit

Permalink
MinorChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Garman committed Jun 12, 2020
1 parent 411afa3 commit bb2e824
Show file tree
Hide file tree
Showing 19 changed files with 1,116 additions and 853 deletions.
33 changes: 33 additions & 0 deletions FileCreator.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['FileCreator.py'],
pathex=['C:\\Users\\bgarman\\Documents\\Projects\\ODXF & IVS Editor\\File Editor'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='FileCreator',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False , icon='icon.ico')
50 changes: 39 additions & 11 deletions IVS_Creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@
import os, glob
import xml.etree.ElementTree as ET
import datetime
import json
from functools import partial

path = ""
comments = []
class Ui_Dialog(object):

def InitalLoad(self):
with open(r'config.json') as json_file:
data = json.load(json_file)
fileLocation = data["ivsPath"]
if fileLocation != "":
self.fileLocationLineEdit.setText(fileLocation)
global path
path = fileLocation + "\\"
self.initaliseComboBox()

def initaliseComboBox(self):
#List all the vehicle lines that are available
vehicles = []
Expand All @@ -37,7 +48,9 @@ def vehicleComboBoxSelected(self):
modules.append(y.split("-")[1])
# Create a plaehoolder at beginign of list
modules.insert(0,"-- Select Module --")
#Remopve dupliactes
modules.insert(1,"19L310")
modules.insert(2,"19L320")
#Remove dupliactes
modules = list(dict.fromkeys(modules))
#Clear the combo box and append the modules
self.moduleComboBox.clear()
Expand Down Expand Up @@ -88,6 +101,8 @@ def hardwareComboBoxSelected(self):
self.valueComboBox.clear()
self.valueComboBox.addItems(value)

def valueComboBoxSelected(self):
self.fileLineEdit.setText(self.hardwareComboBox.currentText() + "-" + self.moduleComboBox.currentText() + "-")

def createFileButtonClicked(self):
#Used for creating the files from the combobox choices
Expand All @@ -103,7 +118,7 @@ def createFileButtonClicked(self):
prevFilePath = glob.glob(newPath + hardware +"*" + module + "*" + prevValue + ".xml")[0]
prevFile = prevFilePath.split("\\")
prevFile = prevFile[len(prevFile) - 1].split(".xml")[0]
newFilePath = newPath + hardware + "-" + module + "-" + newValue + ".xml"
newFilePath = newPath + newValue + ".xml"
newFile = newFilePath.split("\\")
newFile = newFile[len(newFile) - 1].split(".xml")[0]

Expand Down Expand Up @@ -160,7 +175,7 @@ def initaliseUpdateComboBox(self):
newPath = path + vehicle + "\\"

# Gets the xml from the file and parses through it
newFilePath = newPath + hardware + "-" + module + "-" + newValue + ".xml"
newFilePath = newPath + newValue + ".xml"
tree = ET.parse(newFilePath)
root = tree.getroot()

Expand Down Expand Up @@ -214,9 +229,9 @@ def updateAreaComboBoxSelected(self):
newPath = path + vehicle + "\\"

#Find the Path for the newfile which has been created
newFilePath = newPath + hardware + "-" + module + "-" + newValue + ".xml"
newFilePath = newPath + newValue + ".xml"
#Find the name of the new file
newFile = hardware + "-" + module + "-" + newValue + ".xml"
newFile = newValue + ".xml"

# Parse the xml file into the python viewer and get the first root
newFileXML = ET.parse(newFilePath)
Expand Down Expand Up @@ -247,10 +262,12 @@ def updateAreaComboBoxSelected(self):

if 'hardware' in tempRoot.tag:
# Hardware has different tags to everythign else
self.updateFileLineEdit.setPlaceholderText("Prev: " + tempRoot.attrib['hardwareType'])
temp = tempRoot.attrib['hardwareType'].split("-")
self.updateFileLineEdit.setText(temp[0] + "-" + temp[1] + "-")
else:
# Normal tags
self.updateFileLineEdit.setPlaceholderText("Prev: " + tempRoot.attrib['filePN'])
temp = tempRoot.attrib['filePN'].split("-")
self.updateFileLineEdit.setText(temp[0] + "-" + temp[1] + "-")



Expand All @@ -266,9 +283,9 @@ def updateFileButtonClicked(self):
newPath = path + vehicle + "\\"

#Find the Path for the newfile which has been created
newFilePath = newPath + hardware + "-" + module + "-" + newValue + ".xml"
newFilePath = newPath + newValue + ".xml"
#Find the name of the new file
newFile = hardware + "-" + module + "-" + newValue + ".xml"
newFile = newValue + ".xml"

# Parse the xml file into the python viewer and get the first root
newFileXML = ET.parse(newFilePath)
Expand Down Expand Up @@ -372,13 +389,22 @@ def updateFileButtonClicked(self):

def fileLocationPressed(self):
#Used for setting the location of the IVS Files
fileLoc = str(QtWidgets.QFileDialog.getExistingDirectory(None, "Select Directory"))
with open(r'config.json') as json_file:
data = json.load(json_file)
fileLocation = data["ivsPath"]

fileLoc = str(QtWidgets.QFileDialog.getExistingDirectory(None, "Select Directory", fileLocation))
#Stores it in the filelocationLineEdit
data["ivsPath"] = fileLoc

with open(r'config.json', 'w') as outfile:
json.dump(data, outfile)

self.fileLocationLineEdit.setText(fileLoc)
global path
path = fileLoc + "\\"

#Initalise the comboboxes once its been selected
#Initalise the combobox for vehicles
self.initaliseComboBox()

def closeEvent(self, Previous, event):
Expand Down Expand Up @@ -493,6 +519,7 @@ def setupUi(self, Dialog):
self.vehicleComboBox.activated.connect(self.vehicleComboBoxSelected)
self.hardwareComboBox.activated.connect(self.hardwareComboBoxSelected)
self.moduleComboBox.activated.connect(self.moduleComboBoxSelected)
self.valueComboBox.activated.connect(self.valueComboBoxSelected)
self.updateAreaComboBox.activated.connect(self.updateAreaComboBoxSelected)

#Activating the Buttons on the UI When they are pressed
Expand All @@ -502,6 +529,7 @@ def setupUi(self, Dialog):

self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
self.InitalLoad()


def retranslateUi(self, Dialog):
Expand Down
33 changes: 33 additions & 0 deletions Name_Of_App.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['Name_Of_File.py'],
pathex=['C:\\Users\\bgarman\\Documents\\Projects\\Harrys IVS Editor'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='Name_Of_App',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False , icon='Name_Of_Icon.ico')
46 changes: 39 additions & 7 deletions ODXF_Creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,36 @@
import os, glob
import xml.etree.ElementTree as ET
import datetime
import json
from functools import partial



class Ui_Dialog(object):

def InitalLoad(self):
with open(r'config.json') as json_file:
data = json.load(json_file)
fileLocation = data["odxfPath"]
if fileLocation != "":
self.fileLocationLineEdit.setText(fileLocation)
global path
path = fileLocation + "\\"
self.initaliseVehicleComboBox()

def fileLocationButtonPushed(self):
#Used for setting the location of the IVS Files
fileLoc = str(QtWidgets.QFileDialog.getExistingDirectory(None, "Select Directory"))
with open(r'config.json') as json_file:
data = json.load(json_file)
fileLocation = data["odxfPath"]

fileLoc = str(QtWidgets.QFileDialog.getExistingDirectory(None, "Select Directory", fileLocation))
#Stores it in the filelocationLineEdit
data["odxfPath"] = fileLoc

with open(r'config.json', 'w') as outfile:
json.dump(data, outfile)

self.fileLocationLineEdit.setText(fileLoc)
global path
path = fileLoc + "\\"
Expand Down Expand Up @@ -46,6 +66,9 @@ def vehicleComboBoxSelected(self):
#Add to the modules list
modules.append(y.split("-")[1])
#Remopve dupliactes
modules.insert(1,"19L310")
modules.insert(2,"19L320")

modules = list(dict.fromkeys(modules))
#Clear the combo box and append the modules
self.moduleComboBox.clear()
Expand Down Expand Up @@ -92,6 +115,10 @@ def hardwareComboBoxSelected(self):
self.valueComboBox.clear()
self.valueComboBox.addItems(value)

def valueComboBoxSelected(self):
self.fileLineEdit.setText(self.hardwareComboBox.currentText() + "-" + self.moduleComboBox.currentText() + "-")


def saveXML(self, XML, path):
#Used for saving the xml to a specific file path
XML.write(path, encoding='utf-8', xml_declaration=True)
Expand All @@ -117,7 +144,7 @@ def createFileButtonPushed(self):
prevFilePath = glob.glob(newPath + hardware +"*" + module + "*" + prevValue + ".xml")[0]
prevFile = prevFilePath.split("\\")
prevFile = prevFile[len(prevFile) - 1].split(".xml")[0]
newFilePath = newPath + hardware + "-" + module + "-" + newValue + ".xml"
newFilePath = newPath + newValue + ".xml"
newFile = newFilePath.split("\\")
newFile = newFile[len(newFile) - 1].split(".xml")[0]

Expand Down Expand Up @@ -169,7 +196,7 @@ def initaliseTypeComboBox(self):
module = self.moduleComboBox.currentText()
hardware = self.hardwareComboBox.currentText()
newValue = self.fileLineEdit.text()
newFilePath = path + vehicle + "\\" + hardware + "-" + module + "-" + newValue + ".xml"
newFilePath = path + vehicle + "\\" + newValue + ".xml"

newFileXML = ET.parse(newFilePath)
newFileRoot = newFileXML.getroot()
Expand Down Expand Up @@ -212,7 +239,7 @@ def typeComboBoxSelected(self):
module = self.moduleComboBox.currentText()
hardware = self.hardwareComboBox.currentText()
newValue = self.fileLineEdit.text()
newFilePath = path + vehicle + "\\" + hardware + "-" + module + "-" + newValue + ".xml"
newFilePath = path + vehicle + "\\" + newValue + ".xml"

newFileXML = ET.parse(newFilePath)
newFileRoot = newFileXML.getroot()
Expand All @@ -226,22 +253,24 @@ def typeComboBoxSelected(self):
#Checks if it is the correct area
if x.attrib["ID"] == idName:
#If it is update the placeholder text
self.partNumberLineEdit.setPlaceholderText("Prev: " + x[1].text)
temp = x[1].text.split("-")
self.partNumberLineEdit.setText(temp[0] + "-" + temp[1] + "-")
else:
#Get the id from the combobox
idName = self.typeComboBox.currentText().split(" - ")[0]
idName = idName.split("_")
prev = idName[2] + "-" + idName[3] + "-" + idName[4]
#Set the placeholder to previous value
self.partNumberLineEdit.setPlaceholderText("Prev: " + prev)
temp = prev.split("-")
self.partNumberLineEdit.setText(temp[0] + "-" + temp[1] + "-")

def updateFileButtonPushed(self):
# Getting the text from the comboboxes selected
vehicle = self.vehicleComboBox.currentText()
module = self.moduleComboBox.currentText()
hardware = self.hardwareComboBox.currentText()
newValue = self.fileLineEdit.text()
newFilePath = path + vehicle + "\\" + hardware + "-" + module + "-" + newValue + ".xml"
newFilePath = path + vehicle + "\\" + newValue + ".xml"

newFileXML = ET.parse(newFilePath)
newFileRoot = newFileXML.getroot()
Expand Down Expand Up @@ -369,6 +398,7 @@ def closeEvent(self, Previous, event):

def setupUi(self, Dialog):
#Code to create the UI Design

Dialog.setObjectName("Dialog")
Dialog.resize(774, 510)
Dialog.closeEvent = partial(self.closeEvent, Dialog)
Expand Down Expand Up @@ -502,9 +532,11 @@ def setupUi(self, Dialog):
self.vehicleComboBox.activated.connect(self.vehicleComboBoxSelected)
self.moduleComboBox.activated.connect(self.moduleComboBoxSelected)
self.hardwareComboBox.activated.connect(self.hardwareComboBoxSelected)
self.valueComboBox.activated.connect(self.valueComboBoxSelected)
self.typeComboBox.activated.connect(self.typeComboBoxSelected)

self.retranslateUi(Dialog)
self.InitalLoad()
QtCore.QMetaObject.connectSlotsByName(Dialog)

def retranslateUi(self, Dialog):
Expand Down
Binary file modified __pycache__/IVS_Creator.cpython-37.pyc
Binary file not shown.
Binary file modified __pycache__/ODXF_Creator.cpython-37.pyc
Binary file not shown.
Loading

0 comments on commit bb2e824

Please sign in to comment.