# eric6.E5Network.E5TldExtractor

Module implementing the TLD Extractor.

### Global Attributes

_TLDExtractor

### Classes

E5TldExtractor | Class implementing the TLD Extractor.
E5TldHostParts | Class implementing the host parts helper.

### Functions

instance | Global function to get a reference to the TLD extractor and create it, if it hasn't been yet.

## E5TldExtractor

Class implementing the TLD Extractor.

Note: The module function instance() should be used to get a reference to a global object to avoid overhead.

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

E5TldExtractor | Constructor
__checkPublicSuffix | Private method to test a host name against a registrable name.
__defaultDataSearchPaths | Private method to get the default search paths for the TLD data file.
__domainHelper | Private method to get the domain name without TLD.
__loadData | Private method to load the TLD data.
__normalizedHost | Private method to get the normalized host for a host address.
__parseData | Private method to parse TLD data.
__registrableDomainHelper | Private method to get the registrable domain (i.e.
__subdomainHelper | Private method to get the subdomain of a host address (i.e.
dataSearchPaths | Public method to get the search paths for the TLD data file.
domain | Public method to get the domain for a host.
getTldDownloadUrl | Public method to get the TLD data file download URL.
isDataLoaded | Public method to check, if the TLD data ia already loaded.
registrableDomain | Public method to get the registrable domain for a host.
setDataSearchPaths | Public method to set the search paths for the TLD data file.
splitParts | Public method to split a host address into its parts.
subdomain | Public method to get the subdomain for a host.
test | Public method to execute the tests.
tld | Public method to get the top level domain for a host.

### Static Methods

None

#### E5TldExtractor (Constructor)

E5TldExtractor(withPrivate=False, parent=None)

Constructor

withPrivate (bool)
  flag indicating to load private TLDs as well
parent (QObject)
  reference to the parent object

#### E5TldExtractor.__checkPublicSuffix

__checkPublicSuffix(host, registrableName)

Private method to test a host name against a registrable name.

host (str)
  host name to test
registrableName (str)
  registrable domain name to test against

Returns:
  flag indicating the check result

Return Type:
  bool

#### E5TldExtractor.__defaultDataSearchPaths

__defaultDataSearchPaths()

Private method to get the default search paths for the TLD data file.

Returns:
  default search paths for the TLD data file

Return Type:
  list of str

#### E5TldExtractor.__domainHelper

__domainHelper(host, tldPart)

Private method to get the domain name without TLD.

host (str)
  host address
tldPart (str)
  TLD part of the host address

Returns:
  domain name

Return Type:
  str

#### E5TldExtractor.__loadData

__loadData()

Private method to load the TLD data.

#### E5TldExtractor.__normalizedHost

__normalizedHost(host)

Private method to get the normalized host for a host address.

host (str)
  host address to be normalized

Returns:
  normalized host address

Return Type:
  str

#### E5TldExtractor.__parseData

__parseData(dataFile, loadPrivateDomains=False)

Private method to parse TLD data.

dataFile (str)
  name of the file containing the TLD data
loadPrivateDomains (bool)
  flag indicating to load private domains

Returns:
  flag indicating success

Return Type:
  bool

#### E5TldExtractor.__registrableDomainHelper

__registrableDomainHelper(domainPart, tldPart)

Private method to get the registrable domain (i.e. domain plus TLD).

domainPart (str)
  domain part of a host address
tldPart (str)
  TLD part of a host address

Returns:
  registrable domain name

Return Type:
  str

#### E5TldExtractor.__subdomainHelper

__subdomainHelper(host, registrablePart)

Private method to get the subdomain of a host address (i.e. domain part without the registrable domain name).

host (str)
  host address
registrablePart (str)
  registrable domain part of the host address

Returns:
  subdomain name

Return Type:
  str

#### E5TldExtractor.dataSearchPaths

dataSearchPaths()

Public method to get the search paths for the TLD data file.

Returns:
  search paths for the TLD data file

Return Type:
  list of str

#### E5TldExtractor.domain

domain(host)

Public method to get the domain for a host.

host (str)
  host name to get the domain for

Returns:
  domain for host

Return Type:
  str

#### E5TldExtractor.getTldDownloadUrl

getTldDownloadUrl()

Public method to get the TLD data file download URL.

Returns:
  download URL

Return Type:
  QUrl

#### E5TldExtractor.isDataLoaded

isDataLoaded()

Public method to check, if the TLD data ia already loaded.

Returns:
  flag indicating data is loaded

Return Type:
  bool

#### E5TldExtractor.registrableDomain

registrableDomain(host)

Public method to get the registrable domain for a host.

host (str)
  host name to get the registrable domain for

Returns:
  registrable domain for host

Return Type:
  str

#### E5TldExtractor.setDataSearchPaths

setDataSearchPaths(searchPaths=None)

Public method to set the search paths for the TLD data file.

searchPaths (list of str)
  search paths for the TLD data file or None, if the default search paths shall be set

#### E5TldExtractor.splitParts

splitParts(host)

Public method to split a host address into its parts.

host (str)
  host address to be split

Returns:
  splitted host address

Return Type:
  E5TldHostParts

#### E5TldExtractor.subdomain

subdomain(host)

Public method to get the subdomain for a host.

host (str)
  host name to get the subdomain for

Returns:
  subdomain for host

Return Type:
  str

#### E5TldExtractor.test

test()

Public method to execute the tests.

Returns:
  flag indicating the test result

Return Type:
  bool

#### E5TldExtractor.tld

tld(host)

Public method to get the top level domain for a host.

host (str)
  host name to get TLD for

Returns:
  TLD for host

Return Type:
  str

Up

## E5TldHostParts

Class implementing the host parts helper.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

E5TldHostParts | Constructor

### Static Methods

None

#### E5TldHostParts (Constructor)

E5TldHostParts()

Constructor

Up

## instance

instance(withPrivate=False)

Global function to get a reference to the TLD extractor and create it, if it hasn't been yet.

withPrivate (bool)
  flag indicating to load private TLDs as well

Returns:
  reference to the zoom manager object

Return Type:
  E5TldExtractor

Up