|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.E5Network.E5TldExtractor</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.E5Network.E5TldExtractor</h1> |
|
23 <p> |
|
24 Module implementing the TLD Extractor. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>_TLDExtractor</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#E5TldExtractor">E5TldExtractor</a></td> |
|
34 <td>Class implementing the TLD Extractor.</td> |
|
35 </tr><tr> |
|
36 <td><a href="#E5TldHostParts">E5TldHostParts</a></td> |
|
37 <td>Class implementing the host parts helper.</td> |
|
38 </tr> |
|
39 </table> |
|
40 <h3>Functions</h3> |
|
41 <table> |
|
42 <tr> |
|
43 <td><a href="#instance">instance</a></td> |
|
44 <td>Global function to get a reference to the TLD extractor and create it, if it hasn't been yet.</td> |
|
45 </tr> |
|
46 </table> |
|
47 <hr /><hr /> |
|
48 <a NAME="E5TldExtractor" ID="E5TldExtractor"></a> |
|
49 <h2>E5TldExtractor</h2> |
|
50 <p> |
|
51 Class implementing the TLD Extractor. |
|
52 </p><p> |
|
53 Note: The module function instance() should be used to get a reference |
|
54 to a global object to avoid overhead. |
|
55 </p> |
|
56 <h3>Derived from</h3> |
|
57 QObject |
|
58 <h3>Class Attributes</h3> |
|
59 <table> |
|
60 <tr><td>None</td></tr> |
|
61 </table> |
|
62 <h3>Class Methods</h3> |
|
63 <table> |
|
64 <tr><td>None</td></tr> |
|
65 </table> |
|
66 <h3>Methods</h3> |
|
67 <table> |
|
68 <tr> |
|
69 <td><a href="#E5TldExtractor.__init__">E5TldExtractor</a></td> |
|
70 <td>Constructor</td> |
|
71 </tr><tr> |
|
72 <td><a href="#E5TldExtractor.__checkPublicSuffix">__checkPublicSuffix</a></td> |
|
73 <td>Private method to test a host name against a registrable name.</td> |
|
74 </tr><tr> |
|
75 <td><a href="#E5TldExtractor.__defaultDataSearchPaths">__defaultDataSearchPaths</a></td> |
|
76 <td>Private method to get the default search paths for the TLD data file.</td> |
|
77 </tr><tr> |
|
78 <td><a href="#E5TldExtractor.__domainHelper">__domainHelper</a></td> |
|
79 <td>Private method to get the domain name without TLD.</td> |
|
80 </tr><tr> |
|
81 <td><a href="#E5TldExtractor.__loadData">__loadData</a></td> |
|
82 <td>Private method to load the TLD data.</td> |
|
83 </tr><tr> |
|
84 <td><a href="#E5TldExtractor.__normalizedHost">__normalizedHost</a></td> |
|
85 <td>Private method to get the normalized host for a host address.</td> |
|
86 </tr><tr> |
|
87 <td><a href="#E5TldExtractor.__parseData">__parseData</a></td> |
|
88 <td>Private method to parse TLD data.</td> |
|
89 </tr><tr> |
|
90 <td><a href="#E5TldExtractor.__registrableDomainHelper">__registrableDomainHelper</a></td> |
|
91 <td>Private method to get the registrable domain (i.e.</td> |
|
92 </tr><tr> |
|
93 <td><a href="#E5TldExtractor.__subdomainHelper">__subdomainHelper</a></td> |
|
94 <td>Private method to get the subdomain of a host address (i.e.</td> |
|
95 </tr><tr> |
|
96 <td><a href="#E5TldExtractor.dataSearchPaths">dataSearchPaths</a></td> |
|
97 <td>Public method to get the search paths for the TLD data file.</td> |
|
98 </tr><tr> |
|
99 <td><a href="#E5TldExtractor.domain">domain</a></td> |
|
100 <td>Public method to get the domain for a host.</td> |
|
101 </tr><tr> |
|
102 <td><a href="#E5TldExtractor.getTldDownloadUrl">getTldDownloadUrl</a></td> |
|
103 <td>Public method to get the TLD data file download URL.</td> |
|
104 </tr><tr> |
|
105 <td><a href="#E5TldExtractor.isDataLoaded">isDataLoaded</a></td> |
|
106 <td>Public method to check, if the TLD data ia already loaded.</td> |
|
107 </tr><tr> |
|
108 <td><a href="#E5TldExtractor.registrableDomain">registrableDomain</a></td> |
|
109 <td>Public method to get the registrable domain for a host.</td> |
|
110 </tr><tr> |
|
111 <td><a href="#E5TldExtractor.setDataSearchPaths">setDataSearchPaths</a></td> |
|
112 <td>Public method to set the search paths for the TLD data file.</td> |
|
113 </tr><tr> |
|
114 <td><a href="#E5TldExtractor.splitParts">splitParts</a></td> |
|
115 <td>Public method to split a host address into its parts.</td> |
|
116 </tr><tr> |
|
117 <td><a href="#E5TldExtractor.subdomain">subdomain</a></td> |
|
118 <td>Public method to get the subdomain for a host.</td> |
|
119 </tr><tr> |
|
120 <td><a href="#E5TldExtractor.test">test</a></td> |
|
121 <td>Public method to execute the tests.</td> |
|
122 </tr><tr> |
|
123 <td><a href="#E5TldExtractor.tld">tld</a></td> |
|
124 <td>Public method to get the top level domain for a host.</td> |
|
125 </tr> |
|
126 </table> |
|
127 <h3>Static Methods</h3> |
|
128 <table> |
|
129 <tr><td>None</td></tr> |
|
130 </table> |
|
131 <a NAME="E5TldExtractor.__init__" ID="E5TldExtractor.__init__"></a> |
|
132 <h4>E5TldExtractor (Constructor)</h4> |
|
133 <b>E5TldExtractor</b>(<i>withPrivate=False, parent=None</i>) |
|
134 <p> |
|
135 Constructor |
|
136 </p><dl> |
|
137 <dt><i>withPrivate</i> (bool)</dt> |
|
138 <dd> |
|
139 flag indicating to load private TLDs as well |
|
140 </dd><dt><i>parent</i> (QObject)</dt> |
|
141 <dd> |
|
142 reference to the parent object |
|
143 </dd> |
|
144 </dl><a NAME="E5TldExtractor.__checkPublicSuffix" ID="E5TldExtractor.__checkPublicSuffix"></a> |
|
145 <h4>E5TldExtractor.__checkPublicSuffix</h4> |
|
146 <b>__checkPublicSuffix</b>(<i>host, registrableName</i>) |
|
147 <p> |
|
148 Private method to test a host name against a registrable name. |
|
149 </p><dl> |
|
150 <dt><i>host</i> (str)</dt> |
|
151 <dd> |
|
152 host name to test |
|
153 </dd><dt><i>registrableName</i> (str)</dt> |
|
154 <dd> |
|
155 registrable domain name to test against |
|
156 </dd> |
|
157 </dl><dl> |
|
158 <dt>Returns:</dt> |
|
159 <dd> |
|
160 flag indicating the check result |
|
161 </dd> |
|
162 </dl><dl> |
|
163 <dt>Return Type:</dt> |
|
164 <dd> |
|
165 bool |
|
166 </dd> |
|
167 </dl><a NAME="E5TldExtractor.__defaultDataSearchPaths" ID="E5TldExtractor.__defaultDataSearchPaths"></a> |
|
168 <h4>E5TldExtractor.__defaultDataSearchPaths</h4> |
|
169 <b>__defaultDataSearchPaths</b>(<i></i>) |
|
170 <p> |
|
171 Private method to get the default search paths for the TLD data file. |
|
172 </p><dl> |
|
173 <dt>Returns:</dt> |
|
174 <dd> |
|
175 default search paths for the TLD data file |
|
176 </dd> |
|
177 </dl><dl> |
|
178 <dt>Return Type:</dt> |
|
179 <dd> |
|
180 list of str |
|
181 </dd> |
|
182 </dl><a NAME="E5TldExtractor.__domainHelper" ID="E5TldExtractor.__domainHelper"></a> |
|
183 <h4>E5TldExtractor.__domainHelper</h4> |
|
184 <b>__domainHelper</b>(<i>host, tldPart</i>) |
|
185 <p> |
|
186 Private method to get the domain name without TLD. |
|
187 </p><dl> |
|
188 <dt><i>host</i> (str)</dt> |
|
189 <dd> |
|
190 host address |
|
191 </dd><dt><i>tldPart</i> (str)</dt> |
|
192 <dd> |
|
193 TLD part of the host address |
|
194 </dd> |
|
195 </dl><dl> |
|
196 <dt>Returns:</dt> |
|
197 <dd> |
|
198 domain name |
|
199 </dd> |
|
200 </dl><dl> |
|
201 <dt>Return Type:</dt> |
|
202 <dd> |
|
203 str |
|
204 </dd> |
|
205 </dl><a NAME="E5TldExtractor.__loadData" ID="E5TldExtractor.__loadData"></a> |
|
206 <h4>E5TldExtractor.__loadData</h4> |
|
207 <b>__loadData</b>(<i></i>) |
|
208 <p> |
|
209 Private method to load the TLD data. |
|
210 </p><a NAME="E5TldExtractor.__normalizedHost" ID="E5TldExtractor.__normalizedHost"></a> |
|
211 <h4>E5TldExtractor.__normalizedHost</h4> |
|
212 <b>__normalizedHost</b>(<i>host</i>) |
|
213 <p> |
|
214 Private method to get the normalized host for a host address. |
|
215 </p><dl> |
|
216 <dt><i>host</i> (str)</dt> |
|
217 <dd> |
|
218 host address to be normalized |
|
219 </dd> |
|
220 </dl><dl> |
|
221 <dt>Returns:</dt> |
|
222 <dd> |
|
223 normalized host address |
|
224 </dd> |
|
225 </dl><dl> |
|
226 <dt>Return Type:</dt> |
|
227 <dd> |
|
228 str |
|
229 </dd> |
|
230 </dl><a NAME="E5TldExtractor.__parseData" ID="E5TldExtractor.__parseData"></a> |
|
231 <h4>E5TldExtractor.__parseData</h4> |
|
232 <b>__parseData</b>(<i>dataFile, loadPrivateDomains=False</i>) |
|
233 <p> |
|
234 Private method to parse TLD data. |
|
235 </p><dl> |
|
236 <dt><i>dataFile</i> (str)</dt> |
|
237 <dd> |
|
238 name of the file containing the TLD data |
|
239 </dd><dt><i>loadPrivateDomains</i> (bool)</dt> |
|
240 <dd> |
|
241 flag indicating to load private domains |
|
242 </dd> |
|
243 </dl><dl> |
|
244 <dt>Returns:</dt> |
|
245 <dd> |
|
246 flag indicating success |
|
247 </dd> |
|
248 </dl><dl> |
|
249 <dt>Return Type:</dt> |
|
250 <dd> |
|
251 bool |
|
252 </dd> |
|
253 </dl><a NAME="E5TldExtractor.__registrableDomainHelper" ID="E5TldExtractor.__registrableDomainHelper"></a> |
|
254 <h4>E5TldExtractor.__registrableDomainHelper</h4> |
|
255 <b>__registrableDomainHelper</b>(<i>domainPart, tldPart</i>) |
|
256 <p> |
|
257 Private method to get the registrable domain (i.e. domain plus TLD). |
|
258 </p><dl> |
|
259 <dt><i>domainPart</i> (str)</dt> |
|
260 <dd> |
|
261 domain part of a host address |
|
262 </dd><dt><i>tldPart</i> (str)</dt> |
|
263 <dd> |
|
264 TLD part of a host address |
|
265 </dd> |
|
266 </dl><dl> |
|
267 <dt>Returns:</dt> |
|
268 <dd> |
|
269 registrable domain name |
|
270 </dd> |
|
271 </dl><dl> |
|
272 <dt>Return Type:</dt> |
|
273 <dd> |
|
274 str |
|
275 </dd> |
|
276 </dl><a NAME="E5TldExtractor.__subdomainHelper" ID="E5TldExtractor.__subdomainHelper"></a> |
|
277 <h4>E5TldExtractor.__subdomainHelper</h4> |
|
278 <b>__subdomainHelper</b>(<i>host, registrablePart</i>) |
|
279 <p> |
|
280 Private method to get the subdomain of a host address (i.e. domain part |
|
281 without the registrable domain name). |
|
282 </p><dl> |
|
283 <dt><i>host</i> (str)</dt> |
|
284 <dd> |
|
285 host address |
|
286 </dd><dt><i>registrablePart</i> (str)</dt> |
|
287 <dd> |
|
288 registrable domain part of the host address |
|
289 </dd> |
|
290 </dl><dl> |
|
291 <dt>Returns:</dt> |
|
292 <dd> |
|
293 subdomain name |
|
294 </dd> |
|
295 </dl><dl> |
|
296 <dt>Return Type:</dt> |
|
297 <dd> |
|
298 str |
|
299 </dd> |
|
300 </dl><a NAME="E5TldExtractor.dataSearchPaths" ID="E5TldExtractor.dataSearchPaths"></a> |
|
301 <h4>E5TldExtractor.dataSearchPaths</h4> |
|
302 <b>dataSearchPaths</b>(<i></i>) |
|
303 <p> |
|
304 Public method to get the search paths for the TLD data file. |
|
305 </p><dl> |
|
306 <dt>Returns:</dt> |
|
307 <dd> |
|
308 search paths for the TLD data file |
|
309 </dd> |
|
310 </dl><dl> |
|
311 <dt>Return Type:</dt> |
|
312 <dd> |
|
313 list of str |
|
314 </dd> |
|
315 </dl><a NAME="E5TldExtractor.domain" ID="E5TldExtractor.domain"></a> |
|
316 <h4>E5TldExtractor.domain</h4> |
|
317 <b>domain</b>(<i>host</i>) |
|
318 <p> |
|
319 Public method to get the domain for a host. |
|
320 </p><dl> |
|
321 <dt><i>host</i> (str)</dt> |
|
322 <dd> |
|
323 host name to get the domain for |
|
324 </dd> |
|
325 </dl><dl> |
|
326 <dt>Returns:</dt> |
|
327 <dd> |
|
328 domain for host |
|
329 </dd> |
|
330 </dl><dl> |
|
331 <dt>Return Type:</dt> |
|
332 <dd> |
|
333 str |
|
334 </dd> |
|
335 </dl><a NAME="E5TldExtractor.getTldDownloadUrl" ID="E5TldExtractor.getTldDownloadUrl"></a> |
|
336 <h4>E5TldExtractor.getTldDownloadUrl</h4> |
|
337 <b>getTldDownloadUrl</b>(<i></i>) |
|
338 <p> |
|
339 Public method to get the TLD data file download URL. |
|
340 </p><dl> |
|
341 <dt>Returns:</dt> |
|
342 <dd> |
|
343 download URL |
|
344 </dd> |
|
345 </dl><dl> |
|
346 <dt>Return Type:</dt> |
|
347 <dd> |
|
348 QUrl |
|
349 </dd> |
|
350 </dl><a NAME="E5TldExtractor.isDataLoaded" ID="E5TldExtractor.isDataLoaded"></a> |
|
351 <h4>E5TldExtractor.isDataLoaded</h4> |
|
352 <b>isDataLoaded</b>(<i></i>) |
|
353 <p> |
|
354 Public method to check, if the TLD data ia already loaded. |
|
355 </p><dl> |
|
356 <dt>Returns:</dt> |
|
357 <dd> |
|
358 flag indicating data is loaded |
|
359 </dd> |
|
360 </dl><dl> |
|
361 <dt>Return Type:</dt> |
|
362 <dd> |
|
363 bool |
|
364 </dd> |
|
365 </dl><a NAME="E5TldExtractor.registrableDomain" ID="E5TldExtractor.registrableDomain"></a> |
|
366 <h4>E5TldExtractor.registrableDomain</h4> |
|
367 <b>registrableDomain</b>(<i>host</i>) |
|
368 <p> |
|
369 Public method to get the registrable domain for a host. |
|
370 </p><dl> |
|
371 <dt><i>host</i> (str)</dt> |
|
372 <dd> |
|
373 host name to get the registrable domain for |
|
374 </dd> |
|
375 </dl><dl> |
|
376 <dt>Returns:</dt> |
|
377 <dd> |
|
378 registrable domain for host |
|
379 </dd> |
|
380 </dl><dl> |
|
381 <dt>Return Type:</dt> |
|
382 <dd> |
|
383 str |
|
384 </dd> |
|
385 </dl><a NAME="E5TldExtractor.setDataSearchPaths" ID="E5TldExtractor.setDataSearchPaths"></a> |
|
386 <h4>E5TldExtractor.setDataSearchPaths</h4> |
|
387 <b>setDataSearchPaths</b>(<i>searchPaths=None</i>) |
|
388 <p> |
|
389 Public method to set the search paths for the TLD data file. |
|
390 </p><dl> |
|
391 <dt><i>searchPaths</i> (list of str)</dt> |
|
392 <dd> |
|
393 search paths for the TLD data file or None, |
|
394 if the default search paths shall be set |
|
395 </dd> |
|
396 </dl><a NAME="E5TldExtractor.splitParts" ID="E5TldExtractor.splitParts"></a> |
|
397 <h4>E5TldExtractor.splitParts</h4> |
|
398 <b>splitParts</b>(<i>host</i>) |
|
399 <p> |
|
400 Public method to split a host address into its parts. |
|
401 </p><dl> |
|
402 <dt><i>host</i> (str)</dt> |
|
403 <dd> |
|
404 host address to be split |
|
405 </dd> |
|
406 </dl><dl> |
|
407 <dt>Returns:</dt> |
|
408 <dd> |
|
409 splitted host address |
|
410 </dd> |
|
411 </dl><dl> |
|
412 <dt>Return Type:</dt> |
|
413 <dd> |
|
414 E5TldHostParts |
|
415 </dd> |
|
416 </dl><a NAME="E5TldExtractor.subdomain" ID="E5TldExtractor.subdomain"></a> |
|
417 <h4>E5TldExtractor.subdomain</h4> |
|
418 <b>subdomain</b>(<i>host</i>) |
|
419 <p> |
|
420 Public method to get the subdomain for a host. |
|
421 </p><dl> |
|
422 <dt><i>host</i> (str)</dt> |
|
423 <dd> |
|
424 host name to get the subdomain for |
|
425 </dd> |
|
426 </dl><dl> |
|
427 <dt>Returns:</dt> |
|
428 <dd> |
|
429 subdomain for host |
|
430 </dd> |
|
431 </dl><dl> |
|
432 <dt>Return Type:</dt> |
|
433 <dd> |
|
434 str |
|
435 </dd> |
|
436 </dl><a NAME="E5TldExtractor.test" ID="E5TldExtractor.test"></a> |
|
437 <h4>E5TldExtractor.test</h4> |
|
438 <b>test</b>(<i></i>) |
|
439 <p> |
|
440 Public method to execute the tests. |
|
441 </p><dl> |
|
442 <dt>Returns:</dt> |
|
443 <dd> |
|
444 flag indicating the test result |
|
445 </dd> |
|
446 </dl><dl> |
|
447 <dt>Return Type:</dt> |
|
448 <dd> |
|
449 bool |
|
450 </dd> |
|
451 </dl><a NAME="E5TldExtractor.tld" ID="E5TldExtractor.tld"></a> |
|
452 <h4>E5TldExtractor.tld</h4> |
|
453 <b>tld</b>(<i>host</i>) |
|
454 <p> |
|
455 Public method to get the top level domain for a host. |
|
456 </p><dl> |
|
457 <dt><i>host</i> (str)</dt> |
|
458 <dd> |
|
459 host name to get TLD for |
|
460 </dd> |
|
461 </dl><dl> |
|
462 <dt>Returns:</dt> |
|
463 <dd> |
|
464 TLD for host |
|
465 </dd> |
|
466 </dl><dl> |
|
467 <dt>Return Type:</dt> |
|
468 <dd> |
|
469 str |
|
470 </dd> |
|
471 </dl> |
|
472 <div align="right"><a href="#top">Up</a></div> |
|
473 <hr /><hr /> |
|
474 <a NAME="E5TldHostParts" ID="E5TldHostParts"></a> |
|
475 <h2>E5TldHostParts</h2> |
|
476 <p> |
|
477 Class implementing the host parts helper. |
|
478 </p> |
|
479 <h3>Derived from</h3> |
|
480 object |
|
481 <h3>Class Attributes</h3> |
|
482 <table> |
|
483 <tr><td>None</td></tr> |
|
484 </table> |
|
485 <h3>Class Methods</h3> |
|
486 <table> |
|
487 <tr><td>None</td></tr> |
|
488 </table> |
|
489 <h3>Methods</h3> |
|
490 <table> |
|
491 <tr> |
|
492 <td><a href="#E5TldHostParts.__init__">E5TldHostParts</a></td> |
|
493 <td>Constructor</td> |
|
494 </tr> |
|
495 </table> |
|
496 <h3>Static Methods</h3> |
|
497 <table> |
|
498 <tr><td>None</td></tr> |
|
499 </table> |
|
500 <a NAME="E5TldHostParts.__init__" ID="E5TldHostParts.__init__"></a> |
|
501 <h4>E5TldHostParts (Constructor)</h4> |
|
502 <b>E5TldHostParts</b>(<i></i>) |
|
503 <p> |
|
504 Constructor |
|
505 </p> |
|
506 <div align="right"><a href="#top">Up</a></div> |
|
507 <hr /><hr /> |
|
508 <a NAME="instance" ID="instance"></a> |
|
509 <h2>instance</h2> |
|
510 <b>instance</b>(<i>withPrivate=False</i>) |
|
511 <p> |
|
512 Global function to get a reference to the TLD extractor and create it, if |
|
513 it hasn't been yet. |
|
514 </p><dl> |
|
515 <dt><i>withPrivate</i> (bool)</dt> |
|
516 <dd> |
|
517 flag indicating to load private TLDs as well |
|
518 </dd> |
|
519 </dl><dl> |
|
520 <dt>Returns:</dt> |
|
521 <dd> |
|
522 reference to the zoom manager object |
|
523 </dd> |
|
524 </dl><dl> |
|
525 <dt>Return Type:</dt> |
|
526 <dd> |
|
527 E5TldExtractor |
|
528 </dd> |
|
529 </dl> |
|
530 <div align="right"><a href="#top">Up</a></div> |
|
531 <hr /> |
|
532 </body></html> |