View Issue Details

IDProjectCategoryView StatusLast Update
0008968ScribusScripterpublic2015-09-18 07:38
Reportermochouinard Assigned Tocbradney  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionduplicate 
PlatformIntel 64bitOSUbuntuOS Version9.10
Product Version1.3.7svn 
Fixed in Version1.5.1svn 
Summary0008968: [patch] add getArgv(num) and getArgc() api : Access the scribus started argument to do custom procesing
DescriptionI use this with --plugin-script-run so I can add for example --plugin-script-invoice-number 12345

http://64.235.217.39/tmp/auto_git_export_scribus/scripter_arg_api.diff
TagsNo tags attached.
PatchYes

Relationships

duplicate of 0013311 closedcbradney support for command line arguments to be passed on to python script (-py option) 

Activities

ale

2010-03-24 21:59

manager  

scripter_arg_api.diff (4,654 bytes)   
diff --git a/scribus/plugins/scriptplugin/cmdmisc.cpp b/scribus/plugins/scriptplugin/cmdmisc.cpp
index 03484b4..695bc8f 100644
--- a/scribus/plugins/scriptplugin/cmdmisc.cpp
+++ b/scribus/plugins/scriptplugin/cmdmisc.cpp
@@ -750,6 +750,22 @@ PyObject *scribus_getlanguage(PyObject* /* self */)
 	return PyString_FromString(ScCore->getGuiLanguage().toUtf8());
 }
 
