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