tldextract 5.1.0__py3-none-any.whl → 5.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tldextract/__main__.py CHANGED
@@ -1,6 +1,5 @@
1
1
  """tldextract __main__."""
2
2
 
3
-
4
3
  from .cli import main
5
4
 
6
5
  if __name__ == "__main__":
tldextract/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '5.1.0'
16
- __version_tuple__ = version_tuple = (5, 1, 0)
15
+ __version__ = version = '5.1.2'
16
+ __version_tuple__ = version_tuple = (5, 1, 2)
tldextract/cache.py CHANGED
@@ -1,4 +1,5 @@
1
1
  """Helpers."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import errno
@@ -6,9 +7,9 @@ import hashlib
6
7
  import json
7
8
  import logging
8
9
  import os
9
- import os.path
10
10
  import sys
11
11
  from collections.abc import Callable, Hashable, Iterable
12
+ from pathlib import Path
12
13
  from typing import (
13
14
  TypeVar,
14
15
  cast,
@@ -37,8 +38,7 @@ else:
37
38
 
38
39
 
39
40
  def get_pkg_unique_identifier() -> str:
40
- """
41
- Generate an identifier unique to the python version, tldextract version, and python instance.
41
+ """Generate an identifier unique to the python version, tldextract version, and python instance.
42
42
 
43
43
  This will prevent interference between virtualenvs and issues that might arise when installing
44
44
  a new version of tldextract
@@ -65,8 +65,7 @@ def get_pkg_unique_identifier() -> str:
65
65
 
66
66
 
67
67
  def get_cache_dir() -> str:
68
- """
69
- Get a cache dir that we have permission to write to.
68
+ """Get a cache dir that we have permission to write to.
70
69
 
71
70
  Try to follow the XDG standard, but if that doesn't work fallback to the package directory
72
71
  http://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -79,15 +78,15 @@ def get_cache_dir() -> str:
79
78
  if xdg_cache_home is None:
80
79
  user_home = os.getenv("HOME", None)
81
80
  if user_home:
82
- xdg_cache_home = os.path.join(user_home, ".cache")
81
+ xdg_cache_home = str(Path(user_home, ".cache"))
83
82
 
84
83
  if xdg_cache_home is not None:
85
- return os.path.join(
86
- xdg_cache_home, "python-tldextract", get_pkg_unique_identifier()
84
+ return str(
85
+ Path(xdg_cache_home, "python-tldextract", get_pkg_unique_identifier())
87
86
  )
88
87
 
89
88
  # fallback to trying to use package directory itself
90
- return os.path.join(os.path.dirname(__file__), ".suffix_cache/")
89
+ return str(Path(os.path.dirname(__file__), ".suffix_cache"))
91
90
 
92
91
 
93
92
  class DiskCache:
@@ -153,7 +152,7 @@ class DiskCache:
153
152
  self.file_ext + ".lock"
154
153
  ):
155
154
  try:
156
- os.unlink(os.path.join(root, filename))
155
+ os.unlink(str(Path(root, filename)))
157
156
  except FileNotFoundError:
158
157
  pass
159
158
  except OSError as exc:
@@ -165,10 +164,10 @@ class DiskCache:
165
164
  def _key_to_cachefile_path(
166
165
  self, namespace: str, key: str | dict[str, Hashable]
167
166
  ) -> str:
168
- namespace_path = os.path.join(self.cache_dir, namespace)
167
+ namespace_path = str(Path(self.cache_dir, namespace))
169
168
  hashed_key = _make_cache_key(key)
170
169
 
171
- cache_path = os.path.join(namespace_path, hashed_key + self.file_ext)
170
+ cache_path = str(Path(namespace_path, hashed_key + self.file_ext))
172
171
 
173
172
  return cache_path
174
173
 
tldextract/remote.py CHANGED
@@ -3,19 +3,13 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import re
6
- from collections.abc import Callable
7
6
  from ipaddress import AddressValueError, IPv6Address
8
7
  from urllib.parse import scheme_chars
9
8
 
10
- inet_pton: Callable[[int, str], bytes] | None
11
- try:
12
- from socket import AF_INET, AF_INET6, inet_pton # Availability: Unix, Windows.
13
- except ImportError:
14
- inet_pton = None
15
-
16
9
  IP_RE = re.compile(
17
- r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)"
18
- r"{3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
10
+ r"^(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)"
11
+ r"{3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$",
12
+ re.ASCII,
19
13
  )
20
14
 
21
15
  scheme_chars_set = set(scheme_chars)
@@ -59,32 +53,16 @@ def _schemeless_url(url: str) -> str:
59
53
  return url[double_slashes_start + 2 :]
60
54
 
61
55
 
62
- def looks_like_ip(
63
- maybe_ip: str, pton: Callable[[int, str], bytes] | None = inet_pton
64
- ) -> bool:
65
- """Check whether the given str looks like an IP address."""
56
+ def looks_like_ip(maybe_ip: str) -> bool:
57
+ """Check whether the given str looks like an IPv4 address."""
66
58
  if not maybe_ip[0].isdigit():
67
59
  return False
68
60
 
69
- if pton is not None:
70
- try:
71
- pton(AF_INET, maybe_ip)
72
- return True
73
- except OSError:
74
- return False
75
61
  return IP_RE.fullmatch(maybe_ip) is not None
76
62
 
77
63
 
78
- def looks_like_ipv6(
79
- maybe_ip: str, pton: Callable[[int, str], bytes] | None = inet_pton
80
- ) -> bool:
64
+ def looks_like_ipv6(maybe_ip: str) -> bool:
81
65
  """Check whether the given str looks like an IPv6 address."""
82
- if pton is not None:
83
- try:
84
- pton(AF_INET6, maybe_ip)
85
- return True
86
- except OSError:
87
- return False
88
66
  try:
89
67
  IPv6Address(maybe_ip)
90
68
  except AddressValueError:
tldextract/tldextract.py CHANGED
@@ -75,8 +75,7 @@ class ExtractResult:
75
75
 
76
76
  @property
77
77
  def registered_domain(self) -> str:
78
- """
79
- Joins the domain and suffix fields with a dot, if they're both set.
78
+ """Joins the domain and suffix fields with a dot, if they're both set.
80
79
 
81
80
  >>> extract('http://forums.bbc.co.uk').registered_domain
82
81
  'bbc.co.uk'
@@ -89,8 +88,7 @@ class ExtractResult:
89
88
 
90
89
  @property
91
90
  def fqdn(self) -> str:
92
- """
93
- Returns a Fully Qualified Domain Name, if there is a proper domain/suffix.
91
+ """Returns a Fully Qualified Domain Name, if there is a proper domain/suffix.
94
92
 
95
93
  >>> extract('http://forums.bbc.co.uk/path/to/file').fqdn
96
94
  'forums.bbc.co.uk'
@@ -103,8 +101,7 @@ class ExtractResult:
103
101
 
104
102
  @property
105
103
  def ipv4(self) -> str:
106
- """
107
- Returns the ipv4 if that is what the presented domain/url is.
104
+ """Returns the ipv4 if that is what the presented domain/url is.
108
105
 
109
106
  >>> extract('http://127.0.0.1/path/to/file').ipv4
110
107
  '127.0.0.1'
@@ -123,8 +120,7 @@ class ExtractResult:
123
120
 
124
121
  @property
125
122
  def ipv6(self) -> str:
126
- """
127
- Returns the ipv6 if that is what the presented domain/url is.
123
+ """Returns the ipv6 if that is what the presented domain/url is.
128
124
 
129
125
  >>> extract('http://[aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1]/path/to/file').ipv6
130
126
  'aBcD:ef01:2345:6789:aBcD:ef01:127.0.0.1'
@@ -334,8 +330,7 @@ class TLDExtract:
334
330
 
335
331
  @property
336
332
  def tlds(self, session: requests.Session | None = None) -> list[str]:
337
- """
338
- Returns the list of tld's used by default.
333
+ """Returns the list of tld's used by default.
339
334
 
340
335
  This will vary based on `include_psl_private_domains` and `extra_suffixes`
341
336
  """
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2020, John Kurkowski
3
+ Copyright (c) 2013-2024, John Kurkowski
4
4
  All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tldextract