+PyObject *scribus_getargc(PyObject* /* self */, PyObject* args)
+{
+	return PyInt_FromLong(QApplication::argc());
+}
+
+PyObject *scribus_getargv(PyObject* /* self */, PyObject* args)
+{
+        int w;
+        if (!PyArg_ParseTuple(args, "i", &w))
+                return NULL;
+
+	QString arg = QApplication::argv()[w];
+
+	return PyString_FromString(arg.toUtf8());
+}
+
 /*! 04.01.2007 : Joachim Neu : Moves item selection to front. */
 PyObject *scribus_moveselectiontofront(PyObject*)
 {
@@ -770,5 +786,5 @@ PV */
 void cmdmiscdocwarnings()
 {
     QStringList s;
-	s << scribus_setredraw__doc__ <<scribus_fontnames__doc__ << scribus_xfontnames__doc__ <<scribus_renderfont__doc__ << scribus_getlayers__doc__ << scribus_setactlayer__doc__ << scribus_getactlayer__doc__ << scribus_senttolayer__doc__ <<scribus_layervisible__doc__ <<scribus_layerprint__doc__ <<scribus_layerlock__doc__ <<scribus_layeroutline__doc__ <<scribus_layerflow__doc__ <<scribus_layerblend__doc__ <<scribus_layertrans__doc__ <<scribus_glayervisib__doc__ <<scribus_glayerprint__doc__ <<scribus_glayerlock__doc__ <<scribus_glayeroutline__doc__ <<scribus_glayerflow__doc__ <<scribus_glayerblend__doc__ <<scribus_glayertrans__doc__ <<scribus_removelayer__doc__ <<scribus_createlayer__doc__ <<scribus_getlanguage__doc__ <<scribus_moveselectiontofront__doc__<< scribus_moveselectiontoback__doc__;
+	s << scribus_setredraw__doc__ <<scribus_fontnames__doc__ << scribus_xfontnames__doc__ <<scribus_renderfont__doc__ << scribus_getlayers__doc__ << scribus_setactlayer__doc__ << scribus_getactlayer__doc__ << scribus_senttolayer__doc__ <<scribus_layervisible__doc__ <<scribus_layerprint__doc__ <<scribus_layerlock__doc__ <<scribus_layeroutline__doc__ <<scribus_layerflow__doc__ <<scribus_layerblend__doc__ <<scribus_layertrans__doc__ <<scribus_glayervisib__doc__ <<scribus_glayerprint__doc__ <<scribus_glayerlock__doc__ <<scribus_glayeroutline__doc__ <<scribus_glayerflow__doc__ <<scribus_glayerblend__doc__ <<scribus_glayertrans__doc__ <<scribus_removelayer__doc__ <<scribus_createlayer__doc__ <<scribus_getlanguage__doc__ <<scribus_moveselectiontofront__doc__<< scribus_moveselectiontoback__doc__<< scribus_getargc__doc__<< scribus_getargv__doc__;
 }
diff --git a/scribus/plugins/scriptplugin/cmdmisc.h b/scribus/plugins/scriptplugin/cmdmisc.h
index 59e612d..64c9507 100644
--- a/scribus/plugins/scriptplugin/cmdmisc.h
+++ b/scribus/plugins/scriptplugin/cmdmisc.h
@@ -322,6 +322,24 @@ Returns a string with the -lang value.\n\
 PyObject *scribus_getlanguage(PyObject * /*self*/);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_getargc__doc__,
+QT_TR_NOOP("getArgc() -> int\n\
+\n\
+Returns the count of arguments.\n\
+"));
+/*! Count of Command Line Argument */
+PyObject *scribus_getargc(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
+PyDoc_STRVAR(scribus_getargv__doc__,
+QT_TR_NOOP("getArgv(i) -> string\n\
+\n\
+Returns the value of a argument position i.\n\
+"));
+/*! Count of Command Line Argument */
+PyObject *scribus_getargv(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_moveselectiontofront__doc__,
 QT_TR_NOOP("moveSelectionToFront()\n\
 \n\
diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index 163e90b..d87f42e 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -312,6 +312,8 @@ PyMethodDef scribus_methods[] = {
 	{const_cast<char*>("getAllObjects"), scribus_getallobj, METH_VARARGS, tr(scribus_getallobj__doc__)},
 	{const_cast<char*>("getAllStyles"), (PyCFunction)scribus_getstylenames, METH_NOARGS, tr(scribus_getstylenames__doc__)},
 	{const_cast<char*>("getAllText"), scribus_gettext, METH_VARARGS, tr(scribus_gettext__doc__)},
+	{const_cast<char*>("getArgc"), scribus_getargc, METH_VARARGS, tr(scribus_getargc__doc__)},
+	{const_cast<char*>("getArgv"), scribus_getargv, METH_VARARGS, tr(scribus_getargv__doc__)},
 	{const_cast<char*>("getColorNames"), (PyCFunction)scribus_colornames, METH_NOARGS, tr(scribus_colornames__doc__)},
 	{const_cast<char*>("getColor"), scribus_getcolor, METH_VARARGS, tr(scribus_getcolor__doc__)},
 	{const_cast<char*>("getColorAsRGB"), scribus_getcolorasrgb, METH_VARARGS, tr(scribus_getcolorasrgb__doc__)},
scripter_arg_api.diff (4,654 bytes)   

jghali

2010-03-27 13:28

administrator   ~0023618

Please reupload the patch in unified format. See issue 0008865 for an example.

mochouinard

2012-06-13 14:42

reporter  

Scribus_scripter_arg_api.diff (3,375 bytes)   
diff --git a/scribus/plugins/scriptplugin/cmdmisc.cpp b/scribus/plugins/scriptplugin/cmdmisc.cpp
index a6f5ce0..c3386a3 100644
--- a/scribus/plugins/scriptplugin/cmdmisc.cpp
+++ b/scribus/plugins/scriptplugin/cmdmisc.cpp
@@ -756,6 +756,22 @@ PyObject *scribus_getlanguage(PyObject* /* self */)
 	return PyString_FromString(ScCore->getGuiLanguage().toUtf8());
 }
 
+PyObject *scribus_getargc(PyObject* /* self */, PyObject* args)
+{
+	return PyInt_FromLong(QApplication::argc());
+}
+
+PyObject *scribus_getargv(PyObject* /* self */, PyObject* args)
+{
+        int w;
+        if (!PyArg_ParseTuple(args, "i", &w))
+                return NULL;
+
+	QString arg = QApplication::argv()[w];
+
+	return PyString_FromString(arg.toUtf8());
+}
+
 /*! 04.01.2007 : Joachim Neu : Moves item selection to front. */
 PyObject *scribus_moveselectiontofront(PyObject*)
 {
@@ -789,5 +805,6 @@ void cmdmiscdocwarnings()
 	  << scribus_glayerblend__doc__ << scribus_glayertrans__doc__ 
 	  << scribus_removelayer__doc__ << scribus_createlayer__doc__ 
 	  << scribus_getlanguage__doc__ << scribus_moveselectiontofront__doc__
-	  << scribus_moveselectiontoback__doc__<< scribus_filequit__doc__;
+	  << scribus_moveselectiontoback__doc__<< scribus_filequit__doc__
+	  << scribus_getargc__doc__ << scribus_getargv__doc__;
 }
diff --git a/scribus/plugins/scriptplugin/cmdmisc.h b/scribus/plugins/scriptplugin/cmdmisc.h
index 48f857a..4a840d6 100644
--- a/scribus/plugins/scriptplugin/cmdmisc.h
+++ b/scribus/plugins/scriptplugin/cmdmisc.h
@@ -331,6 +331,24 @@ Returns a string with the -lang value.\n\
 PyObject *scribus_getlanguage(PyObject * /*self*/);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_getargc__doc__,
+QT_TR_NOOP("getArgc() -> int\n\
+\n\
+Returns the count of arguments.\n\
+"));
+/*! Count of Command Line Argument */
+PyObject *scribus_getargc(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
+PyDoc_STRVAR(scribus_getargv__doc__,
+QT_TR_NOOP("getArgv(i) -> string\n\
+\n\
+Returns the value of a argument position i.\n\
+"));
+/*! Count of Command Line Argument */
+PyObject *scribus_getargv(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_moveselectiontofront__doc__,
 QT_TR_NOOP("moveSelectionToFront()\n\
 \n\
diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index c4233f5..b917987 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -314,6 +314,8 @@ PyMethodDef scribus_methods[] = {
 	{const_cast<char*>("getAllObjects"), scribus_getallobj, METH_VARARGS, tr(scribus_getallobj__doc__)},
 	{const_cast<char*>("getAllStyles"), (PyCFunction)scribus_getstylenames, METH_NOARGS, tr(scribus_getstylenames__doc__)},
 	{const_cast<char*>("getAllText"), scribus_gettext, METH_VARARGS, tr(scribus_gettext__doc__)},
+	{const_cast<char*>("getArgc"), scribus_getargc, METH_VARARGS, tr(scribus_getargc__doc__)},
+	{const_cast<char*>("getArgv"), scribus_getargv, METH_VARARGS, tr(scribus_getargv__doc__)},
 	{const_cast<char*>("getColorNames"), (PyCFunction)scribus_colornames, METH_NOARGS, tr(scribus_colornames__doc__)},
 	{const_cast<char*>("getColor"), scribus_getcolor, METH_VARARGS, tr(scribus_getcolor__doc__)},
 	{const_cast<char*>("getColorAsRGB"), scribus_getcolorasrgb, METH_VARARGS, tr(scribus_getcolorasrgb__doc__)},
Scribus_scripter_arg_api.diff (3,375 bytes)   

ale

2015-09-17 08:58

manager   ~0036254

... i guess we can now close this...

Kunda

2015-09-17 17:02

updater   ~0036257

What's the status of this ticket? Closed 'Won't Fix' or 'Suspended' or what?

mochouinard

2015-09-17 17:10

reporter   ~0036258

Well, I still use it on my end... Though I'm running 1.4.0 since the new script engine didn't work correctly for me... I haven't tried the new version for a while now though (few month). But I keep getting told that it ready now the last few time I tried it and it was lacking a lot, so not really interested to give it a try AGAIN.

cbradney

2015-09-17 18:50

administrator   ~0036268

This is fixed in 1.5.1. Wont fix for 1.4.x

Kunda

2015-09-17 19:10

updater   ~0036269

mochouinard, thanks for your contribution. Please check out 1.5.1 and see if it works for you. It would be educational to know if it does. Also since there is more development these days on Scripter so I encourage you to re-ignite your energies for contributions. There is some great work happening at https://github.com/berteh/ScribusGenerator as berteh has recently submitted patches for CLI for Scribus (0013311)

ale

2015-09-18 07:38

manager   ~0036279

hi mo,

two things:

- on the one side, you can work with 1.4 and only use 1.5 for processing .sla files to automatically produce PDFs. (the old scripter is still in 1.5)
- on the other side, we urgently need help in getting the new scripter to work. if you know anybody that could help us for connecting signals and slots accross the boundaries between c++ and python (with pyqt5) help is very welcome!

Issue History

Date Modified Username Field Change
2010-03-23 21:30 mochouinard New Issue
2010-03-24 21:59 ale File Added: scripter_arg_api.diff
2010-03-27 13:28 jghali Note Added: 0023618
2012-06-13 14:26 ale Assigned To => jainbasil
2012-06-13 14:26 ale Status new => assigned
2012-06-13 14:42 mochouinard File Added: Scribus_scripter_arg_api.diff
2014-10-24 23:00 Kunda Patch => Yes
2015-09-17 08:58 ale Note Added: 0036254
2015-09-17 17:02 Kunda Note Added: 0036257
2015-09-17 17:10 mochouinard Note Added: 0036258
2015-09-17 18:50 cbradney Note Added: 0036268
2015-09-17 18:50 cbradney Relationship added duplicate of 0013311
2015-09-17 18:50 cbradney Status assigned => resolved
2015-09-17 18:50 cbradney Fixed in Version => 1.5.1svn
2015-09-17 18:50 cbradney Resolution open => duplicate
2015-09-17 18:50 cbradney Assigned To jainbasil => cbradney
2015-09-17 19:10 Kunda Note Added: 0036269
2015-09-17 19:10 Kunda Status resolved => closed
2015-09-18 07:38 ale Note Added: 0036279