From 175f28dbb541296dbede06f02a273260f93bfc5b Mon Sep 17 00:00:00 2001
From: berteh <berteh@gmail.com>
Date: Thu, 17 Sep 2015 11:19:12 +0200
Subject: [PATCH] remove ext/sub extra argument added by Scripter to run
 scripts

---
 scribus/plugins/scriptplugin/samples/3columnA4.py | 20 +++-----------------
 scribus/plugins/scriptplugin/samples/wordcount.py | 11 +++++------
 scribus/plugins/scriptplugin/scriptercore.cpp     | 16 ++--------------
 3 files changed, 10 insertions(+), 37 deletions(-)

diff --git a/scribus/plugins/scriptplugin/samples/3columnA4.py b/scribus/plugins/scriptplugin/samples/3columnA4.py
index 2609c72..23f0816 100644
--- a/scribus/plugins/scriptplugin/samples/3columnA4.py
+++ b/scribus/plugins/scriptplugin/samples/3columnA4.py
@@ -8,23 +8,9 @@
     # Do so _after_ the 'import scribus' and only import the names you need, such
     # as commonly used constants.
     import scribus
-except ImportError,err:
-    print "This Python script is written for the Scribus scripting interface."
-    print "It can only be run from within Scribus."
-    sys.exit(1)
-
-def main(argv):
-    """This is a simple way to demonstrate creating a doc on the fly. """
-
-    pass    # <--- Delete this line
-#########################
-# YOUR IMPORTS GO HERE  #
-#########################
-
-import sys
-
-try:
-    from scribus import *
+    #########################
+    # YOUR IMPORTS GO HERE  #
+    #########################
 except ImportError:
     print "This script only runs from within Scribus."
     sys.exit(1)
diff --git a/scribus/plugins/scriptplugin/samples/wordcount.py b/scribus/plugins/scriptplugin/samples/wordcount.py
index de372d6..26540a4 100644
--- a/scribus/plugins/scriptplugin/samples/wordcount.py
+++ b/scribus/plugins/scriptplugin/samples/wordcount.py
@@ -14,6 +14,7 @@
 import re
 
 TITLE = "Word count"
+
 
 def wordsplit(text):
     word_pattern = "([A-Za-zäöüÄÖÜß]+)"
@@ -35,8 +36,7 @@ def main():
                 text = getText(getSelectedObject(i))
                 words += len(wordsplit(text))
             except WrongFrameTypeError:
-                if sel_count == 1:
-                    # If there's only one object selected, display a message
+                if sel_count == 1: # If there's only one object selected, display a message
                     messageBox(TITLE, "Can't count words in a non-text frame", ICON_INFORMATION);
                     sys.exit(1)
                 else:
@@ -52,10 +52,9 @@ def main():
                     words += len(wordsplit(text))
                 except WrongFrameTypeError:
                     pass # ignore the error, it just wasn't a frame we can count
-
-    if words == 0: words = "No"
-    messageBox(TITLE, "%s words counted in %s" % (words, source),
-               ICON_INFORMATION)
+    if (words == 0):
+        words = "No"
+        messageBox(TITLE, "%s words counted in %s" % (words, source), ICON_INFORMATION)
 
 
 if __name__ == '__main__':
diff --git a/scribus/plugins/scriptplugin/scriptercore.cpp b/scribus/plugins/scriptplugin/scriptercore.cpp
index ad76e03..667b763 100644
--- a/scribus/plugins/scriptplugin/scriptercore.cpp
+++ b/scribus/plugins/scriptplugin/scriptercore.cpp
@@ -262,16 +262,8 @@ void ScripterCore::slotRunScriptFile(QString fileName, QStringList arguments, bo
 
 	// Make sure sys.argv[0] is the path to the script
 	arguments.prepend(na.data());
-	
-	// and tell the script if it's running in the main intepreter or
-	// a subinterpreter using the second argument, ie sys.argv[1]
-	if (inMainInterpreter)
-		arguments.insert(1,QString("ext"));
-	else
-		arguments.insert(1,QString("sub"));
-
 	//convert arguments (QListString) to char** for Python bridge
-	/* typically arguments == ['path/to/script.py','ext','--argument1','valueforarg1','--flag']*/
+	/* typically arguments == ['path/to/script.py','--argument1','valueforarg1','--flag']*/
 	char **comm = new char*[arguments.size()];
 	for (int i = 0; i < arguments.size(); i++)
 	{
@@ -431,11 +423,7 @@ void ScripterCore::slotRunScript(const QString Script)
 	"In file tools/qgarray.cpp, line 147: Out of memory"
 	Anyway - sys.argv is set above
 	char* comm[1];
-	comm[0] = const_cast<char*>("scribus");
-	// the scripter console runs everything in the main interpreter
-	// tell the code it's running there.
-	comm[1] = const_cast<char*>("ext");
-	PySys_SetArgv(2, comm); */
+	comm[0] = const_cast<char*>("scribus"); */
 	// then run the code
 	PyObject* m = PyImport_AddModule((char*)"__main__");
 	if (m == NULL)