3
- Version: 5.1.0
3
+ Version: 5.1.2
4
4
  Summary: Accurately separates a URL's subdomain, domain, and public suffix, using the Public Suffix List (PSL). By default, this includes the public ICANN TLDs and their exceptions. You can optionally support the Public Suffix List's private domains as well.
5
5
  Author-email: John Kurkowski <john.kurkowski@gmail.com>
6
6
  License: BSD-3-Clause
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.8
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
17
18
  Requires-Python: >=3.8
18
19
  Description-Content-Type: text/markdown
19
20
  License-File: LICENSE
@@ -21,6 +22,9 @@ Requires-Dist: idna
21
22
  Requires-Dist: requests >=2.1.0
22
23
  Requires-Dist: requests-file >=1.4
23
24
  Requires-Dist: filelock >=3.0.8
25
+ Provides-Extra: release
26
+ Requires-Dist: build ; extra == 'release'
27
+ Requires-Dist: twine ; extra == 'release'
24
28
  Provides-Extra: testing
25
29
  Requires-Dist: black ; extra == 'testing'
26
30
  Requires-Dist: mypy ; extra == 'testing'
@@ -29,11 +33,12 @@ Requires-Dist: pytest-gitignore ; extra == 'testing'
29
33
  Requires-Dist: pytest-mock ; extra == 'testing'
