diff --git a/src/nodeforge/PluginManager.py b/src/nodeforge/PluginManager.py index ade27a4..93a232b 100644 --- a/src/nodeforge/PluginManager.py +++ b/src/nodeforge/PluginManager.py @@ -100,7 +100,8 @@ def loadModule(path, reload=False): # This can be overriden by os.chdir(). But, maybe the seperation between plugins, and working data is fine. # create the module - execfile(mod.__file__, mod.__dict__) + with open(mod.__file__) as in_file: + exec(in_file.read(), mod.__dict__) # remove the directory to clean it up now that we are done. sys.path.pop(0) diff --git a/src/nodeforge/PluginUtils.py b/src/nodeforge/PluginUtils.py index ebe34b1..1674236 100644 --- a/src/nodeforge/PluginUtils.py +++ b/src/nodeforge/PluginUtils.py @@ -6,7 +6,7 @@ """ from Plugin import Plugin, Priority -import sys, imp, os +import sys, imp, os, types def comparePlugin(x,y): """ @@ -79,4 +79,4 @@ class MyPlugin(Plugin): """ sys._getframe(1).f_locals.update({'main': classobj}) - return classobj \ No newline at end of file + return classobj diff --git a/src/nodeforge/cores/client.py b/src/nodeforge/cores/client.py index 38e35c9..923cdfc 100644 --- a/src/nodeforge/cores/client.py +++ b/src/nodeforge/cores/client.py @@ -2,6 +2,7 @@ Core file for TCP/IP Clients """ from __future__ import with_statement +from __future__ import print_function import socket, sys @@ -60,7 +61,7 @@ def buildProtocol(self, addr): This is executed when a connection is successful. """ - print '%s: Connected at %s' % (self, addr) + print('%s: Connected at %s' % (self, addr)) # this line is necessary because some plugins need to know what # the protocol object is, which is only defined when @@ -78,7 +79,7 @@ def _buildProtocolTrigger(self): plugin.onConnect() def clientConnectionFailed(self, connector, reason): - print 'Connection failed. Reason:', reason + print('Connection failed. Reason:', reason) for plugin in self.plugins: plugin.onConnectFailed(reason) @@ -88,14 +89,14 @@ def clientConnectionLost(self, connector, reason): Called when a connection is lost. """ - print >> sys.stderr, '%s: Disconnected.' % self + print('%s: Disconnected.' % self, file=sys.stderr) for plugin in self.plugins: plugin.onDisconnect(reason) def startedConnecting(self, connector): - print 'Started to connect.' + print('Started to connect.') def lineReceived(self, msg): @@ -107,7 +108,7 @@ def lineReceived(self, msg): # I think this happens and should be ignored. if len(msg) == 0: return - print msg + print(msg) for each in self.plugins: each.onData(msg) diff --git a/src/nodeforge/import2.py b/src/nodeforge/import2.py index 4fc1371..39b4d98 100644 --- a/src/nodeforge/import2.py +++ b/src/nodeforge/import2.py @@ -11,7 +11,7 @@ def customimport(name, globals=None, locals=None, fromlist=None): try: mod = oldimport(name, globals, locals, fromlist) - except SystemError, e: + except SystemError as e: # Get the module to save the import to. # It should be saved as _self. # This is defined in main.PluginManager.loadModule diff --git a/src/plugins/dc/IMDB Query v1.1/imdblib.py b/src/plugins/dc/IMDB Query v1.1/imdblib.py index a24d1d0..e6cea9f 100644 --- a/src/plugins/dc/IMDB Query v1.1/imdblib.py +++ b/src/plugins/dc/IMDB Query v1.1/imdblib.py @@ -1,3 +1,4 @@ +from __future__ import print_function # TV-Series Current Episode Lister 1.01 # Date: 2008/04/28 # Author: Amit.Belani@hotmail.com @@ -33,6 +34,11 @@ from time import sleep, strptime import locale +try: + xrange # Python 2 +except NameError: + xrange = range # Python 3 + # Set locale # This is used for formatting numbers (particularly for grouping digits) if locale.getdefaultlocale()!=(None,None): @@ -73,7 +79,7 @@ def getEps(title,max_len=1024,debug=False): break except: if attempt1 and ('in %s days'%getAge(e)) or e['age']==1 and 'tomorrow' or e['age']==0 and 'today' e_out=e_out+' It airs '+e_schedule+', '+getDate(e)+'.' del e_schedule @@ -163,7 +169,7 @@ def getDate(e): return 'i.e. on '+e['date'].strftime('%a, ')+str(e['date'].day)+ e_out=e_out+' Its air date is unavailable.' if include_plot: - if e.has_key('plot') and e['plot']!='Related Links': + if 'plot' in e and e['plot']!='Related Links': e_out=e_out+' Its plot is: '+e['plot'] elif e_out.endswith('Its air date is unavailable.'): e_out=e_out.replace('Its air date is unavailable.','Its air date and plot are unavailable.') @@ -224,10 +230,10 @@ def getEps_test(add_noplot=False): #titles=('',) # For testing a single or limited number of TV-series for title in titles: - print title+':\n' - print getEps(title,debug=False)+'\n'+'_'*72+'\n' + print(title+':\n') + print(getEps(title,debug=False)+'\n'+'_'*72+'\n') if add_noplot: - print title+': '+getEps(title+' /noplot',debug=False)++'\n''_'*72+'\n' + print(title+': '+getEps(title+' /noplot',debug=False)++'\n''_'*72+'\n') # Run tests #getEps_test() diff --git a/src/plugins/dc/NMDC Parser/main.py b/src/plugins/dc/NMDC Parser/main.py index d7d670c..2bc198c 100644 --- a/src/plugins/dc/NMDC Parser/main.py +++ b/src/plugins/dc/NMDC Parser/main.py @@ -1,3 +1,4 @@ +from __future__ import print_function from nodeforge.PluginUtils import * from twisted.internet.task import LoopingCall @@ -120,9 +121,9 @@ def send(self, string): try: self.core.sendLine(string) - print '>>> %s' % string - except Exception, e: - print e + print('>>> %s' % string) + except Exception as e: + print(e) def tell(self, target, msg): self.send('$To: %s From: %s $<%s> %s' % (target, self.nick, self.nick, msg)) diff --git a/src/plugins/dc/Party Tools/main.py b/src/plugins/dc/Party Tools/main.py index efddf13..7ca4f82 100644 --- a/src/plugins/dc/Party Tools/main.py +++ b/src/plugins/dc/Party Tools/main.py @@ -34,7 +34,7 @@ def roll(self): context.reply('Die must be between 1 and 500, ex. 5d24') return - except Exception, e: + except Exception as e: context.reply('Parse Error ex. 5d24') return diff --git a/src/plugins/irc/IRC Parser/main.py b/src/plugins/irc/IRC Parser/main.py index d74f775..0588f47 100644 --- a/src/plugins/irc/IRC Parser/main.py +++ b/src/plugins/irc/IRC Parser/main.py @@ -2,6 +2,7 @@ An IRC parser. This is by no means complete. """ +from __future__ import print_function from nodeforge.PluginUtils import * from twisted.internet.task import LoopingCall @@ -17,7 +18,7 @@ def send(self, string): string = string.encode('raw_unicode_escape') self.core.sendLine(string) - print '>>> %s' % string + print('>>> %s' % string) def privmsg(self, who, msg): """