src/eric7/EricNetwork/EricTldExtractor.py

branch
eric7
changeset 9500
5771348ded12
parent 9413
80c06d472826
child 9653
e67609152c5e
--- a/src/eric7/EricNetwork/EricTldExtractor.py	Wed Nov 09 11:32:13 2022 +0100
+++ b/src/eric7/EricNetwork/EricTldExtractor.py	Wed Nov 09 15:05:06 2022 +0100
@@ -15,25 +15,24 @@
 import collections
 import os
 
+from dataclasses import dataclass
+
 from PyQt6.QtCore import QObject, QUrl, qWarning
 
 from eric7.EricWidgets import EricMessageBox
 
 
+@dataclass
 class EricTldHostParts:
     """
     Class implementing the host parts helper.
     """
 
-    def __init__(self):
-        """
-        Constructor
-        """
-        self.host = ""
-        self.tld = ""
-        self.domain = ""
-        self.registrableDomain = ""
-        self.subdomain = ""
+    host: str = ""
+    tld: str = ""
+    domain: str = ""
+    registrableDomain: str = ""
+    subdomain: str = ""
 
 
 class EricTldExtractor(QObject):
@@ -201,14 +200,18 @@
         @return splitted host address
         @rtype EricTldHostParts
         """
-        hostParts = EricTldHostParts()
-        hostParts.host = host
-        hostParts.tld = self.tld(host)
-        hostParts.domain = self.__domainHelper(host, hostParts.tld)
-        hostParts.registrableDomain = self.__registrableDomainHelper(
-            hostParts.domain, hostParts.tld
+        tld = self.tld(host)
+        domain = self.__domainHelper(host, tld)
+        registrableDomain = self.__registrableDomainHelper(domain, tld)
+        subdomain = self.__subdomainHelper(host, registrableDomain)
+
+        hostParts = EricTldHostParts(
+            host=host,
+            tld=tld,
+            domain=domain,
+            registrableDomain=registrableDomain,
+            subdomain=subdomain,
         )
-        hostParts.subdomain = self.__subdomainHelper(host, hostParts.registrableDomain)
 
         return hostParts
 

eric ide

mercurial