I'm writing my own extension command in Python 3. After successful development in external mode only, I included Run function as it's needed according to
this documentation. Later, I created .xml syntax description and installed it using the solution below:
extension action = add
/specification command =
"C:\<SPSS installation directory>\extensions\MY_OWN_COMMAND.xml".
The command was installed without any issues. Moreover, when I typed this syntax in SPSS – the command was coloured. Sadly, during execution, I constantly get very weird error:
Traceback (most recent call last):
File "<string>", line 13, in <module>
File "C:\\<SPSS installation directory>\\extensions\MY_OWN_COMMAND.py", line 23, in Run
TypeError: 'dict_keys' object is not subscriptable
Line 23 in my code is empty. No matter what I place in that line (code, comment, nothing) I always get this error in this exact line. These are first 24 lines of the code (I cannot post everything due to my company rights):
import spss
import spssaux
import SpssClient
from extension import Template, Syntax, processcmd
from itertools import chain
from typing import Tuple
def Run(
args
) -> None:
oobj = Syntax([
Template("...", subc="...", ktype="str", var="...", vallist=["...", "..."]),
Template("...", subc="...", ktype="int", var="..."),
Template("...", subc="...", ktype="int", var="..."),
Template("...", subc="...", ktype="int", var="...", islist=True),
Template("...", subc="...", ktype="existingvarlist", var="...", islist=True),
Template("...", subc="...", ktype="str", var="...", vallist=["...", "..."]),
Template("...", subc="...", ktype="existingvarlist", var="...", islist=False)])
args = args[args.keys()[0]]
processcmd(oobj, args, my_own_command)
This is exactly the same code (except Templates) as in the documentation above. Why is this happening? Any advice will be appreciated
------------------------------
Konrad Gałuszko
------------------------------
#SPSSStatistics