src/eric7/WebBrowser/Bookmarks/NsHtmlReader.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/WebBrowser/Bookmarks/NsHtmlReader.py
--- a/src/eric7/WebBrowser/Bookmarks/NsHtmlReader.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/WebBrowser/Bookmarks/NsHtmlReader.py	Wed Jul 13 14:55:47 2022 +0200
@@ -20,14 +20,15 @@
     """
     Class implementing a reader object for Netscape HTML bookmark files.
     """
+
     indentSize = 4
-    
+
     def __init__(self):
         """
         Constructor
         """
         super().__init__()
-        
+
         self.__folderRx = re.compile("<DT><H3(.*?)>(.*?)</H3>", re.IGNORECASE)
         self.__endFolderRx = re.compile("</DL>", re.IGNORECASE)
         self.__bookmarkRx = re.compile("<DT><A(.*?)>(.*?)</A>", re.IGNORECASE)
@@ -35,15 +36,14 @@
         self.__separatorRx = re.compile("<HR>", re.IGNORECASE)
         self.__urlRx = re.compile('HREF="(.*?)"', re.IGNORECASE)
         self.__addedRx = re.compile(r'ADD_DATE="(\d*?)"', re.IGNORECASE)
-        self.__modifiedRx = re.compile(r'LAST_MODIFIED="(\d*?)"',
-                                       re.IGNORECASE)
+        self.__modifiedRx = re.compile(r'LAST_MODIFIED="(\d*?)"', re.IGNORECASE)
         self.__visitedRx = re.compile(r'LAST_VISIT="(\d*?)"', re.IGNORECASE)
         self.__foldedRx = re.compile("FOLDED", re.IGNORECASE)
-    
+
     def read(self, fileNameOrDevice):
         """
         Public method to read a Netscape HTML bookmark file.
-        
+
         @param fileNameOrDevice name of the file to read (string)
             or reference to the device to read (QIODevice)
         @return reference to the root node (BookmarkNode)
@@ -56,25 +56,25 @@
                 return BookmarkNode(BookmarkNode.Root)
             f.open(QIODevice.OpenModeFlag.ReadOnly)
             dev = f
-        
+
         folders = []
         lastNode = None
-        
+
         root = BookmarkNode(BookmarkNode.Root)
         folders.append(root)
-        
+
         while not dev.atEnd():
             line = str(dev.readLine(), encoding="utf-8").rstrip()
             match = (
-                self.__folderRx.search(line) or
-                self.__endFolderRx.search(line) or
-                self.__bookmarkRx.search(line) or
-                self.__descRx.search(line) or
-                self.__separatorRx.search(line)
+                self.__folderRx.search(line)
+                or self.__endFolderRx.search(line)
+                or self.__bookmarkRx.search(line)
+                or self.__descRx.search(line)
+                or self.__separatorRx.search(line)
             )
             if match is None:
                 continue
-            
+
             if match.re is self.__folderRx:
                 # folder definition
                 arguments = match.group(1)
@@ -84,15 +84,14 @@
                 node.expanded = self.__foldedRx.search(arguments) is None
                 addedMatch = self.__addedRx.search(arguments)
                 if addedMatch is not None:
-                    node.added = QDateTime.fromSecsSinceEpoch(
-                        int(addedMatch.group(1)))
+                    node.added = QDateTime.fromSecsSinceEpoch(int(addedMatch.group(1)))
                 folders.append(node)
                 lastNode = node
-            
+
             elif match.re is self.__endFolderRx:
                 # end of folder definition
                 folders.pop()
-            
+
             elif match.re is self.__bookmarkRx:
                 # bookmark definition
                 arguments = match.group(1)
@@ -104,26 +103,22 @@
                     node.url = match1.group(1)
                 match1 = self.__addedRx.search(arguments)
                 if match1 is not None:
-                    node.added = QDateTime.fromSecsSinceEpoch(
-                        int(match1.group(1)))
+                    node.added = QDateTime.fromSecsSinceEpoch(int(match1.group(1)))
                 match1 = self.__modifiedRx.search(arguments)
                 if match1 is not None:
-                    node.modified = QDateTime.fromSecsSinceEpoch(
-                        int(match1.group(1)))
+                    node.modified = QDateTime.fromSecsSinceEpoch(int(match1.group(1)))
                 match1 = self.__visitedRx.search(arguments)
                 if match1 is not None:
-                    node.visited = QDateTime.fromSecsSinceEpoch(
-                        int(match1.group(1)))
+                    node.visited = QDateTime.fromSecsSinceEpoch(int(match1.group(1)))
                 lastNode = node
-            
+
             elif match.re is self.__descRx:
                 # description
                 if lastNode:
-                    lastNode.desc = Utilities.html_udecode(
-                        match.group(1))
-            
+                    lastNode.desc = Utilities.html_udecode(match.group(1))
+
             elif match.re is self.__separatorRx:
                 # separator definition
                 BookmarkNode(BookmarkNode.Separator, folders[-1])
-        
+
         return root

eric ide

mercurial