瀏覽代碼

[enh] engine shortcut validation

Adam Tauber 10 年之前
父節點
當前提交
2e41bfcbdb
共有 1 個檔案被更改,包括 6 行新增1 行删除
  1. 6
    1
      searx/engines/__init__.py

+ 6
- 1
searx/engines/__init__.py 查看文件

81
         if engine_attr.startswith('_'):
81
         if engine_attr.startswith('_'):
82
             continue
82
             continue
83
         if getattr(engine, engine_attr) is None:
83
         if getattr(engine, engine_attr) is None:
84
-            print '[E] Engine config error: Missing attribute "{0}.{1}"'.format(engine.name, engine_attr)  # noqa
84
+            print('[E] Engine config error: Missing attribute "{0}.{1}"'\
85
+                  .format(engine.name, engine_attr))
85
             sys.exit(1)
86
             sys.exit(1)
86
 
87
 
87
     engine.stats = {
88
     engine.stats = {
100
 
101
 
101
     if engine.shortcut:
102
     if engine.shortcut:
102
         # TODO check duplications
103
         # TODO check duplications
104
+        if engine.shortcut in engine_shortcuts:
105
+            print('[E] Engine config error: ambigious shortcut: {0}'\
106
+                  .format(engine.shortcut))
107
+            sys.exit(1)
103
         engine_shortcuts[engine.shortcut] = engine.name
108
         engine_shortcuts[engine.shortcut] = engine.name
104
     return engine
109
     return engine
105
 
110