From 28cdf5c386feb0d4f8b35486a3e3c046184f9916 Mon Sep 17 00:00:00 2001
From: Andreas Freise <adf@star.bham.ac.uk>
Date: Sun, 14 Dec 2014 14:27:46 +0000
Subject: [PATCH] changing prints to function and make selective exception
 import towards python 3 compatibility

---
 pykat/commands.py     | 5 ++++-
 pykat/components.py   | 5 ++++-
 pykat/detectors.py    | 7 +++++--
 pykat/exceptions.py   | 5 ++++-
 pykat/gui/graphics.py | 5 ++++-
 pykat/node_network.py | 4 ++--
 pykat/param.py        | 5 +++--
 7 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/pykat/commands.py b/pykat/commands.py
index 8300b18..bd21e8c 100644
--- a/pykat/commands.py
+++ b/pykat/commands.py
@@ -4,9 +4,12 @@ Created on Mon Jan 28 11:58:09 2013
 
 @author: Daniel
 """
+from __future__ import print_function
 import numpy
 from numpy import min,max
-import exceptions
+import pykat.external.six as six
+if six.PY2:
+	import exceptions
 from components import *
 from structs import *
 from pykat.param import Param, putter
diff --git a/pykat/components.py b/pykat/components.py
index f6b5e83..99c8cdb 100644
--- a/pykat/components.py
+++ b/pykat/components.py
@@ -4,7 +4,10 @@ Created on Mon Jan 28 11:10:01 2013
 
 @author: Daniel
 """
-import exceptions
+from __future__ import print_function
+import pykat.external.six as six
+if six.PY2:
+	import exceptions
 import pykat.exceptions as pkex
 import pykat
 from pykat.node_network import *
diff --git a/pykat/detectors.py b/pykat/detectors.py
index 1726b30..612b01c 100644
--- a/pykat/detectors.py
+++ b/pykat/detectors.py
@@ -4,7 +4,10 @@ Created on Fri Feb 01 0split()9:09:10 2013
 
 @author: Daniel
 """
-import exceptions
+from __future__ import print_function
+import pykat.external.six as six
+if six.PY2:
+	import exceptions
 import abc
 from pykat.node_network import *
 from pykat.param import Param
@@ -878,4 +881,4 @@ class qhd(Detector2):
             for p in self._params:
                 rtn.extend(p.getFinesseText())
             
-        return rtn
\ No newline at end of file
+        return rtn
diff --git a/pykat/exceptions.py b/pykat/exceptions.py
index c1f620b..e3d9042 100644
--- a/pykat/exceptions.py
+++ b/pykat/exceptions.py
@@ -1,4 +1,7 @@
-import exceptions
+from __future__ import print_function
+import pykat.external.six as six
+if six.PY2:
+	import exceptions
 import os
 
 class BasePyKatException(Exception):
diff --git a/pykat/gui/graphics.py b/pykat/gui/graphics.py
index 3543002..84618b3 100644
--- a/pykat/gui/graphics.py
+++ b/pykat/gui/graphics.py
@@ -5,12 +5,15 @@ Created on Fri Feb 01 09:13:03 2013
 @author: Daniel
 """
 
+from __future__ import print_function
+import pykat.external.six as six
+if six.PY2:
+	import exceptions
 from PyQt4.QtGui import *
 from PyQt4.Qt import *
 from PyQt4 import QtSvg
 from PyQt4.QtSvg import QGraphicsSvgItem
 import pykat.components
-import exceptions
 import weakref
 
 nsize = 10
diff --git a/pykat/node_network.py b/pykat/node_network.py
index 0db1216..115c2b9 100644
--- a/pykat/node_network.py
+++ b/pykat/node_network.py
@@ -4,7 +4,7 @@ Created on Sun Jan 27 10:02:41 2013
 
 @author: Daniel
 """
-
+from __future__ import print_function
 from pykat import USE_GUI, NoGUIException
 
 if USE_GUI:
@@ -349,7 +349,7 @@ class NodeNetwork(object):
             return False
             
         elif isinstance(currcomp, pykat.components.isolator):
-            print "isol"
+            print("isol")
         elif isinstance(currcomp, pykat.components.laser):
             # if we are at a laser then we can't go any further
             # and it isn;t this node as we checked before
diff --git a/pykat/param.py b/pykat/param.py
index 31fe7c3..590fbf5 100644
--- a/pykat/param.py
+++ b/pykat/param.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
 import abc
 import pykat.exceptions as pkex
 import weakref
@@ -150,7 +151,7 @@ class Param(putable, putter):
         #if this param can be put somewhere we need to check if it is
         if self.isPutable:
             for a in self.putees:
-                print "Removing put from {0} {1} to {2} {3}".format(self.owner.name, self.name, a.owner.name, a.name)
+                print("Removing put from {0} {1} to {2} {3}".format(self.owner.name, self.name, a.owner.name, a.name))
                 a._putter = None
                 self.put_count -= 1
                 
@@ -160,7 +161,7 @@ class Param(putable, putter):
         # check if we have anything being put to us
         if self.isPutter:
             if self._putter != None:
-                print "Removing put from {0} {1} to {2} {3}".format(self._putter.owner.name, self._putter.name, self.owner.name, self.name)
+                print("Removing put from {0} {1} to {2} {3}".format(self._putter.owner.name, self._putter.name, self.owner.name, self.name))
                 self._putter.put_count -= 1
                 self._putter.putees.remove(self)
                 self._putter = None
-- 
GitLab