2016-01-10 92 views
1

尝试使用Python 2.7获取Windows 10中的蜻蜓工作。我有我做的,我尝试但得到的工作而言,我发现了以下错误的样本模块:蜻蜓IntegerRef获取TypeError:'NoneType'对象不可调用错误

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 

生成该错误代码是:

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() 

没有人知道我可能做错了吗?

+0

你的样品模块从哪里来?在此之前你有任何错误信息吗? –

+0

原来是从这里:http://dragonfly.readthedocs.org/en/latest/rules.html#id1我改变了'整数'为'IntegerRef',因为我得到了另一个'整数'错误。在这之前没有错误信息。 – Jarrett

+0

原始错误(使用'Integer')为: 'Traceback(最近一次调用最后一个): loadFile中的文件“C:\ NatLink \ NatLink \ MacroSystem \ core \ natlinkmain.py”,第304行imp.load_module (modName,fndFile,fndName,fndDesc) 文件“C:\ Users \ jarrett \ projects \ natlink \ _test.py”,第3行, class ExampleRule2(MappingRule): 文件“C:\ Users \ jarrett \项目\ natlink \ _test.py“,第20行,ExampleRule2 Integer(”n“,1,20), TypeError:'NoneType'对象不可调用' – Jarrett

回答

1

因此,事实证明这是我的语言问题 - 我的语言被设置为蜻蜓natlink引擎中未定义的语言。

一旦我手动添加我的语言,一切正常。