liburlparser 1.4.6__cp312-cp312-win32.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.
- liburlparser/__init__.py +7 -0
- liburlparser/__main__.py +33 -0
- liburlparser/_core.pyd +0 -0
- liburlparser/core.py +43 -0
- liburlparser/public_suffix_list.dat +15491 -0
- liburlparser-1.4.6.dist-info/METADATA +316 -0
- liburlparser-1.4.6.dist-info/RECORD +10 -0
- liburlparser-1.4.6.dist-info/WHEEL +5 -0
- liburlparser-1.4.6.dist-info/entry_points.txt +0 -0
- liburlparser-1.4.6.dist-info/licenses/LICENSE +36 -0
liburlparser/__init__.py
ADDED
liburlparser/__main__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/bin/python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from . import Host, Url, __doc__, __version__
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def show_if_not_none(_str, _class):
|
|
11
|
+
if _str is not None:
|
|
12
|
+
print(_class(_str).to_json())
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main(args):
|
|
16
|
+
show_if_not_none(args.url, Url)
|
|
17
|
+
show_if_not_none(args.host, Host)
|
|
18
|
+
if args.version:
|
|
19
|
+
print(__version__)
|
|
20
|
+
if args.doc:
|
|
21
|
+
print(__doc__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == '__main__':
|
|
25
|
+
parser = argparse.ArgumentParser()
|
|
26
|
+
parser.add_argument("--url", type=str, default=None,
|
|
27
|
+
help="enter entire url (for example: \"https://google.com/about\")")
|
|
28
|
+
parser.add_argument("--host", type=str, default=None,
|
|
29
|
+
help="enter just host part of url (for example: \"google.com\")")
|
|
30
|
+
parser.add_argument('-v', '--version', action='store_true', help="showing version of module")
|
|
31
|
+
parser.add_argument('--doc', action='store_true', help="showing version of module")
|
|
32
|
+
args = parser.parse_args(args=None if sys.argv[1:] else ['--help'])
|
|
33
|
+
main(args)
|
liburlparser/_core.pyd
ADDED
|
Binary file
|
liburlparser/core.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/bin/python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import warnings
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from filelock import FileLock
|
|
8
|
+
|
|
9
|
+
from ._core import Host, Psl, Url, __doc__, __version__
|
|
10
|
+
|
|
11
|
+
psl = Psl() # psl
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def warning_on_one_line(message, category, filename, lineno, file=None, line=None):
|
|
15
|
+
return f'{filename}:{lineno}: {category.__name__}: {message}\n'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
warnings.formatwarning = warning_on_one_line
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
import requests
|
|
22
|
+
|
|
23
|
+
def psl_update():
|
|
24
|
+
resp = requests.get(psl.url)
|
|
25
|
+
psl.load_from_string(resp.text)
|
|
26
|
+
|
|
27
|
+
psl.update = psl_update
|
|
28
|
+
|
|
29
|
+
except ImportError:
|
|
30
|
+
def psl_update():
|
|
31
|
+
raise NotImplementedError
|
|
32
|
+
|
|
33
|
+
psl.update = psl_update
|
|
34
|
+
|
|
35
|
+
if not psl.is_loaded():
|
|
36
|
+
psl_filename = Path(__file__).parent / psl.filename
|
|
37
|
+
if psl_filename.exists():
|
|
38
|
+
with FileLock(psl_filename.with_suffix(".lock")):
|
|
39
|
+
psl.load_from_path(psl_filename.as_posix())
|
|
40
|
+
else:
|
|
41
|
+
warnings.warn(
|
|
42
|
+
f"Cannot find {psl_filename}. you must import it with \"psl.load_from_path\" or \"psl.load_from_string\" or \"psl.update\" functions",
|
|
43
|
+
RuntimeWarning, stacklevel=2)
|