Helpviewer/Bookmarks/BookmarksImporters/XbelImporter.py

changeset 3002
6ffc581f00f1
parent 2954
bf0215fe12d1
child 3022
57179e4cdadd
child 3057
10516539f238
equal deleted inserted replaced
3001:3674ff5fa8f8 3002:6ffc581f00f1
21 Module function to get information for the given XBEL source id. 21 Module function to get information for the given XBEL source id.
22 22
23 @param id id of the browser ("chrome" or "chromium") 23 @param id id of the browser ("chrome" or "chromium")
24 @return tuple with an icon (QPixmap), readable name (string), name of 24 @return tuple with an icon (QPixmap), readable name (string), name of
25 the default bookmarks file (string), an info text (string), 25 the default bookmarks file (string), an info text (string),
26 a prompt (string) and the default directory of the bookmarks file (string) 26 a prompt (string) and the default directory of the bookmarks file
27 (string)
27 @exception ValueError raised to indicate an invalid browser ID 28 @exception ValueError raised to indicate an invalid browser ID
28 """ 29 """
29 if id == "e5browser": 30 if id == "e5browser":
30 from ..BookmarksManager import BookmarksManager 31 from ..BookmarksManager import BookmarksManager
31 bookmarksFile = BookmarksManager.getFileName() 32 bookmarksFile = BookmarksManager.getFileName()
32 return ( 33 return (
33 UI.PixmapCache.getPixmap("ericWeb48.png"), 34 UI.PixmapCache.getPixmap("ericWeb48.png"),
34 "eric5 Web Browser", 35 "eric5 Web Browser",
35 os.path.basename(bookmarksFile), 36 os.path.basename(bookmarksFile),
36 QCoreApplication.translate("XbelImporter", 37 QCoreApplication.translate(
37 """eric5 Web Browser stores its bookmarks in the <b>{0}</b> XML file. """ 38 "XbelImporter",
38 """This file is usually located in""" 39 """eric5 Web Browser stores its bookmarks in the"""
40 """ <b>{0}</b> XML file. This file is usually located in"""
39 ).format(os.path.basename(bookmarksFile)), 41 ).format(os.path.basename(bookmarksFile)),
40 QCoreApplication.translate("XbelImporter", 42 QCoreApplication.translate("XbelImporter",
41 """Please choose the file to begin importing bookmarks."""), 43 """Please choose the file to begin importing bookmarks."""),
42 os.path.dirname(bookmarksFile), 44 os.path.dirname(bookmarksFile),
43 ) 45 )
50 standardDir = "" 52 standardDir = ""
51 return ( 53 return (
52 UI.PixmapCache.getPixmap("konqueror.png"), 54 UI.PixmapCache.getPixmap("konqueror.png"),
53 "Konqueror", 55 "Konqueror",
54 "bookmarks.xml", 56 "bookmarks.xml",
55 QCoreApplication.translate("XbelImporter", 57 QCoreApplication.translate(
56 """Konqueror stores its bookmarks in the <b>bookmarks.xml</b> XML """ 58 "XbelImporter",
57 """file. This file is usually located in"""), 59 """Konqueror stores its bookmarks in the"""
60 """ <b>bookmarks.xml</b> XML file. This file is usually"""
61 """ located in"""),
58 QCoreApplication.translate("XbelImporter", 62 QCoreApplication.translate("XbelImporter",
59 """Please choose the file to begin importing bookmarks."""), 63 """Please choose the file to begin importing bookmarks."""),
60 standardDir, 64 standardDir,
61 ) 65 )
62 elif id == "xbel": 66 elif id == "xbel":
63 return ( 67 return (
64 UI.PixmapCache.getPixmap("xbel.png"), 68 UI.PixmapCache.getPixmap("xbel.png"),
65 "XBEL Bookmarks", 69 "XBEL Bookmarks",
66 QCoreApplication.translate("XbelImporter", "XBEL Bookmarks") + \ 70 QCoreApplication.translate(
67 " (*.xbel *.xml)", 71 "XbelImporter", "XBEL Bookmarks") + " (*.xbel *.xml)",
68 QCoreApplication.translate("XbelImporter", 72 QCoreApplication.translate(
69 """You can import bookmarks from any browser that supports XBEL """ 73 "XbelImporter",
70 """exporting. This file has usually the extension .xbel or .xml."""), 74 """You can import bookmarks from any browser that supports"""
71 QCoreApplication.translate("XbelImporter", 75 """ XBEL exporting. This file has usually the extension"""
76 """ .xbel or .xml."""),
77 QCoreApplication.translate(
78 "XbelImporter",
72 """Please choose the file to begin importing bookmarks."""), 79 """Please choose the file to begin importing bookmarks."""),
73 "", 80 "",
74 ) 81 )
75 else: 82 else:
76 raise ValueError("Unsupported browser ID given ({0}).".format(id)) 83 raise ValueError("Unsupported browser ID given ({0}).".format(id))
124 importRootNode = reader.read(self.__fileName) 131 importRootNode = reader.read(self.__fileName)
125 132
126 if reader.error() != QXmlStreamReader.NoError: 133 if reader.error() != QXmlStreamReader.NoError:
127 self._error = True 134 self._error = True
128 self._errorString = self.trUtf8( 135 self._errorString = self.trUtf8(
129 """Error when importing bookmarks on line {0}, column {1}:\n{2}""")\ 136 """Error when importing bookmarks on line {0},"""
137 """ column {1}:\n{2}""")\
130 .format(reader.lineNumber(), 138 .format(reader.lineNumber(),
131 reader.columnNumber(), 139 reader.columnNumber(),
132 reader.errorString()) 140 reader.errorString())
133 return None 141 return None
134 142

eric ide

mercurial