File: //opt/alt/python37/lib/python3.7/site-packages/tldextract/__pycache__/tldextract.cpython-37.pyc
B
��f`G � @ s& d Z ddlmZ ddlZddlZddlZddlmZm Z ddl
mZ ddlm
Z
ddlZddlmZmZ dd lmZmZmZ dd
lmZ e�d�Zej�d�Zd
ZG dd� de
�ZG dd� d�Ze� Z G dd� d�Z!ee j"�d!dddd�dd��Z#ee j$�dd� �Z$G dd� d�Z%ddd�dd �Z&dS )"aW `tldextract` accurately separates a URL's subdomain, domain, and public suffix.
It does this via the Public Suffix List (PSL).
>>> import tldextract
>>> tldextract.extract('http://forums.news.cnn.com/')
ExtractResult(subdomain='forums.news', domain='cnn', suffix='com', is_private=False)
>>> tldextract.extract('http://forums.bbc.co.uk/') # United Kingdom
ExtractResult(subdomain='forums', domain='bbc', suffix='co.uk', is_private=False)
>>> tldextract.extract('http://www.worldbank.org.kg/') # Kyrgyzstan
ExtractResult(subdomain='www', domain='worldbank', suffix='org.kg', is_private=False)
`ExtractResult` is a namedtuple, so it's simple to access the parts you want.
>>> ext = tldextract.extract('http://forums.bbc.co.uk')
>>> (ext.subdomain, ext.domain, ext.suffix)
('forums', 'bbc', 'co.uk')
>>> # rejoin subdomain and domain
>>> '.'.join(ext[:2])
'forums.bbc'
>>> # a common alias
>>> ext.registered_domain
'bbc.co.uk'
Note subdomain and suffix are _optional_. Not all URL-like inputs have a
subdomain or a valid suffix.
>>> tldextract.extract('google.com')
ExtractResult(subdomain='', domain='google', suffix='com', is_private=False)
>>> tldextract.extract('google.notavalidsuffix')
ExtractResult(subdomain='google', domain='notavalidsuffix', suffix='', is_private=False)
>>> tldextract.extract('http://127.0.0.1:8080/deployed/')
ExtractResult(subdomain='', domain='127.0.0.1', suffix='', is_private=False)
If you want to rejoin the whole namedtuple, regardless of whether a subdomain
or suffix were found:
>>> ext = tldextract.extract('http://127.0.0.1:8080/deployed/')
>>> # this has unwanted dots
>>> '.'.join(part for part in ext[:3])
'.127.0.0.1.'
>>> # join part only if truthy
>>> '.'.join(part for part in ext[:3] if part)
'127.0.0.1'
� )�annotationsN)�
Collection�Sequence)�wraps)�
NamedTuple� )� DiskCache�
get_cache_dir)�lenient_netloc�
looks_like_ip�looks_like_ipv6)�get_suffix_listsZ
tldextractZTLDEXTRACT_CACHE_TIMEOUT)z4https://publicsuffix.org/list/public_suffix_list.datzQhttps://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.datc @ s~ e Zd ZU dZded<