32 |
32 |
33 def __init__(self, html, parent=None): |
33 def __init__(self, html, parent=None): |
34 """ |
34 """ |
35 Constructor |
35 Constructor |
36 |
36 |
37 @param html HTML text to be converted (string) |
37 @param html HTML text to be converted |
38 @param parent reference to the parent object (QObject) |
38 @type str |
|
39 @param parent reference to the parent object |
|
40 @type QObject |
39 """ |
41 """ |
40 super().__init__(parent) |
42 super().__init__(parent) |
41 |
43 |
42 self.__html = html |
44 self.__html = html |
43 |
45 |
44 def getJavaScript(self): |
46 def getJavaScript(self): |
45 """ |
47 """ |
46 Public method to get the converted JavaScript text. |
48 Public method to get the converted JavaScript text. |
47 |
49 |
48 @return JavaScript text (string) |
50 @return JavaScript text |
|
51 @rtype str |
49 """ |
52 """ |
50 dlg = Html5ToJsConverterParameterDialog() |
53 dlg = Html5ToJsConverterParameterDialog() |
51 if dlg.exec() == QDialog.Accepted: |
54 if dlg.exec() == QDialog.DialogCode.Accepted: |
52 indentation, scriptTags = dlg.getData() |
55 indentation, scriptTags = dlg.getData() |
53 |
56 |
54 self.__createSoup() |
57 self.__createSoup() |
55 |
58 |
56 alreadyDone = list(self.TagsToIgnore) |
59 alreadyDone = list(self.TagsToIgnore) |
131 def __getClasses(self): |
134 def __getClasses(self): |
132 """ |
135 """ |
133 Private method to extract all classes of the HTML text. |
136 Private method to extract all classes of the HTML text. |
134 |
137 |
135 @return list of tuples containing the tag name and its classes |
138 @return list of tuples containing the tag name and its classes |
136 as a blank separated string (list of tuples of two strings) |
139 as a blank separated string |
|
140 @rtype list of tuples of (str, str) |
137 """ |
141 """ |
138 classes = [(t.name, " ".join(t["class"])) for t in |
142 classes = [(t.name, " ".join(t["class"])) for t in |
139 self.__soup.find_all(True, {"class": True})] |
143 self.__soup.find_all(True, {"class": True})] |
140 return sorted(list(set(classes))) |
144 return sorted(list(set(classes))) |
141 |
145 |
142 def __getIds(self): |
146 def __getIds(self): |
143 """ |
147 """ |
144 Private method to extract all IDs of the HTML text. |
148 Private method to extract all IDs of the HTML text. |
145 |
149 |
146 @return list of tuples containing the tag name and its ID |
150 @return list of tuples containing the tag name and its ID |
147 (list of tuples of two strings) |
151 @rtype list of tuples of (str, str) |
148 """ |
152 """ |
149 ids = [(t.name, t["id"]) for t in |
153 ids = [(t.name, t["id"]) for t in |
150 self.__soup.find_all(True, {"id": True})] |
154 self.__soup.find_all(True, {"id": True})] |
151 return sorted(list(set(ids))) |
155 return sorted(list(set(ids))) |