From 3381a06cf8284673d801717674fbc2b6042c58b5 Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Tue, 27 Oct 2015 16:49:17 +0000
Subject: [PATCH] Add a closed method to the Python environment in MantidPlot

This allows it to closer mimic a file-like object.
---
 MantidPlot/src/PythonScript.h    | 4 +++-
 MantidPlot/src/PythonScripting.h | 6 ++++--
 MantidPlot/src/qti.sip           | 8 ++++++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/MantidPlot/src/PythonScript.h b/MantidPlot/src/PythonScript.h
index 88e8a936f57..8575c2d54f3 100644
--- a/MantidPlot/src/PythonScript.h
+++ b/MantidPlot/src/PythonScript.h
@@ -66,8 +66,10 @@ public:
   // -------------------------- Print/error message handling ------------------
   /// Connects the python stdout to a Qt signal
   inline void write(const QString &text) { emit print(text); }
-  /// 'Fake' method needed for IPython import
+  /// Simulate file-like object (required for IPython)
   inline void flush() {}
+  /// Simulate file-like object (required for colorama)
+  inline bool closed() { return false;  }
   /// Is the given code complete
   bool compilesToCompleteStatement(const QString & code) const;
 
diff --git a/MantidPlot/src/PythonScripting.h b/MantidPlot/src/PythonScripting.h
index f34b0ae5c5f..cd6b6aae697 100644
--- a/MantidPlot/src/PythonScripting.h
+++ b/MantidPlot/src/PythonScripting.h
@@ -52,8 +52,10 @@ public:
   ~PythonScripting();
   /// Write text to std out
   void write(const QString &text) { emit print(text); }
-  /// 'Fake' method needed for IPython import
-  void flush() {}
+  /// Simulate file-like object (required for IPython)
+  inline void flush() {}
+  /// Simulate file-like object (required for colorama)
+  inline bool closed() { return false; }
   /// 'Fake' method needed for IPython import
   void set_parent(PyObject*) {}
 
diff --git a/MantidPlot/src/qti.sip b/MantidPlot/src/qti.sip
index 1ce385f18b4..3443b9e57cb 100644
--- a/MantidPlot/src/qti.sip
+++ b/MantidPlot/src/qti.sip
@@ -1287,8 +1287,10 @@ class PythonScripting
 %End
 public:
   void write(const QString&);
-  // 'Fake' methods needed for IPython import
+  // Simulate file-like object (required for IPython)
   void flush();
+  // Simulate file-like object (required for colorama)
+  bool closed();
   void set_parent(SIP_PYOBJECT);
 private:
   PythonScripting(const PythonScripting&);
@@ -1300,8 +1302,10 @@ class PythonScript
 %End
 public:
   void write(const QString&);
-  // 'Fake' method needed for IPython import
+  // Simulate file-like object (required for IPython)
   void flush();
+  // Simulate file-like object (required for colorama)
+  bool closed();
   // Line number trace
   void lineNumberChanged(SIP_PYOBJECT,int);
 private:
-- 
GitLab