20 |
20 |
21 def getImporterInfo(sourceId): |
21 def getImporterInfo(sourceId): |
22 """ |
22 """ |
23 Module function to get information for the given source id. |
23 Module function to get information for the given source id. |
24 |
24 |
25 @param sourceId id of the browser ("chrome" or "chromium") |
25 @param sourceId id of the browser |
26 @return tuple with an icon (QPixmap), readable name (string), name of |
26 @type str |
27 the default bookmarks file (string), an info text (string), |
27 @return tuple with an icon, readable name, name of the default |
28 a prompt (string) and the default directory of the bookmarks file |
28 bookmarks file, an info text, a prompt and the default directory |
29 (string) |
29 of the bookmarks file |
|
30 @rtype tuple of (QPixmap, str, str, str, str, str) |
30 @exception ValueError raised to indicate an invalid browser ID |
31 @exception ValueError raised to indicate an invalid browser ID |
31 """ |
32 """ |
32 if sourceId != "safari": |
33 if sourceId != "safari": |
33 raise ValueError("Unsupported browser ID given ({0}).".format(sourceId)) |
34 raise ValueError("Unsupported browser ID given ({0}).".format(sourceId)) |
34 |
35 |
75 |
76 |
76 def setPath(self, path): |
77 def setPath(self, path): |
77 """ |
78 """ |
78 Public method to set the path of the bookmarks file or directory. |
79 Public method to set the path of the bookmarks file or directory. |
79 |
80 |
80 @param path bookmarks file or directory (string) |
81 @param path bookmarks file or directory |
|
82 @type str |
81 """ |
83 """ |
82 self.__fileName = path |
84 self.__fileName = path |
83 |
85 |
84 def open(self): |
86 def open(self): |
85 """ |
87 """ |
86 Public method to open the bookmarks file. |
88 Public method to open the bookmarks file. |
87 |
89 |
88 @return flag indicating success (boolean) |
90 @return flag indicating success |
|
91 @rtype bool |
89 """ |
92 """ |
90 if not os.path.exists(self.__fileName): |
93 if not os.path.exists(self.__fileName): |
91 self._error = True |
94 self._error = True |
92 self._errorString = self.tr("File '{0}' does not exist.").format( |
95 self._errorString = self.tr("File '{0}' does not exist.").format( |
93 self.__fileName |
96 self.__fileName |
97 |
100 |
98 def importedBookmarks(self): |
101 def importedBookmarks(self): |
99 """ |
102 """ |
100 Public method to get the imported bookmarks. |
103 Public method to get the imported bookmarks. |
101 |
104 |
102 @return imported bookmarks (BookmarkNode) |
105 @return imported bookmarks |
|
106 @rtype BookmarkNode |
103 """ |
107 """ |
104 from ..BookmarkNode import BookmarkNode |
108 from ..BookmarkNode import BookmarkNode |
105 |
109 |
106 try: |
110 try: |
107 with open(self.__fileName, "rb") as f: |
111 with open(self.__fileName, "rb") as f: |
130 |
134 |
131 def __processChildren(self, children, rootNode): |
135 def __processChildren(self, children, rootNode): |
132 """ |
136 """ |
133 Private method to process the list of children. |
137 Private method to process the list of children. |
134 |
138 |
135 @param children list of child nodes to be processed (list of dict) |
139 @param children list of child nodes to be processed |
136 @param rootNode node to add the bookmarks to (BookmarkNode) |
140 @type list of dict |
|
141 @param rootNode node to add the bookmarks to |
|
142 @type BookmarkNode |
137 """ |
143 """ |
138 from ..BookmarkNode import BookmarkNode |
144 from ..BookmarkNode import BookmarkNode |
139 |
145 |
140 for child in children: |
146 for child in children: |
141 if child["WebBookmarkType"] == "WebBookmarkTypeList": |
147 if child["WebBookmarkType"] == "WebBookmarkTypeList": |