Helpviewer/OpenSearch/OpenSearchManager.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3020
542e97d4ecb3
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
9 9
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 10 from __future__ import unicode_literals # __IGNORE_WARNING__
11 11
12 import os 12 import os
13 13
14 from PyQt4.QtCore import pyqtSignal, QObject, QUrl, QFile, QDir, QIODevice, \ 14 from PyQt4.QtCore import pyqtSignal, QObject, QUrl, QFile, QDir, QIODevice
15 QByteArray, QBuffer
16 from PyQt4.QtNetwork import QNetworkRequest, QNetworkReply 15 from PyQt4.QtNetwork import QNetworkRequest, QNetworkReply
17 16
18 from E5Gui.E5Application import e5App 17 from E5Gui.E5Application import e5App
19 from E5Gui import E5MessageBox 18 from E5Gui import E5MessageBox
20 19
357 356
358 def restoreDefaults(self): 357 def restoreDefaults(self):
359 """ 358 """
360 Public method to restore the default search engines. 359 Public method to restore the default search engines.
361 """ 360 """
362 from .OpenSearchDefaultEngines import OpenSearchDefaultEngines
363 from .OpenSearchReader import OpenSearchReader 361 from .OpenSearchReader import OpenSearchReader
364 362 from .DefaultSearchEngines import DefaultSearchEngines_rc # __IGNORE_WARNING__
363
364 defaultEngineFiles = ["YouTube.xml", "Amazoncom.xml", "Bing.xml",
365 "DeEn_Beolingus.xml", "Facebook.xml",
366 "Google_Im_Feeling_Lucky.xml", "Google.xml",
367 "LEO_DeuEng.xml", "LinuxMagazin.xml",
368 "Reddit.xml", "Wikia_en.xml", "Wikia.xml",
369 "Wikipedia.xml", "Wiktionary.xml", "Yahoo.xml"]
370 # Keep this list in sync with the contents of the resource file.
371
365 reader = OpenSearchReader() 372 reader = OpenSearchReader()
366 for engine in OpenSearchDefaultEngines: 373 for engineFileName in defaultEngineFiles:
367 engineDescription = QByteArray(OpenSearchDefaultEngines[engine]) 374 engineFile = QFile(":/" + engineFileName)
368 buffer_ = QBuffer(engineDescription) 375 if not engineFile.open(QIODevice.ReadOnly):
369 if not buffer_.open(QIODevice.ReadOnly):
370 continue 376 continue
371 377 engine = reader.read(engineFile)
372 engine = reader.read(buffer_)
373
374 self.__addEngineByEngine(engine) 378 self.__addEngineByEngine(engine)
375 379
376 def enginesDirectory(self): 380 def enginesDirectory(self):
377 """ 381 """
378 Public method to determine the directory containing the search engine 382 Public method to determine the directory containing the search engine
393 if engine is None or not engine.isValid(): 397 if engine is None or not engine.isValid():
394 return False 398 return False
395 399
396 host = QUrl(engine.searchUrlTemplate()).host() 400 host = QUrl(engine.searchUrlTemplate()).host()
397 401
398 res = E5MessageBox.yesNo(None, 402 res = E5MessageBox.yesNo(
403 None,
399 "", 404 "",
400 self.trUtf8( 405 self.trUtf8(
401 """<p>Do you want to add the following engine to your""" 406 """<p>Do you want to add the following engine to your"""
402 """ list of search engines?<br/><br/>Name: {0}<br/>""" 407 """ list of search engines?<br/><br/>Name: {0}<br/>"""
403 """Searches on: {1}</p>""").format(engine.name(), host)) 408 """Searches on: {1}</p>""").format(engine.name(), host))

eric ide

mercurial