12 # Copyright (C) 2014 Razi Alavizadeh <s.r.alavizadeh@gmail.com> |
12 # Copyright (C) 2014 Razi Alavizadeh <s.r.alavizadeh@gmail.com> |
13 # |
13 # |
14 |
14 |
15 import collections |
15 import collections |
16 import os |
16 import os |
17 |
17 import re |
18 from PyQt5.QtCore import QObject, QUrl, QFile, QFileInfo, QRegExp, qWarning |
18 |
|
19 from PyQt5.QtCore import QObject, QUrl, QFile, QFileInfo, qWarning |
19 |
20 |
20 from E5Gui import E5MessageBox |
21 from E5Gui import E5MessageBox |
21 |
22 |
22 |
23 |
23 class E5TldHostParts(object): |
24 class E5TldHostParts(object): |
479 file = QFile(testDataFileName) |
480 file = QFile(testDataFileName) |
480 |
481 |
481 if not file.open(QFile.ReadOnly | QFile.Text): |
482 if not file.open(QFile.ReadOnly | QFile.Text): |
482 return False |
483 return False |
483 |
484 |
484 testRegExp = QRegExp( |
485 testRegExp = re.compile( |
485 "checkPublicSuffix\\(('([^']+)'|null), ('([^']+)'|null)\\);") |
486 "checkPublicSuffix\\(('([^']+)'|null), ('([^']+)'|null)\\);") |
486 allTestSuccess = True |
487 allTestSuccess = True |
487 |
488 |
488 while not file.atEnd(): |
489 while not file.atEnd(): |
489 line = bytes(file.readLine()).decode("utf-8").strip() |
490 line = bytes(file.readLine()).decode("utf-8").strip() |
490 if not line or line.startswith("//"): |
491 if not line or line.startswith("//"): |
491 continue |
492 continue |
492 |
493 |
493 if testRegExp.indexIn(line) == -1: |
494 match = testRegExp.search(line) |
|
495 if match is None: |
494 allTestSuccess = False |
496 allTestSuccess = False |
495 else: |
497 else: |
496 hostName = testRegExp.cap(2) |
498 hostName, registrableName = match.group(2, 4) |
497 registrableName = testRegExp.cap(4) |
|
498 |
499 |
499 if not self.__checkPublicSuffix(hostName, registrableName): |
500 if not self.__checkPublicSuffix(hostName, registrableName): |
500 allTestSuccess = False |
501 allTestSuccess = False |
501 |
502 |
502 if allTestSuccess: |
503 if allTestSuccess: |