30
34
  Requires-Dist: responses ; extra == 'testing'
31
35
  Requires-Dist: ruff ; extra == 'testing'
36
+ Requires-Dist: syrupy ; extra == 'testing'
32
37
  Requires-Dist: tox ; extra == 'testing'
33
38
  Requires-Dist: types-filelock ; extra == 'testing'
34
39
  Requires-Dist: types-requests ; extra == 'testing'
35
40
 
36
- # tldextract [![PyPI version](https://badge.fury.io/py/tldextract.svg)](https://badge.fury.io/py/tldextract) [![Build Status](https://travis-ci.com/john-kurkowski/tldextract.svg?branch=master)](https://app.travis-ci.com/github/john-kurkowski/tldextract)
41
+ # tldextract [![PyPI version](https://badge.fury.io/py/tldextract.svg)](https://badge.fury.io/py/tldextract) [![Build Status](https://github.com/john-kurkowski/tldextract/actions/workflows/ci.yml/badge.svg)](https://github.com/john-kurkowski/tldextract/actions/workflows/ci.yml)
37
42
 
38
43
  `tldextract` accurately separates a URL's subdomain, domain, and public suffix,
39
44
  using [the Public Suffix List (PSL)](https://publicsuffix.org).
@@ -0,0 +1,16 @@
1
+ tldextract/.tld_set_snapshot,sha256=TVya0bCcmRKl_16oPKPIlNmWS09rXrjOKGgYjhvAGLE,238022
2
+ tldextract/__init__.py,sha256=rZg3DKzS9CTARuF4Tuq50ViILwUktDED89Av8nStNuM,216
3
+ tldextract/__main__.py,sha256=oiZ5EW_lxRLH6Khk6MdzXf7a1Ld5-A3k4wOFRmNNk2o,89
4
+ tldextract/_version.py,sha256=iJQJoAO8HGnLsPBpH1rkF4KPbrYxIqs4qAXfUgzhRqQ,411
5
+ tldextract/cache.py,sha256=vsr4ERgNxmBO_mYwXLCMbRRKq1s-IDZZLXoaGIYXmBM,8601
6
+ tldextract/cli.py,sha256=nCzBAFrgAopTK1t5eBRQgeveSgWheUx4LAlAHE_8mzQ,3010
7
+ tldextract/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ tldextract/remote.py,sha256=sklRFbATwPs_S33-KeIu9ixuSWP5w7QXO8jnhi_lgJs,1944
9
+ tldextract/suffix_list.py,sha256=TcUpMTZwsicZn6_eHKqA4bjurQrKYde14P-4HT4s4yE,3896
10
+ tldextract/tldextract.py,sha256=oUYLJcgWmeika0teDq2nNI5UCSbAR0c3eosYslVJPUY,18731
11
+ tldextract-5.1.2.dist-info/LICENSE,sha256=dKIruBYZ9wJFoTWv8hvg2bhDv9TXDQ82u-0EERuGJYg,1527
12
+ tldextract-5.1.2.dist-info/METADATA,sha256=dkiY2wl_8M2guJ0MGhGi0YQ9OgZI4vGpJ0I9LMLSGyQ,11464
13
+ tldextract-5.1.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
14
+ tldextract-5.1.2.dist-info/entry_points.txt,sha256=EStkXC80BetCMp1UDhU3kWuXBo3qDpgKltZTJ1x4x1U,51
15
+ tldextract-5.1.2.dist-info/top_level.txt,sha256=DWZIjV49WP30tyC1KOEP7t-EaS4IRCXQzc0KXAOn_bk,11
16
+ tldextract-5.1.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,16 +0,0 @@
1
- tldextract/.tld_set_snapshot,sha256=TVya0bCcmRKl_16oPKPIlNmWS09rXrjOKGgYjhvAGLE,238022
2
- tldextract/__init__.py,sha256=rZg3DKzS9CTARuF4Tuq50ViILwUktDED89Av8nStNuM,216
3
- tldextract/__main__.py,sha256=FxfCNOozXSaJP2GTjgWLAn03oNMd_EUUOWkfT1_YRgM,90
4
- tldextract/_version.py,sha256=JM_f1kYygbvsxl3WSjr9uwddNNdtkWyW4r-uwJZMXyI,411
5
- tldextract/cache.py,sha256=o15NbGa5Cljv2VBBGPCQln-cqnyBeHeH7c_6P3RYzcw,8619
6
- tldextract/cli.py,sha256=nCzBAFrgAopTK1t5eBRQgeveSgWheUx4LAlAHE_8mzQ,3010
7
- tldextract/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- tldextract/remote.py,sha256=dpLz-s-1AP4Ai4XPVQe-uT2Nmev8CZEMKURdqGw5XiA,2550
9
- tldextract/suffix_list.py,sha256=TcUpMTZwsicZn6_eHKqA4bjurQrKYde14P-4HT4s4yE,3896
10
- tldextract/tldextract.py,sha256=HRf7efVbEz3_k5dDypjpqNtUXCMb7ZWotZ1pccR5dBo,18776
11
- tldextract-5.1.0.dist-info/LICENSE,sha256=oqlDTqZaKpeJ6jYsQYqTkmV8gGGg-o7cO_OnH79KjsE,1522
12
- tldextract-5.1.0.dist-info/METADATA,sha256=UwAWHVEdLOqFeglhYbTrJ3F0qteJY0OgVraqzYLZrbY,11237
13
- tldextract-5.1.0.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
14
- tldextract-5.1.0.dist-info/entry_points.txt,sha256=EStkXC80BetCMp1UDhU3kWuXBo3qDpgKltZTJ1x4x1U,51
15
- tldextract-5.1.0.dist-info/top_level.txt,sha256=DWZIjV49WP30tyC1KOEP7t-EaS4IRCXQzc0KXAOn_bk,11
16
- tldextract-5.1.0.dist-info/RECORD,,