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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/WebBrowser/Bookmarks/BookmarksImporters/IExplorerImporter.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/WebBrowser/Bookmarks/BookmarksImporters/IExplorerImporter.py	Wed Jul 13 14:55:47 2022 +0200
@@ -20,7 +20,7 @@
 def getImporterInfo(sourceId):
     """
     Module function to get information for the given source id.
-    
+
     @param sourceId 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),
@@ -29,13 +29,12 @@
     @exception ValueError raised to indicate an invalid browser ID
     """
     if sourceId != "ie":
-        raise ValueError(
-            "Unsupported browser ID given ({0}).".format(sourceId))
-    
+        raise ValueError("Unsupported browser ID given ({0}).".format(sourceId))
+
     standardDir = (
         os.path.expandvars("%USERPROFILE%\\Favorites")
-        if Globals.isWindowsPlatform() else
-        ""
+        if Globals.isWindowsPlatform()
+        else ""
     )
     return (
         UI.PixmapCache.getPixmap("internet_explorer"),
@@ -45,10 +44,12 @@
             "IExplorerImporter",
             """Internet Explorer stores its bookmarks in the"""
             """ <b>Favorites</b> folder This folder is usually"""
-            """ located in"""),
+            """ located in""",
+        ),
         QCoreApplication.translate(
             "IExplorerImporter",
-            """Please choose the folder to begin importing bookmarks."""),
+            """Please choose the folder to begin importing bookmarks.""",
+        ),
         standardDir,
     )
 
@@ -57,68 +58,69 @@
     """
     Class implementing the Chrome bookmarks importer.
     """
+
     def __init__(self, sourceId="", parent=None):
         """
         Constructor
-        
+
         @param sourceId source ID (string)
         @param parent reference to the parent object (QObject)
         """
         super().__init__(sourceId, parent)
-        
+
         self.__fileName = ""
-    
+
     def setPath(self, path):
         """
         Public method to set the path of the bookmarks file or directory.
-        
+
         @param path bookmarks file or directory (string)
         """
         self.__fileName = path
-    
+
     def open(self):
         """
         Public method to open the bookmarks file.
-        
+
         @return flag indicating success (boolean)
         """
         if not os.path.exists(self.__fileName):
             self._error = True
-            self._errorString = self.tr(
-                "Folder '{0}' does not exist."
-            ).format(self.__fileName)
+            self._errorString = self.tr("Folder '{0}' does not exist.").format(
+                self.__fileName
+            )
             return False
         if not os.path.isdir(self.__fileName):
             self._error = True
-            self._errorString = self.tr(
-                "'{0}' is not a folder."
-            ).format(self.__fileName)
+            self._errorString = self.tr("'{0}' is not a folder.").format(
+                self.__fileName
+            )
         return True
-    
+
     def importedBookmarks(self):
         """
         Public method to get the imported bookmarks.
-        
+
         @return imported bookmarks (BookmarkNode)
         """
         from ..BookmarkNode import BookmarkNode
-        
+
         folders = {}
-        
+
         importRootNode = BookmarkNode(BookmarkNode.Folder)
         folders[self.__fileName] = importRootNode
-        
+
         for directory, subdirs, files in os.walk(self.__fileName):
             for subdir in subdirs:
                 path = os.path.join(directory, subdir)
                 folder = (
                     BookmarkNode(BookmarkNode.Folder, folders[directory])
-                    if directory in folders else
-                    BookmarkNode(BookmarkNode.Folder, importRootNode)
+                    if directory in folders
+                    else BookmarkNode(BookmarkNode.Folder, importRootNode)
                 )
                 folder.title = subdir.replace("&", "&&")
                 folders[path] = folder
-            
+
             for file in files:
                 name, ext = os.path.splitext(file)
                 if ext.lower() == ".url":
@@ -135,19 +137,20 @@
                             break
                     if url:
                         if directory in folders:
-                            bookmark = BookmarkNode(BookmarkNode.Bookmark,
-                                                    folders[directory])
+                            bookmark = BookmarkNode(
+                                BookmarkNode.Bookmark, folders[directory]
+                            )
                         else:
-                            bookmark = BookmarkNode(BookmarkNode.Bookmark,
-                                                    importRootNode)
+                            bookmark = BookmarkNode(
+                                BookmarkNode.Bookmark, importRootNode
+                            )
                         bookmark.url = url
                         bookmark.title = name.replace("&", "&&")
-        
+
         if self._id == "ie":
             importRootNode.title = self.tr("Internet Explorer Import")
         else:
-            importRootNode.title = self.tr(
-                "Imported {0}"
-            ).format(QDate.currentDate().toString(
-                Qt.DateFormat.SystemLocaleShortDate))
+            importRootNode.title = self.tr("Imported {0}").format(
+                QDate.currentDate().toString(Qt.DateFormat.SystemLocaleShortDate)
+            )
         return importRootNode

eric ide

mercurial