Dragonfly IntegerRef getting a TypeError: 'NoneType' object is not callable error

女生的网名这么多〃 提交于 2020-01-03 03:47:06

问题


Try to get dragonfly working in Windows 10 with Python 2.7. I have a sample module that I made that im trying to get working, however Im getting the following error:

Traceback (most recent call last):
  File "C:\NatLink\NatLink\MacroSystem\core\natlinkmain.py", line 304, in loadFile
    imp.load_module(modName,fndFile,fndName,fndDesc)
  File "C:\Users\jarrett\projects\natlink\_test.py", line 3, in <module>
    class ExampleRule2(MappingRule):
  File "C:\Users\jarrett\projects\natlink\_test.py", line 20, in ExampleRule2
    IntegerRef("n", 1, 20),
  File "C:\Python27\lib\site-packages\dragonfly-0.6.5-py2.7.egg\dragonfly\grammar\number.py", line 75, in __init__
    element = self._element_type(None, min, max)
TypeError: 'NoneType' object is not callable

the code that generates this error is:

from dragonfly.all import Grammar, CompoundRule, MappingRule, Key, Text, IntegerRef, Dictation

class ExampleRule2(MappingRule):
    mapping  = {
                "[feed] address [bar]":                Key("a-d"),
                "subscribe [[to] [this] feed]":        Key("a-u"),
                "paste [feed] address":                Key("a-d, c-v, enter"),
                "feeds | feed (list | window | win)":  Key("a-d, tab:2, s-tab"),
                "down [<n>] (feed | feeds)":           Key("a-d, tab:2, s-tab, down:%(n)d"),
                "up [<n>] (feed | feeds)":             Key("a-d, tab:2, s-tab, up:%(n)d"),
                "open [item]":                         Key("a-d, tab:2, c-s"),
                "newer [<n>]":                         Key("a-d, tab:2, up:%(n)d"),
                "older [<n>]":                         Key("a-d, tab:2, down:%(n)d"),
                "mark all [as] read":                  Key("cs-r"),
                "mark all [as] unread":                Key("cs-u"),
                "search [bar]":                        Key("a-s"),
                "search [for] <text>":                 Key("a-s") + Text("%(text)s\n"),
               }
    extras   = [
                IntegerRef("n", 1, 20),
                Dictation("text"),
               ]
    defaults = {
                "n": 1,
               }

# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar")
grammar.add_rule(ExampleRule2())
grammar.load()

does anyone know what I may be doing wrong?


回答1:


So it turns out it was an issue with my language – my language was set to a language which is not defined in the dragonfly natlink engine.

Once I manually added my language, everything worked fine.



来源:https://stackoverflow.com/questions/34700823/dragonfly-integerref-getting-a-typeerror-nonetype-object-is-not-callable-erro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!