Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def entry_changed(self, event=None):
# log.debug("entry_changed")
# char = event.keysym
pathI = self.entry_i.get()
if self.pathI != pathI:
formatD = self.combobox_i.get()
if pathI.startswith("file://"):
pathI = urlToPath(pathI)
self.entry_i.delete(0, "end")
self.entry_i.insert(0, pathI)
if self.pref["ui_autoSetFormat"]:
ext = os.path.splitext(pathI)[-1].lower()
if ext in (".gz", ".bz2", ".zip"):
ext = os.path.splitext(pathI[:-len(ext)])[-1].lower()
for i in range(len(Glossary.readExt)):
if ext in Glossary.readExt[i]:
self.combobox_i.set(Glossary.readDesc[i])
break
if self.pref["ui_autoSetOutputFileName"]:
# pathI = self.entry_i.get()
formatOD = self.combobox_o.get()
pathO = self.entry_o.get()
if formatOD and not pathO and "." in pathI:
extO = Glossary.descExt[formatOD]
def reverseInputEntryChanged(self, widget=None):
inPath = self.reverseInputEntry.get_text()
inFormat = self.reverseInputFormatCombo.getActive()
if inPath.startswith("file://"):
inPath = urlToPath(inPath)
self.reverseInputEntry.set_text(inPath)
inExt = getCopressedFileExt(inPath)
inFormatNew = Glossary.extFormat.get(inExt)
if inFormatNew and self.pref["ui_autoSetFormat"] and not inFormat:
self.reverseInputFormatCombo.setActive(inFormatNew)
if self.pref["ui_autoSetOutputFileName"]:
outExt = ".txt"
outPath = self.reverseOutputEntry.get_text()
if inFormatNew and not outPath:
outPath = splitext(inPath)[0] + "-reversed" + outExt
self.reverseOutputEntry.set_text(outPath)
if self.pref["ui_autoSetOutputFileName"]:
# pathI = self.entry_i.get()
formatOD = self.combobox_o.get()
pathO = self.entry_o.get()
if formatOD and not pathO and "." in pathI:
extO = Glossary.descExt[formatOD]
pathO = "".join(os.path.splitext(pathI)[:-1]) + extO
self.entry_o.delete(0, "end")
self.entry_o.insert(0, pathO)
self.pathI = pathI
##############################################
pathO = self.entry_o.get()
if self.pathO != pathO:
formatD = self.combobox_o.get()
if pathO.startswith("file://"):
pathO = urlToPath(pathO)
self.entry_o.delete(0, "end")
self.entry_o.insert(0, pathO)
if self.pref["ui_autoSetFormat"]:
ext = os.path.splitext(pathO)[-1].lower()
if ext in (".gz", ".bz2", ".zip"):
ext = os.path.splitext(pathO[:-len(ext)])[-1].lower()
for i in range(len(Glossary.writeExt)):
if ext in Glossary.writeExt[i]:
self.combobox_o.set(Glossary.writeDesc[i])
break
self.pathO = pathO
def convertOutputEntryChanged(self, widget=None):
outPath = self.convertOutputEntry.get_text()
outFormat = self.convertOutputFormatCombo.getActive()
if not outPath:
return
# outFormat = self.combobox_o.get_active_text()
if outPath.startswith("file://"):
outPath = urlToPath(outPath)
self.convertOutputEntry.set_text(outPath)
if self.pref["ui_autoSetFormat"] and not outFormat:
outExt = getCopressedFileExt(outPath)
try:
outFormatNew = Glossary.extFormat[outExt]
except KeyError:
pass
else:
self.convertOutputFormatCombo.setActive(outFormatNew)
if self.convertOutputFormatCombo.getActive():
self.status("Press \"Convert\"")
else:
self.status("Select output format")
def convertOutputEntryChanged(self, widget=None):
outPath = self.convertOutputEntry.get_text()
outFormat = self.convertOutputFormatCombo.getActive()
if not outPath:
return
#outFormat = self.combobox_o.get_active_text()
if len(outPath)>7:
if outPath[:7]=='file://':
outPath = urlToPath(outPath)
self.convertOutputEntry.set_text(outPath)
if self.pref['auto_set_for']:## and not outFormat:
outExt = getCopressedFileExt(outPath)
try:
outFormatNew = Glossary.extFormat[outExt]
except KeyError:
pass
else:
self.convertOutputFormatCombo.setActive(outFormatNew)
def convertInputEntryChanged(self, widget=None):
inPath = self.convertInputEntry.get_text()
inFormat = self.convertInputFormatCombo.getActive()
if inPath.startswith("file://"):
inPath = urlToPath(inPath)
self.convertInputEntry.set_text(inPath)
inExt = getCopressedFileExt(inPath)
inFormatNew = Glossary.extFormat.get(inExt)
if not inFormatNew:
return
if not isfile(inPath):
return
if self.pref["ui_autoSetFormat"] and not inFormat:
self.convertInputFormatCombo.setActive(inFormatNew)
self.status("Select output file")
if self.pref["ui_autoSetOutputFileName"]:
def convertInputEntryChanged(self, widget=None):
inPath = self.convertInputEntry.get_text()
inFormat = self.convertInputFormatCombo.getActive()
if len(inPath) > 7:
if inPath[:7]=='file://':
inPath = urlToPath(inPath)
self.convertInputEntry.set_text(inPath)
if self.pref['auto_set_for']:## and not inFormat:
inExt = getCopressedFileExt(inPath)
try:
inFormatNew = Glossary.extFormat[inExt]
except KeyError:
pass
else:
self.convertInputFormatCombo.setActive(inFormatNew)
if self.pref['auto_set_out']:
outFormat = self.convertOutputFormatCombo.getActive()
outPath = self.convertOutputEntry.get_text()
if outFormat and not outPath and '.' in inPath:
outPath = os.path.splitext(inPath)[0] + Glossary.formatsExt[outFormat][0]