summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/scripting/scripts/copycenter/CopyCenter.py
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2023-01-22 02:02:13 +0100
committerSlávek Banko <[email protected]>2023-01-22 02:02:13 +0100
commit86480e58eafc1fa3486e03155ed34e02b4595a24 (patch)
tree0e8f64c4003ea558e946b7a3347688904b451635 /kexi/plugins/scripting/scripts/copycenter/CopyCenter.py
parent135d005014a1e85295af4e379f026a361537ae5f (diff)
downloadkoffice-86480e58eafc1fa3486e03155ed34e02b4595a24.tar.gz
koffice-86480e58eafc1fa3486e03155ed34e02b4595a24.zip
Drop python2 support in scripts.
Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'kexi/plugins/scripting/scripts/copycenter/CopyCenter.py')
-rw-r--r--kexi/plugins/scripting/scripts/copycenter/CopyCenter.py66
1 files changed, 33 insertions, 33 deletions
diff --git a/kexi/plugins/scripting/scripts/copycenter/CopyCenter.py b/kexi/plugins/scripting/scripts/copycenter/CopyCenter.py
index edcc2891..7c934da3 100644
--- a/kexi/plugins/scripting/scripts/copycenter/CopyCenter.py
+++ b/kexi/plugins/scripting/scripts/copycenter/CopyCenter.py
@@ -27,7 +27,7 @@ class CopyCenter:
return getattr(self.plugin, plugintype)(self.plugin)
except:
import traceback
- print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
+ print("".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
return None
def __init__(self, scriptpath):
@@ -38,7 +38,7 @@ class CopyCenter:
import os
import sys
if not os.path.exists(scriptpath):
- print "The Path %s does not exist" % scriptpath
+ print("The Path %s does not exist" % scriptpath)
else:
import re
regexp = re.compile('^CopyCenterPlugin(.*)\\.py$')
@@ -47,17 +47,17 @@ class CopyCenter:
if not os.path.isfile(file): continue
m = regexp.match(f)
if not m: continue
- print "Plugin name=%s file=%s" % (m.group(1),file)
+ print("Plugin name=%s file=%s" % (m.group(1),file))
mylocals = {}
try:
- execfile(file, globals(), mylocals)
- if mylocals.has_key("CopyCenterPlugin"):
+ exec(compile(open(file, "rb").read(), file, 'exec'), globals(), mylocals)
+ if "CopyCenterPlugin" in mylocals:
plugin = mylocals.get("CopyCenterPlugin")(self)
self.plugins[plugin.name] = self.Plugin(plugin)
except:
- print "Failed to import file=%s" % file
+ print("Failed to import file=%s" % file)
import traceback
- print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
+ print("".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
def getHomePath(self):
""" Return the homedirectory. """
@@ -163,20 +163,20 @@ def runGuiApp(copycenter, name):
#qt.TQObject.connect(self.listview, qt.SIGNAL("itemRenamed(QListViewItem*, int, const QString&)"), self.itemRenamed)
def doubleClicked(self, **args):
- print "CopyJobWidget.doubleClicked"
+ print("CopyJobWidget.doubleClicked")
item = self.listview.selectedItem()
if item and item.parent(): item.startRename(1)
def readOptions(self,domnode,plugininst):
- print "CopyJobWidget.readOptions plugintype=\"%s\"" % plugininst.plugintype
+ print("CopyJobWidget.readOptions plugintype=\"%s\"" % plugininst.plugintype)
for node in domnode.childNodes:
if node.nodeType == node.ELEMENT_NODE:
v = node.getAttribute("value")
plugininst.options[node.nodeName] = v
- print "Option \"%s\" has value \"%s\" now." % (node.nodeName, v)
+ print("Option \"%s\" has value \"%s\" now." % (node.nodeName, v))
def jobfilecomboboxChanged(self, **args):
- print "CopyJobWidget.jobfilecomboboxChanged"
+ print("CopyJobWidget.jobfilecomboboxChanged")
import os
import xml.dom.minidom
filename = str(self.jobfilecombobox.currentText())
@@ -187,16 +187,16 @@ def runGuiApp(copycenter, name):
sourcenode = elements.getElementsByTagName("Source")[0]
destinationnode = elements.getElementsByTagName("Destination")[0]
except:
- raise "The XML-file \"%s\" does not contain a valid copy-job." % filename
+ raise Exception("The XML-file \"%s\" does not contain a valid copy-job." % filename)
sourcepluginname = str(sourcenode.getAttribute('plugin'))
if not self.dialog.sourcedata.combobox.listBox().findItem(sourcepluginname,qt.TQt.ExactMatch):
- raise "There exists no plugin with the name \"%s\"." % sourcepluginname
+ raise Exception("There exists no plugin with the name \"%s\"." % sourcepluginname)
self.dialog.sourcedata.combobox.setCurrentText(sourcepluginname)
destinationpluginname = str(destinationnode.getAttribute('plugin'))
if not self.dialog.destinationdata.combobox.listBox().findItem(destinationpluginname,qt.TQt.ExactMatch):
- raise "There exists no plugin with the name \"%s\"." % destinationpluginname
+ raise Exception("There exists no plugin with the name \"%s\"." % destinationpluginname)
self.dialog.destinationdata.combobox.setCurrentText(destinationpluginname)
self.readOptions(sourcenode,self.dialog.getSourcePluginImpl())
@@ -213,10 +213,10 @@ def runGuiApp(copycenter, name):
return s.replace("&", "&amp;").replace("'", "&apos;").replace("<", "&lt;").replace(">", "&gt;").replace('"', "&quot;")
def writeOptions(self,writer,pluginname,plugininst):
- print "CopyJobWidget.writeOptions"
+ print("CopyJobWidget.writeOptions")
writer.write("<%s plugin=\"%s\">\n" % (plugininst.plugintype, pluginname))
for optionname in plugininst.options:
- value = self.escape( unicode(plugininst.options[optionname]).encode("utf-8") )
+ value = self.escape( str(plugininst.options[optionname]).encode("utf-8") )
writer.write("\t<%s value=\"%s\" />\n" % (optionname,value))
writer.write("</%s>\n" % plugininst.plugintype)
@@ -236,7 +236,7 @@ def runGuiApp(copycenter, name):
self.writeOptions(f, destinationpluginname, self.dialog.getDestinationPluginImpl())
f.write("</CopyCenterJob>\n")
f.close()
- print "File \%s\" successfully written." % filename
+ print("File \%s\" successfully written." % filename)
def addItem(self, pluginimpl, afteritem = None, parentitem = None):
#print "CopyJobWidget.addItem"
@@ -262,11 +262,11 @@ def runGuiApp(copycenter, name):
def okRename(self, columnindex):
if columnindex == 1:
n = str(self.text(0))
- if not self.pluginimpl.options.has_key(n):
- raise "No such option \"%s\"" % n
+ if n not in self.pluginimpl.options:
+ raise Exception("No such option \"%s\"" % n)
qt.TQListViewItem.okRename(self,columnindex)
v = str(qt.TQListViewItem.text(self,1))
- print "Option \"%s\" has value \"%s\" now." % (n,v)
+ print("Option \"%s\" has value \"%s\" now." % (n,v))
self.pluginimpl.options[n] = v
def text(self, columnindex):
@@ -287,18 +287,18 @@ def runGuiApp(copycenter, name):
afteritem = self.addItem(pluginimpl, afteritem, item)
afteritem.setText(0,str(i))
afteritem.setText(1,str(pluginimpl.options[i]))
- print "CopyJobWidget.updateItem Added item with name \"%s\" and value \"%s\"" % (str(i),str(pluginimpl.options[i]))
+ print("CopyJobWidget.updateItem Added item with name \"%s\" and value \"%s\"" % (str(i),str(pluginimpl.options[i])))
pass
def maybeUpdate(self):
- print "CopyJobWidget.maybeUpdate"
+ print("CopyJobWidget.maybeUpdate")
self.listview.clear()
try:
self.updateItem(self.dialog.getDestinationPluginName(), self.dialog.getDestinationPluginImpl())
self.updateItem(self.dialog.getSourcePluginName(), self.dialog.getSourcePluginImpl())
except:
import traceback
- print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
+ print("".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
self.listview.clear()
#--------------------------------------------------------------------
@@ -382,7 +382,7 @@ def runGuiApp(copycenter, name):
sourceimpl = self.dialog.getSourcePluginImpl()
self.textbrowser.append("Source: %s" % sourcename)
if sourceimpl == None:
- raise "No such source."
+ raise Exception("No such source.")
try:
sourceimpl.init(copierer)
@@ -391,7 +391,7 @@ def runGuiApp(copycenter, name):
destinationimpl = self.dialog.getDestinationPluginImpl()
self.textbrowser.append("<hr>Destination: %s" % destinationname)
if destinationimpl == None:
- raise "No such destination."
+ raise Exception("No such destination.")
try:
destinationimpl.init(copierer)
@@ -418,7 +418,7 @@ def runGuiApp(copycenter, name):
self.setCaption("Copy failed")
self.textbrowser.append("<b>Error: %s</b>" % sys.exc_info()[0])
import traceback
- print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
+ print("".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
#self.progressbar.setEnabled(False)
self.donebtn.setEnabled(True)
self.cancelbtn.setEnabled(False)
@@ -468,11 +468,11 @@ def runGuiApp(copycenter, name):
self.scrollview.viewport().setPaletteBackgroundColor(self.paletteBackgroundColor())
except:
import traceback
- print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
+ print("".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
qt.TQObject.connect(self.combobox, qt.SIGNAL("activated(int)"), self.activated)
def updatePlugin(self):
- print "DataSelector.updatePlugin"
+ print("DataSelector.updatePlugin")
self.pluginimpl = None
text = str(self.combobox.currentText())
plugin = self.dialog.copycenter.plugins[text]
@@ -488,7 +488,7 @@ def runGuiApp(copycenter, name):
self.mainbox = None
def updateMainBox(self):
- print "DataSelector.updateMainBox"
+ print("DataSelector.updateMainBox")
self.removeMainBox()
self.mainbox = qt.TQVBox( self.scrollview.viewport() )
self.mainbox.setSpacing(2)
@@ -497,7 +497,7 @@ def runGuiApp(copycenter, name):
self.pluginimpl.createWidget(self.dialog, self.mainbox)
except:
import traceback
- print "".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) )
+ print("".join( traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) ))
self.mainbox.setStretchFactor(qt.TQWidget(self.mainbox), 1)
self.mainbox.show()
self.scrollview.addChild(self.mainbox)
@@ -507,12 +507,12 @@ def runGuiApp(copycenter, name):
self.updateMainBox()
def maybeUpdate(self):
- print "DataSelector.maybeUpdate"
+ print("DataSelector.maybeUpdate")
self.removeMainBox()
qt.TQTimer.singleShot(50, self.activated)
def maybeDone(self):
- print "DataSelector.maybeDone"
+ print("DataSelector.maybeDone")
if self.pluginimpl.widget == None: return
for optionname in self.pluginimpl.options:
self.pluginimpl.options[optionname] = self.pluginimpl.widget.getOptionValue(optionname)
@@ -588,7 +588,7 @@ def runGuiApp(copycenter, name):
defaultfile = os.path.join(self.copycenter.homepath,"default.copycenterjob.xml")
if os.path.isfile(defaultfile):
- print "Reading default copy job file: %s" % defaultfile
+ print("Reading default copy job file: %s" % defaultfile)
self.jobsbox.jobfilecombobox.setCurrentText(defaultfile)
def getSourcePluginName(self):