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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/WebBrowser/Bookmarks/BookmarksImporters/XbelImporter.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/WebBrowser/Bookmarks/BookmarksImporters/XbelImporter.py	Wed Jul 13 14:55:47 2022 +0200
@@ -19,7 +19,7 @@
 def getImporterInfo(sourceId):
     """
     Module function to get information for the given XBEL 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),
@@ -28,11 +28,11 @@
     @exception ValueError raised to indicate an invalid browser ID
     """
     if sourceId not in ("e5browser", "konqueror", "xbel"):
-        raise ValueError(
-            "Unsupported browser ID given ({0}).".format(sourceId))
-    
+        raise ValueError("Unsupported browser ID given ({0}).".format(sourceId))
+
     if sourceId == "e5browser":
         from ..BookmarksManager import BookmarksManager
+
         bookmarksFile = BookmarksManager.getFileName()
         return (
             UI.PixmapCache.getPixmap("ericWeb48"),
@@ -41,11 +41,12 @@
             QCoreApplication.translate(
                 "XbelImporter",
                 """eric Web Browser stores its bookmarks in the"""
-                """ <b>{0}</b> XML file. This file is usually located in"""
+                """ <b>{0}</b> XML file. This file is usually located in""",
             ).format(os.path.basename(bookmarksFile)),
             QCoreApplication.translate(
                 "XbelImporter",
-                """Please choose the file to begin importing bookmarks."""),
+                """Please choose the file to begin importing bookmarks.""",
+            ),
             os.path.dirname(bookmarksFile),
         )
     elif sourceId == "konqueror":
@@ -63,26 +64,30 @@
                 "XbelImporter",
                 """Konqueror stores its bookmarks in the"""
                 """ <b>bookmarks.xml</b> XML file. This file is usually"""
-                """ located in"""),
+                """ located in""",
+            ),
             QCoreApplication.translate(
                 "XbelImporter",
-                """Please choose the file to begin importing bookmarks."""),
+                """Please choose the file to begin importing bookmarks.""",
+            ),
             standardDir,
         )
     else:
         return (
             UI.PixmapCache.getPixmap("xbel"),
             "XBEL Bookmarks",
-            QCoreApplication.translate(
-                "XbelImporter", "XBEL Bookmarks") + " (*.xbel *.xml)",
+            QCoreApplication.translate("XbelImporter", "XBEL Bookmarks")
+            + " (*.xbel *.xml)",
             QCoreApplication.translate(
                 "XbelImporter",
                 """You can import bookmarks from any browser that supports"""
                 """ XBEL exporting. This file has usually the extension"""
-                """ .xbel or .xml."""),
+                """ .xbel or .xml.""",
+            ),
             QCoreApplication.translate(
                 "XbelImporter",
-                """Please choose the file to begin importing bookmarks."""),
+                """Please choose the file to begin importing bookmarks.""",
+            ),
             "",
         )
 
@@ -91,61 +96,61 @@
     """
     Class implementing the XBEL 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(
-                "File '{0}' does not exist."
-            ).format(self.__fileName)
+            self._errorString = self.tr("File '{0}' does not exist.").format(
+                self.__fileName
+            )
             return False
         return True
-    
+
     def importedBookmarks(self):
         """
         Public method to get the imported bookmarks.
-        
+
         @return imported bookmarks (BookmarkNode)
         """
         from ..XbelReader import XbelReader
-        
+
         reader = XbelReader()
         importRootNode = reader.read(self.__fileName)
-        
+
         if reader.error() != QXmlStreamReader.Error.NoError:
             self._error = True
             self._errorString = self.tr(
                 """Error when importing bookmarks on line {0},"""
                 """ column {1}:\n{2}"""
-            ).format(reader.lineNumber(),
-                     reader.columnNumber(),
-                     reader.errorString())
+            ).format(reader.lineNumber(), reader.columnNumber(), reader.errorString())
             return None
-        
+
         from ..BookmarkNode import BookmarkNode
+
         importRootNode.setType(BookmarkNode.Folder)
         if self._id == "e5browser":
             importRootNode.title = self.tr("eric Web Browser Import")
@@ -154,8 +159,7 @@
         elif self._id == "xbel":
             importRootNode.title = self.tr("XBEL 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