Helpviewer/Bookmarks/BookmarksImporters/FirefoxImporter.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 3002
6ffc581f00f1
child 3058
0a02c433f52d
diff -r 9986ec0e559a -r 10516539f238 Helpviewer/Bookmarks/BookmarksImporters/FirefoxImporter.py
--- a/Helpviewer/Bookmarks/BookmarksImporters/FirefoxImporter.py	Tue Oct 15 22:03:54 2013 +0200
+++ b/Helpviewer/Bookmarks/BookmarksImporters/FirefoxImporter.py	Fri Oct 18 23:00:41 2013 +0200
@@ -24,9 +24,12 @@
     """
     Module function to get information for the given source id.
     
+    @param id id of the browser ("chrome" or "chromium")
     @return tuple with an icon (QPixmap), readable name (string), name of
         the default bookmarks file (string), an info text (string),
-        a prompt (string) and the default directory of the bookmarks file (string)
+        a prompt (string) and the default directory of the bookmarks file
+        (string)
+    @exception ValueError raised to indicate an invalid browser ID
     """
     if id == "firefox":
         if Globals.isWindowsPlatform():
@@ -42,8 +45,9 @@
             "Mozilla Firefox",
             "places.sqlite",
             QCoreApplication.translate("FirefoxImporter",
-                """Mozilla Firefox stores its bookmarks in the <b>places.sqlite</b> """
-                """SQLite database. This file is usually located in"""),
+                """Mozilla Firefox stores its bookmarks in the"""
+                """ <b>places.sqlite</b> SQLite database. This file is"""
+                """ usually located in"""),
             QCoreApplication.translate("FirefoxImporter",
                 """Please choose the file to begin importing bookmarks."""),
             standardDir,
@@ -92,8 +96,8 @@
             self.__db = sqlite3.connect(self.__fileName)
         except sqlite3.DatabaseError as err:
             self._error = True
-            self._errorString = self.trUtf8("Unable to open database.\nReason: {0}")\
-                .format(str(err))
+            self._errorString = self.trUtf8(
+                "Unable to open database.\nReason: {0}").format(str(err))
             return False
         
         return True
@@ -127,8 +131,8 @@
                 folders[id_] = folder
         except sqlite3.DatabaseError as err:
             self._error = True
-            self._errorString = self.trUtf8("Unable to open database.\nReason: {0}")\
-                .format(str(err))
+            self._errorString = self.trUtf8(
+                "Unable to open database.\nReason: {0}").format(str(err))
             return None
         
         try:
@@ -143,23 +147,27 @@
                 
                 cursor2 = self.__db.cursor()
                 cursor2.execute(
-                    "SELECT url FROM moz_places WHERE id = {0}".format(placesId))
+                    "SELECT url FROM moz_places WHERE id = {0}"
+                    .format(placesId))
                 row2 = cursor2.fetchone()
                 if row2:
                     url = QUrl(row2[0])
-                    if not title or url.isEmpty() or url.scheme() in ["place", "about"]:
+                    if not title or url.isEmpty() or \
+                            url.scheme() in ["place", "about"]:
                         continue
                     
                     if parent in folders:
-                        bookmark = BookmarkNode(BookmarkNode.Bookmark, folders[parent])
+                        bookmark = BookmarkNode(BookmarkNode.Bookmark,
+                                                folders[parent])
                     else:
-                        bookmark = BookmarkNode(BookmarkNode.Bookmark, importRootNode)
+                        bookmark = BookmarkNode(BookmarkNode.Bookmark,
+                                                importRootNode)
                     bookmark.url = url.toString()
                     bookmark.title = title.replace("&", "&&")
         except sqlite3.DatabaseError as err:
             self._error = True
-            self._errorString = self.trUtf8("Unable to open database.\nReason: {0}")\
-                .format(str(err))
+            self._errorString = self.trUtf8(
+                "Unable to open database.\nReason: {0}").format(str(err))
             return None
         
         importRootNode.setType(BookmarkNode.Folder)

eric ide

mercurial