From beb99322412889c01e812e0db39ed777a8afb2cc Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Wed, 20 Mar 2024 14:39:16 +0100 Subject: [PATCH] remove usage of six.print_() --- samples/printing/printing.py | 29 +++++++-------- samples/roses/clroses.py | 11 +++--- samples/roses/wxroses.py | 39 +++++++++++---------- samples/simple/events.py | 14 ++++---- wx/lib/pubsub/utils/misc.py | 5 +-- wx/lib/pubsub/utils/xmltopicdefnprovider.py | 4 ++- wx/tools/pywxrc.py | 24 +++++++------ 7 files changed, 67 insertions(+), 59 deletions(-) diff --git a/samples/printing/printing.py b/samples/printing/printing.py index 638d5cde..8af9a05e 100644 --- a/samples/printing/printing.py +++ b/samples/printing/printing.py @@ -1,5 +1,6 @@ +from __future__ import print_function + import wx -from six import print_ import os FONTSIZE = 10 @@ -180,7 +181,7 @@ class PrintFrameworkSample(wx.Frame): data = dlg.GetPageSetupData() self.pdata = wx.PrintData(data.GetPrintData()) # force a copy self.pdata.SetPaperId(data.GetPaperId()) - #print_("paperID %r, paperSize %r" % (self.pdata.GetPaperId(), self.pdata.GetPaperSize())) + #print("paperID %r, paperSize %r" % (self.pdata.GetPaperId(), self.pdata.GetPaperSize())) self.margins = (data.GetMarginTopLeft(), data.GetMarginBottomRight()) dlg.Destroy() @@ -226,20 +227,20 @@ class PrintFrameworkSample(wx.Frame): dlg = wx.PrintDialog(self, data) if dlg.ShowModal() == wx.ID_OK: data = dlg.GetPrintDialogData() - print_() - print_("GetFromPage:", data.GetFromPage()) - print_("GetToPage:", data.GetToPage()) - print_("GetMinPage:", data.GetMinPage()) - print_("GetMaxPage:", data.GetMaxPage()) - print_("GetNoCopies:", data.GetNoCopies()) - print_("GetAllPages:", data.GetAllPages()) - print_("GetSelection:", data.GetSelection()) - print_("GetCollate:", data.GetCollate()) - print_("GetPrintToFile:", data.GetPrintToFile()) + print() + print("GetFromPage:", data.GetFromPage()) + print("GetToPage:", data.GetToPage()) + print("GetMinPage:", data.GetMinPage()) + print("GetMaxPage:", data.GetMaxPage()) + print("GetNoCopies:", data.GetNoCopies()) + print("GetAllPages:", data.GetAllPages()) + print("GetSelection:", data.GetSelection()) + print("GetCollate:", data.GetCollate()) + print("GetPrintToFile:", data.GetPrintToFile()) self.pdata = wx.PrintData(data.GetPrintData()) - print_() - print_("GetPrinterName:", self.pdata.GetPrinterName()) + print() + print("GetPrinterName:", self.pdata.GetPrinterName()) dlg.Destroy() diff --git a/samples/roses/clroses.py b/samples/roses/clroses.py index a5a87866..f25ac93b 100644 --- a/samples/roses/clroses.py +++ b/samples/roses/clroses.py @@ -36,8 +36,9 @@ # ideal Roses program should be, however, callers are welcome to assert their # independence, override defaults, ignore features, etc. +from __future__ import print_function + from math import sin, cos, pi -from six import print_ # Rose class knows about: # > Generating points and vectors (returning data as a list of points) @@ -151,7 +152,7 @@ class rose: # update parameters or stop. def restart(self): if self.verbose: - print_('restart: int_state', self.int_state, 'cmd_state', self.cmd_state) + print('restart: int_state', self.int_state, 'cmd_state', self.cmd_state) try: tmp = self.sin_table[0] except: @@ -192,7 +193,7 @@ class rose: # before initialization is done. def repaint(self, delay): if self.int_state != self.INT_RESIZE: - # print_('repaint after', delay) + # print('repaint after', delay) self.int_state = self.INT_RESIZE self.AppCancelTimer() self.AppAfter(delay, self.clock) @@ -264,7 +265,7 @@ class rose: # roses is 0.) def clock(self): if self.int_state == self.INT_IDLE: - # print_('clock called in idle state') + # print('clock called in idle state') delay = 0 elif self.int_state == self.INT_DRAW: line, run = self.roselet() @@ -295,7 +296,7 @@ class rose: if delay == 0: if self.verbose: - print_('clock: going idle from state', self.int_state) + print('clock: going idle from state', self.int_state) else: self.AppAfter(delay, self.clock) diff --git a/samples/roses/wxroses.py b/samples/roses/wxroses.py index 7f8e3a7e..645f56aa 100644 --- a/samples/roses/wxroses.py +++ b/samples/roses/wxroses.py @@ -68,10 +68,11 @@ # control the display (without blocking the user's control) would be pretty # straightforward. +from __future__ import print_function + import wx import clroses import wx.lib.colourselect as cs -from six import print_ # Class SpinPanel creates a control that includes both a StaticText widget # which holds the the name of a parameter and a SpinCtrl widget which @@ -109,7 +110,7 @@ class SpinPanel(wx.Panel): name = self.st.GetLabel() value = self.sc.GetValue() if verbose: - print_('OnSpin', name, '=', value) + print('OnSpin', name, '=', value) self.callback(name, value) # Call MyFrame.OnSpinback to call clroses @@ -372,10 +373,10 @@ class MyFrame(wx.Frame, clroses.rose): h = max(600, fh) # Change 600 to desired minimum size w = h + fw - rw if verbose: - print_('rose panel size', (rw, rh)) - print_('side panel size', (sw, sh)) - print_(' frame size', (fw, fh)) - print_('Want size', (w,h)) + print('rose panel size', (rw, rh)) + print('side panel size', (sw, sh)) + print(' frame size', (fw, fh)) + print('Want size', (w,h)) self.SetSize((w, h)) self.SupplyControlValues() # Ask clroses to tell us all the defaults self.Show() @@ -386,25 +387,25 @@ class MyFrame(wx.Frame, clroses.rose): # Go/Stop button def OnGoStop(self, event): if verbose: - print_('OnGoStop') + print('OnGoStop') self.cmd_go_stop() # Redraw/Redraw def OnRedraw(self, event): if verbose: - print_('OnRedraw') + print('OnRedraw') self.cmd_redraw() # Backward/Reverse def OnBackward(self, event): if verbose: - print_('OnBackward') + print('OnBackward') self.cmd_backward() # Forward/Skip def OnForward(self, event): if verbose: - print_('OnForward') + print('OnForward') self.cmd_step() @@ -415,7 +416,7 @@ class MyFrame(wx.Frame, clroses.rose): def AppClear(self): if verbose: - print_('AppClear: clear screen') + print('AppClear: clear screen') self.rose_panel.Clear() def AppCreateLine(self, line): @@ -467,8 +468,8 @@ class MyFrame(wx.Frame, clroses.rose): # Method to provide a single callback after some amount of time. def AppAfter(self, msec, callback): if self.timer_callback: - print_('AppAfter: timer_callback already set!') - # print_('AppAfter:', callback) + print('AppAfter: timer_callback already set!') + # print('AppAfter:', callback) self.timer_callback = callback self.timer.Start(msec, True) @@ -476,14 +477,14 @@ class MyFrame(wx.Frame, clroses.rose): # interest in. def AppCancelTimer(self): self.timer.Stop() - # print_('AppCancelTimer') + # print('AppCancelTimer') self.timer_callback = None # When the timer happens, we come here and jump off to clroses internal code. def OnTimer(self, evt): callback = self.timer_callback self.timer_callback = None - # print_('OnTimer,', callback) + # print('OnTimer,', callback) if callback: callback() # Often calls AppAfter() and sets the callback else: @@ -502,7 +503,7 @@ class MyFrame(wx.Frame, clroses.rose): # Called when data in spin boxes changes. def OnSpinback(self, name, value): if verbose: - print_('OnSpinback', name, value) + print('OnSpinback', name, value) if name == 'Style': self.SetStyle(value) elif name == 'Sincr': @@ -530,7 +531,7 @@ class MyFrame(wx.Frame, clroses.rose): elif name == 'Delay': self.SetWaitDelay(value) else: - print_('OnSpinback: Don\'t recognize', name) + print('OnSpinback: Don\'t recognize', name) verbose = 0 # Need some command line options... spin_panels = {} # Hooks to get from rose to panel labels @@ -539,6 +540,6 @@ ctrl_buttons = {} # Button widgets for command (NE) panel app = wx.App(False) MyFrame() if verbose: - print_('spin_panels', list(spin_panels)) - print_('ctrl_buttons', list(ctrl_buttons)) + print('spin_panels', list(spin_panels)) + print('ctrl_buttons', list(ctrl_buttons)) app.MainLoop() diff --git a/samples/simple/events.py b/samples/simple/events.py index af58312a..112875bd 100644 --- a/samples/simple/events.py +++ b/samples/simple/events.py @@ -1,9 +1,9 @@ +from __future__ import print_function import wx -from six import print_ -print_(wx.version()) -#import os; print_('PID:', os.getpid()); raw_input('Ready to start, press enter...') +print(wx.version()) +#import os; print('PID:', os.getpid()); raw_input('Ready to start, press enter...') class MyFrame(wx.Frame): @@ -13,21 +13,21 @@ class MyFrame(wx.Frame): wx.CallAfter(self.after, 1, 2, 3) def after(self, a, b, c): - print_('Called via wx.CallAfter:', a, b, c) + print('Called via wx.CallAfter:', a, b, c) def onSize(self, evt): - print_(repr(evt.Size)) + print(repr(evt.Size)) evt.Skip() class MyApp(wx.App): def OnInit(self): - print_('OnInit') + print('OnInit') frm = MyFrame(None, title="Hello with Events", size=(480,360)) frm.Show() return True def OnExit(self): - print_('OnExit') + print('OnExit') return 0 app = MyApp() diff --git a/wx/lib/pubsub/utils/misc.py b/wx/lib/pubsub/utils/misc.py index 7d772746..29a4b931 100644 --- a/wx/lib/pubsub/utils/misc.py +++ b/wx/lib/pubsub/utils/misc.py @@ -6,8 +6,9 @@ printTreeDocs and printTreeSpec. :license: BSD, see LICENSE_BSD_Simple.txt for details. """ +from __future__ import print_function + import sys -from .. import py2and3 __all__ = ('printImported', 'StructMsg', 'Callback', 'Enum' ) @@ -16,7 +17,7 @@ def printImported(): """Output a list of pubsub modules imported so far""" ll = sorted([mod for mod in sys.modules if mod.find('pubsub') >= 0]) - py2and3.print_('\n'.join(ll)) + print('\n'.join(ll)) class StructMsg: diff --git a/wx/lib/pubsub/utils/xmltopicdefnprovider.py b/wx/lib/pubsub/utils/xmltopicdefnprovider.py index 20954cc5..e9b4ea34 100644 --- a/wx/lib/pubsub/utils/xmltopicdefnprovider.py +++ b/wx/lib/pubsub/utils/xmltopicdefnprovider.py @@ -45,6 +45,8 @@ of the XML tree. :license: BSD, see LICENSE_BSD_Simple.txt for details. """ +from __future__ import print_function + __author__ = 'Joshua R English' __revision__ = 6 __date__ = '2013-07-27' @@ -80,7 +82,7 @@ def _get_elem(elem): try: elem = ET.fromstring(elem) except: - py2and3.print_("Value Error", elem) + print("Value Error", elem) raise ValueError("Cannot convert to element") return elem diff --git a/wx/tools/pywxrc.py b/wx/tools/pywxrc.py index 8596940d..552fcba1 100644 --- a/wx/tools/pywxrc.py +++ b/wx/tools/pywxrc.py @@ -31,9 +31,11 @@ Usage: python pywxrc.py -h -o, --output output filename, or - for stdout """ +from __future__ import print_function + import sys, os, getopt, glob, re import xml.dom.minidom as minidom -from six import print_, byte2int +from six import byte2int #---------------------------------------------------------------------- @@ -286,7 +288,7 @@ class XmlResourceCompiler: gettextStrings += self.FindStringsInNode(resourceDocument.firstChild) # now write it all out - print_(self.templates.FILE_HEADER, file=outputFile) + print(self.templates.FILE_HEADER, file=outputFile) # Note: Technically it is not legal to have anything other # than ascii for class and variable names, but since the user @@ -295,23 +297,23 @@ class XmlResourceCompiler: # later when they try to run the program. if subclasses: subclasses = self.ReplaceBlocks(u"\n".join(subclasses)) - print_(subclasses, file=outputFile) + print(subclasses, file=outputFile) if classes: classes = self.ReplaceBlocks(u"\n".join(classes)) - print_(classes, file=outputFile) + print(classes, file=outputFile) - print_(self.templates.INIT_RESOURE_HEADER, file=outputFile) + print(self.templates.INIT_RESOURE_HEADER, file=outputFile) if embedResources: - print_(self.templates.PREPARE_MEMFS, file=outputFile) + print(self.templates.PREPARE_MEMFS, file=outputFile) resources = u"\n".join(resources) - print_(resources, file=outputFile) + print(resources, file=outputFile) if generateGetText: # gettextStrings is a list of unicode strings as returned by ConvertText conversions = [u' _("%s")' % s for s in gettextStrings] conversion_block = u"\n".join(conversions) conversion_func = self.templates.GETTEXT_DUMMY_FUNC % conversion_block - print_(conversion_func, file=outputFile) + print(conversion_func, file=outputFile) #------------------------------------------------------------------- @@ -327,7 +329,7 @@ class XmlResourceCompiler: strings = self.FindStringsInNode(resource) # strings is a list of unicode strings as returned by ConvertText strings = ['_("%s");' % s for s in strings] - print_("\n".join(strings), file=outputFile) + print("\n".join(strings), file=outputFile) #------------------------------------------------------------------- @@ -940,10 +942,10 @@ def main(args=None): except IOError as exc: - print_("%s." % str(exc), file=sys.stderr) + print("%s." % str(exc), file=sys.stderr) else: if outputFilename != "-": - print_("Resources written to %s." % outputFilename, file=sys.stderr) + print("Resources written to %s." % outputFilename, file=sys.stderr) if __name__ == "__main__": main(sys.argv[1:])