9 |
9 |
10 import re |
10 import re |
11 |
11 |
12 from PyQt6.QtCore import QDateTime, QFile, QIODevice, QObject |
12 from PyQt6.QtCore import QDateTime, QFile, QIODevice, QObject |
13 |
13 |
14 from eric7 import Utilities |
14 from eric7 import EricUtilities |
15 |
15 |
16 from .BookmarkNode import BookmarkNode, BookmarkNodeType |
16 from .BookmarkNode import BookmarkNode, BookmarkNodeType |
17 |
17 |
18 |
18 |
19 class NsHtmlReader(QObject): |
19 class NsHtmlReader(QObject): |
78 if match.re is self.__folderRx: |
78 if match.re is self.__folderRx: |
79 # folder definition |
79 # folder definition |
80 arguments = match.group(1) |
80 arguments = match.group(1) |
81 name = match.group(2) |
81 name = match.group(2) |
82 node = BookmarkNode(BookmarkNodeType.Folder, folders[-1]) |
82 node = BookmarkNode(BookmarkNodeType.Folder, folders[-1]) |
83 node.title = Utilities.html_udecode(name) |
83 node.title = EricUtilities.html_udecode(name) |
84 node.expanded = self.__foldedRx.search(arguments) is None |
84 node.expanded = self.__foldedRx.search(arguments) is None |
85 addedMatch = self.__addedRx.search(arguments) |
85 addedMatch = self.__addedRx.search(arguments) |
86 if addedMatch is not None: |
86 if addedMatch is not None: |
87 node.added = QDateTime.fromSecsSinceEpoch(int(addedMatch.group(1))) |
87 node.added = QDateTime.fromSecsSinceEpoch(int(addedMatch.group(1))) |
88 folders.append(node) |
88 folders.append(node) |
95 elif match.re is self.__bookmarkRx: |
95 elif match.re is self.__bookmarkRx: |
96 # bookmark definition |
96 # bookmark definition |
97 arguments = match.group(1) |
97 arguments = match.group(1) |
98 name = match.group(2) |
98 name = match.group(2) |
99 node = BookmarkNode(BookmarkNodeType.Bookmark, folders[-1]) |
99 node = BookmarkNode(BookmarkNodeType.Bookmark, folders[-1]) |
100 node.title = Utilities.html_udecode(name) |
100 node.title = EricUtilities.html_udecode(name) |
101 match1 = self.__urlRx.search(arguments) |
101 match1 = self.__urlRx.search(arguments) |
102 if match1 is not None: |
102 if match1 is not None: |
103 node.url = match1.group(1) |
103 node.url = match1.group(1) |
104 match1 = self.__addedRx.search(arguments) |
104 match1 = self.__addedRx.search(arguments) |
105 if match1 is not None: |
105 if match1 is not None: |
113 lastNode = node |
113 lastNode = node |
114 |
114 |
115 elif match.re is self.__descRx: |
115 elif match.re is self.__descRx: |
116 # description |
116 # description |
117 if lastNode: |
117 if lastNode: |
118 lastNode.desc = Utilities.html_udecode(match.group(1)) |
118 lastNode.desc = EricUtilities.html_udecode(match.group(1)) |
119 |
119 |
120 elif match.re is self.__separatorRx: |
120 elif match.re is self.__separatorRx: |
121 # separator definition |
121 # separator definition |
122 BookmarkNode(BookmarkNodeType.Separator, folders[-1]) |
122 BookmarkNode(BookmarkNodeType.Separator, folders[-1]) |
123 |
123 |