src/eric7/WebBrowser/Bookmarks/BookmarksImporters/OperaImporter.py

branch
eric7
changeset 10436
f6881d10e995
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10435:c712d09cc839 10436:f6881d10e995
19 19
20 def getImporterInfo(sourceId): 20 def getImporterInfo(sourceId):
21 """ 21 """
22 Module function to get information for the given source id. 22 Module function to get information for the given source id.
23 23
24 @param sourceId id of the browser ("chrome" or "chromium") 24 @param sourceId id of the browser
25 @return tuple with an icon (QPixmap), readable name (string), name of 25 @type str
26 the default bookmarks file (string), an info text (string), 26 @return tuple with an icon, readable name, name of the default
27 a prompt (string) and the default directory of the bookmarks file 27 bookmarks file, an info text, a prompt and the default directory
28 (string) 28 of the bookmarks file
29 @rtype tuple of (QPixmap, str, str, str, str, str)
29 @exception ValueError raised to indicate an invalid browser ID 30 @exception ValueError raised to indicate an invalid browser ID
30 """ 31 """
31 if sourceId != "opera_legacy": 32 if sourceId != "opera_legacy":
32 raise ValueError("Unsupported browser ID given ({0}).".format(sourceId)) 33 raise ValueError("Unsupported browser ID given ({0}).".format(sourceId))
33 34
73 74
74 def setPath(self, path): 75 def setPath(self, path):
75 """ 76 """
76 Public method to set the path of the bookmarks file or directory. 77 Public method to set the path of the bookmarks file or directory.
77 78
78 @param path bookmarks file or directory (string) 79 @param path bookmarks file or directory
80 @type str
79 """ 81 """
80 self.__fileName = path 82 self.__fileName = path
81 83
82 def open(self): 84 def open(self):
83 """ 85 """
84 Public method to open the bookmarks file. 86 Public method to open the bookmarks file.
85 87
86 @return flag indicating success (boolean) 88 @return flag indicating success
89 @rtype bool
87 """ 90 """
88 if not os.path.exists(self.__fileName): 91 if not os.path.exists(self.__fileName):
89 self._error = True 92 self._error = True
90 self._errorString = self.tr("File '{0}' does not exist.").format( 93 self._errorString = self.tr("File '{0}' does not exist.").format(
91 self.__fileName 94 self.__fileName
95 98
96 def importedBookmarks(self): 99 def importedBookmarks(self):
97 """ 100 """
98 Public method to get the imported bookmarks. 101 Public method to get the imported bookmarks.
99 102
100 @return imported bookmarks (BookmarkNode) 103 @return imported bookmarks
104 @rtype BookmarkNode
101 """ 105 """
102 from ..BookmarkNode import BookmarkNode 106 from ..BookmarkNode import BookmarkNode
103 107
104 try: 108 try:
105 with open(self.__fileName, "r", encoding="utf-8") as f: 109 with open(self.__fileName, "r", encoding="utf-8") as f:

eric ide

mercurial