Helpviewer/Bookmarks/BookmarksImporters/XbelImporter.py

changeset 5587
ea526b78ee6c
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
equal deleted inserted replaced
5586:0e5421d679e7 5587:ea526b78ee6c
16 from .BookmarksImporter import BookmarksImporter 16 from .BookmarksImporter import BookmarksImporter
17 17
18 import UI.PixmapCache 18 import UI.PixmapCache
19 19
20 20
21 def getImporterInfo(id): 21 def getImporterInfo(sourceId):
22 """ 22 """
23 Module function to get information for the given XBEL source id. 23 Module function to get information for the given XBEL source id.
24 24
25 @param id id of the browser ("chrome" or "chromium") 25 @param sourceId id of the browser ("chrome" or "chromium")
26 @return tuple with an icon (QPixmap), readable name (string), name of 26 @return tuple with an icon (QPixmap), readable name (string), name of
27 the default bookmarks file (string), an info text (string), 27 the default bookmarks file (string), an info text (string),
28 a prompt (string) and the default directory of the bookmarks file 28 a prompt (string) and the default directory of the bookmarks file
29 (string) 29 (string)
30 @exception ValueError raised to indicate an invalid browser ID 30 @exception ValueError raised to indicate an invalid browser ID
31 """ 31 """
32 if id == "e5browser": 32 if sourceId == "e5browser":
33 from ..BookmarksManager import BookmarksManager 33 from ..BookmarksManager import BookmarksManager
34 bookmarksFile = BookmarksManager.getFileName() 34 bookmarksFile = BookmarksManager.getFileName()
35 return ( 35 return (
36 UI.PixmapCache.getPixmap("ericWeb48.png"), 36 UI.PixmapCache.getPixmap("ericWeb48.png"),
37 "eric6 Web Browser", 37 "eric6 Web Browser",
44 QCoreApplication.translate( 44 QCoreApplication.translate(
45 "XbelImporter", 45 "XbelImporter",
46 """Please choose the file to begin importing bookmarks."""), 46 """Please choose the file to begin importing bookmarks."""),
47 os.path.dirname(bookmarksFile), 47 os.path.dirname(bookmarksFile),
48 ) 48 )
49 elif id == "konqueror": 49 elif sourceId == "konqueror":
50 if os.path.exists(os.path.expanduser("~/.kde4")): 50 if os.path.exists(os.path.expanduser("~/.kde4")):
51 standardDir = os.path.expanduser("~/.kde4/share/apps/konqueror") 51 standardDir = os.path.expanduser("~/.kde4/share/apps/konqueror")
52 elif os.path.exists(os.path.expanduser("~/.kde")): 52 elif os.path.exists(os.path.expanduser("~/.kde")):
53 standardDir = os.path.expanduser("~/.kde/share/apps/konqueror") 53 standardDir = os.path.expanduser("~/.kde/share/apps/konqueror")
54 else: 54 else:
65 QCoreApplication.translate( 65 QCoreApplication.translate(
66 "XbelImporter", 66 "XbelImporter",
67 """Please choose the file to begin importing bookmarks."""), 67 """Please choose the file to begin importing bookmarks."""),
68 standardDir, 68 standardDir,
69 ) 69 )
70 elif id == "xbel": 70 elif sourceId == "xbel":
71 return ( 71 return (
72 UI.PixmapCache.getPixmap("xbel.png"), 72 UI.PixmapCache.getPixmap("xbel.png"),
73 "XBEL Bookmarks", 73 "XBEL Bookmarks",
74 QCoreApplication.translate( 74 QCoreApplication.translate(
75 "XbelImporter", "XBEL Bookmarks") + " (*.xbel *.xml)", 75 "XbelImporter", "XBEL Bookmarks") + " (*.xbel *.xml)",
82 "XbelImporter", 82 "XbelImporter",
83 """Please choose the file to begin importing bookmarks."""), 83 """Please choose the file to begin importing bookmarks."""),
84 "", 84 "",
85 ) 85 )
86 else: 86 else:
87 raise ValueError("Unsupported browser ID given ({0}).".format(id)) 87 raise ValueError(
88 "Unsupported browser ID given ({0}).".format(sourceId))
88 89
89 90
90 class XbelImporter(BookmarksImporter): 91 class XbelImporter(BookmarksImporter):
91 """ 92 """
92 Class implementing the XBEL bookmarks importer. 93 Class implementing the XBEL bookmarks importer.
93 """ 94 """
94 def __init__(self, id="", parent=None): 95 def __init__(self, sourceId="", parent=None):
95 """ 96 """
96 Constructor 97 Constructor
97 98
98 @param id source ID (string) 99 @param sourceId source ID (string)
99 @param parent reference to the parent object (QObject) 100 @param parent reference to the parent object (QObject)
100 """ 101 """
101 super(XbelImporter, self).__init__(id, parent) 102 super(XbelImporter, self).__init__(sourceId, parent)
102 103
103 self.__fileName = "" 104 self.__fileName = ""
104 105
105 def setPath(self, path): 106 def setPath(self, path):
106 """ 107 """

eric ide

mercurial