inspy-logger 3.0.dev4__tar.gz → 3.0.1__tar.gz
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.
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/PKG-INFO +2 -1
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/Scripts/main.py +7 -4
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/__about__.py +1 -12
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/__init__.py +4 -0
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/helpers/network.py +5 -5
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/version.py +7 -4
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/pyproject.toml +5 -1
- inspy_logger-3.0.dev4/inspy_logger/helpers/cache.py +0 -140
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/LICENSE.md +0 -0
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/README.md +0 -0
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/errors/__init__.py +0 -0
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/helpers/__init__.py +0 -0
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/helpers/base_classes.py +0 -0
- {inspy_logger-3.0.dev4 → inspy_logger-3.0.1}/inspy_logger/manifest.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: inspy-logger
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.1
|
|
4
4
|
Summary: Colorable, scalable logger for CLI
|
|
5
5
|
Home-page: https://github.com/Inspyre-Softworks/inSPy-Logger
|
|
6
6
|
License: MIT
|
|
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.9
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
21
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
22
|
Classifier: Programming Language :: Python :: 3.7
|
|
22
23
|
Classifier: Programming Language :: Python :: 3.8
|
|
@@ -48,10 +48,13 @@ def update():
|
|
|
48
48
|
Since:
|
|
49
49
|
v3.0
|
|
50
50
|
"""
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
try:
|
|
52
|
+
if pypi_info.update_available:
|
|
53
|
+
print(f'\n\n[bold green]Update Available![/bold green] New version: [bold cyan]{pypi_info.new_version_available}[/bold cyan]')
|
|
54
|
+
else:
|
|
55
|
+
print(f'\n\n[bold green]No update available.[/bold green] Current version: [bold cyan]{parse_version()}[/bold cyan] {"which is newer than the available version on PyPi.org" if pypi_info.installed_newer_than_latest else ""}')
|
|
56
|
+
except Exception as e:
|
|
57
|
+
print(f'An error occurred during the update check: {str(e)}')
|
|
55
58
|
|
|
56
59
|
|
|
57
60
|
def get_version_info():
|
|
@@ -20,15 +20,4 @@ __authors__ = [
|
|
|
20
20
|
('Taylor-Jayde Blackstone', '<t.blackstone@inspyre.tech')
|
|
21
21
|
]
|
|
22
22
|
|
|
23
|
-
'
|
|
24
|
-
File Change History:
|
|
25
|
-
11/5/22 - 4:21 AM (v2.1.2):
|
|
26
|
-
- Added description to docstring. (target: 2.1.2)
|
|
27
|
-
|
|
28
|
-
11/5/22 - 4:41 AM:
|
|
29
|
-
- Version bump (target: 2.1.3)
|
|
30
|
-
|
|
31
|
-
08/16/2023 - 13:49 (v3.0):
|
|
32
|
-
- Version bump (v2.1.3 -> v3.0-dev.1)
|
|
33
|
-
|
|
34
|
-
'''
|
|
23
|
+
'
|
|
@@ -251,10 +251,12 @@ class Logger:
|
|
|
251
251
|
"""
|
|
252
252
|
self._log(logging.INFO, message, args=(), stacklevel=2)
|
|
253
253
|
|
|
254
|
+
|
|
254
255
|
def warning(self, message):
|
|
255
256
|
"""
|
|
256
257
|
Logs a warning message.
|
|
257
258
|
|
|
259
|
+
|
|
258
260
|
Args:
|
|
259
261
|
message (str): The message to log.
|
|
260
262
|
"""
|
|
@@ -264,6 +266,7 @@ class Logger:
|
|
|
264
266
|
"""
|
|
265
267
|
Logs an error message.
|
|
266
268
|
|
|
269
|
+
|
|
267
270
|
Args:
|
|
268
271
|
message (str): The message to log.
|
|
269
272
|
"""
|
|
@@ -284,6 +287,7 @@ class Logger:
|
|
|
284
287
|
|
|
285
288
|
return f'<Logger: {name} w/ level {self.logger.level} at {hex_id}{parent_part}>'
|
|
286
289
|
|
|
290
|
+
|
|
287
291
|
@classmethod
|
|
288
292
|
def create_logger_for_caller(cls):
|
|
289
293
|
"""
|
|
@@ -27,8 +27,7 @@ from __future__ import annotations
|
|
|
27
27
|
from urllib.parse import quote as url_safe
|
|
28
28
|
|
|
29
29
|
import requests
|
|
30
|
-
|
|
31
|
-
from inspy_logger.helpers.cache import TLDCache
|
|
30
|
+
from public_suffix_list import PublicSuffixList
|
|
32
31
|
|
|
33
32
|
DEFAULT_TEST_HOSTS = [
|
|
34
33
|
['https', 'inspyre', 'tech'],
|
|
@@ -44,10 +43,11 @@ hosts = []
|
|
|
44
43
|
:obj:`list`[:obj:`Host`]:
|
|
45
44
|
A list of host objects that will be used to connect to.
|
|
46
45
|
"""
|
|
46
|
+
psl = PublicSuffixList()
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
URL_SUFFIXES = psl._suffixes
|
|
49
49
|
|
|
50
|
-
VALID_TLDS =
|
|
50
|
+
VALID_TLDS = URL_SUFFIXES
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
class Host():
|
|
@@ -169,7 +169,7 @@ class Host():
|
|
|
169
169
|
def tld(self, new):
|
|
170
170
|
if not isinstance(new, str):
|
|
171
171
|
raise TypeError(f"New value must be a string not {type(new)}")
|
|
172
|
-
if new not in
|
|
172
|
+
if new not in URL_SUFFIXES:
|
|
173
173
|
raise ValueError("TLD must be valid!")
|
|
174
174
|
|
|
175
175
|
self.__tld = new
|
|
@@ -14,9 +14,9 @@ RELEASE_MAP = {
|
|
|
14
14
|
__VERSION__ = {
|
|
15
15
|
'major': 3,
|
|
16
16
|
'minor': 0,
|
|
17
|
-
'patch':
|
|
18
|
-
'release': '
|
|
19
|
-
'release_num':
|
|
17
|
+
'patch': 1,
|
|
18
|
+
'release': 'final',
|
|
19
|
+
'release_num': 0
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
|
|
@@ -50,8 +50,11 @@ def get_full_version_name():
|
|
|
50
50
|
"""
|
|
51
51
|
ver = parse_version()
|
|
52
52
|
ver = ver.split('-')[0]
|
|
53
|
-
return f'v{ver} {RELEASE_MAP[__VERSION__["release"]]} ({__VERSION__["release_num"]})'
|
|
54
53
|
|
|
54
|
+
release_type = RELEASE_MAP[__VERSION__["release"]]
|
|
55
|
+
release_num = __VERSION__["release_num"]
|
|
56
|
+
release_str = f" {release_type} {'' if __VERSION__['release'].lower() == 'final' else f'({release_num})'}"
|
|
57
|
+
return f'v{ver}{release_str}'
|
|
55
58
|
|
|
56
59
|
def get_pypi_info():
|
|
57
60
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "inspy-logger"
|
|
3
|
-
version = "3.0
|
|
3
|
+
version = "3.0.1"
|
|
4
4
|
description = "Colorable, scalable logger for CLI"
|
|
5
5
|
authors = ["Taylor-Jayde Blackstone <tayjaybabee@gmail.com>"]
|
|
6
6
|
homepage = 'https://github.com/Inspyre-Softworks/inSPy-Logger'
|
|
@@ -58,6 +58,10 @@ autoclasstoc = "^1.6.0"
|
|
|
58
58
|
sphinx-autodoc-annotation = "^1.0.post1"
|
|
59
59
|
sphinxcontrib-autoprogram = "^0.1.8"
|
|
60
60
|
|
|
61
|
+
|
|
62
|
+
[tool.poetry.group.dev.dependencies]
|
|
63
|
+
poetry-plugin-export = "^1.6.0"
|
|
64
|
+
|
|
61
65
|
[build-system]
|
|
62
66
|
requires = ["poetry-core>=1.0.0"]
|
|
63
67
|
build-backend = "poetry.core.masonry.api"
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from os import makedirs
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from pickle import dump as pkl_dump
|
|
6
|
-
from pickle import load as pkl_load
|
|
7
|
-
from time import time
|
|
8
|
-
from appdirs import user_cache_dir
|
|
9
|
-
from domain_suffixes.suffixes import Suffixes
|
|
10
|
-
from humanize.time import precisedelta
|
|
11
|
-
|
|
12
|
-
PICKLE_FILEPATH = Path(
|
|
13
|
-
user_cache_dir(
|
|
14
|
-
appname='InspyLogger',
|
|
15
|
-
appauthor='Inspyre-Softworks'
|
|
16
|
-
)
|
|
17
|
-
).joinpath('tld.pkl')
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class TLDCache(object):
|
|
21
|
-
|
|
22
|
-
parent_dir = PICKLE_FILEPATH.parent
|
|
23
|
-
|
|
24
|
-
def __init__(self):
|
|
25
|
-
self.__created_ts = None
|
|
26
|
-
self.__pickle_fp_exists = None
|
|
27
|
-
self.__num_tlds = None
|
|
28
|
-
self.__tlds = None
|
|
29
|
-
self.__data = None
|
|
30
|
-
self.__last_renewal_ts = None
|
|
31
|
-
self.__renewal_hist = None
|
|
32
|
-
|
|
33
|
-
def build(self):
|
|
34
|
-
self.__data = {
|
|
35
|
-
'created_ts': time(),
|
|
36
|
-
'renewal_data': {
|
|
37
|
-
'last_ts': None,
|
|
38
|
-
'history': [],
|
|
39
|
-
},
|
|
40
|
-
'tlds': self.fetch_from_source()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return self.__data
|
|
44
|
-
|
|
45
|
-
@staticmethod
|
|
46
|
-
def load(self):
|
|
47
|
-
""" Load the pickle file for the cache.
|
|
48
|
-
|
|
49
|
-
Will attempt to load the pickle file into memory from the path indicated by :obj:`PICKLE_FILEPATH`
|
|
50
|
-
|
|
51
|
-
Raises:
|
|
52
|
-
:exception:`FileNotFoundError`: If the pickle file does not exist.
|
|
53
|
-
|
|
54
|
-
"""
|
|
55
|
-
with open(PICKLE_FILEPATH, 'rb') as pfp:
|
|
56
|
-
res = pkl_load(pfp)
|
|
57
|
-
|
|
58
|
-
return res
|
|
59
|
-
|
|
60
|
-
def write(self):
|
|
61
|
-
""" Write the pickle file.
|
|
62
|
-
|
|
63
|
-
Write the contents of the cache to the file-system path indicated by :obj:`PICKLE_FILEPATH`
|
|
64
|
-
|
|
65
|
-
Raises:
|
|
66
|
-
:exception:`PermissionError`: If the pickle file can't be written due to permissions writing the file to storage.
|
|
67
|
-
"""
|
|
68
|
-
|
|
69
|
-
if not self.parent_dir.exists():
|
|
70
|
-
makedirs(self.parent_dir, exist_ok=True)
|
|
71
|
-
|
|
72
|
-
with open(PICKLE_FILEPATH, 'wb') as pfp:
|
|
73
|
-
pkl_dump(self.__data, pfp)
|
|
74
|
-
|
|
75
|
-
@staticmethod
|
|
76
|
-
def fetch_from_source(self):
|
|
77
|
-
""" Fetch the top-level-domain list from the source
|
|
78
|
-
|
|
79
|
-
Returns:
|
|
80
|
-
:class:`list`: A list of all known top-level domain suffixes from the domain-suffixes package.
|
|
81
|
-
"""
|
|
82
|
-
suffixes = Suffixes()
|
|
83
|
-
return suffixes.get_all_tlds()
|
|
84
|
-
|
|
85
|
-
@property
|
|
86
|
-
def contents(self) -> dict:
|
|
87
|
-
if self.__data is None:
|
|
88
|
-
try:
|
|
89
|
-
self.__data = self.load()
|
|
90
|
-
except FileNotFoundError:
|
|
91
|
-
self.__data = self.build()
|
|
92
|
-
self.write()
|
|
93
|
-
|
|
94
|
-
return self.__data
|
|
95
|
-
|
|
96
|
-
@property
|
|
97
|
-
def TLDs(self) -> list:
|
|
98
|
-
""" Returns a list of TLDs (top-level domains) for validating against """
|
|
99
|
-
return self.contents['tlds']
|
|
100
|
-
|
|
101
|
-
@property
|
|
102
|
-
def created_timestamp(self) -> float:
|
|
103
|
-
"""
|
|
104
|
-
An alias for :attr:`created_ts`
|
|
105
|
-
|
|
106
|
-
Returns:
|
|
107
|
-
created_ts (float):
|
|
108
|
-
The time (in seconds since Epoch) when the cache was created.
|
|
109
|
-
|
|
110
|
-
"""
|
|
111
|
-
return self.created_ts
|
|
112
|
-
|
|
113
|
-
@property
|
|
114
|
-
def created_ts(self) -> float:
|
|
115
|
-
"""
|
|
116
|
-
The time (in seconds since Epoch) when the cache was created
|
|
117
|
-
"""
|
|
118
|
-
return self.contents['created_ts']
|
|
119
|
-
|
|
120
|
-
@property
|
|
121
|
-
def age_in_seconds(self) -> float:
|
|
122
|
-
"""
|
|
123
|
-
The number of seconds that have elapsed since creation of the cache.
|
|
124
|
-
"""
|
|
125
|
-
return time() - self.created_ts
|
|
126
|
-
|
|
127
|
-
@property
|
|
128
|
-
def age(self) -> str:
|
|
129
|
-
return precisedelta(self.age_in_seconds)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
"""
|
|
133
|
-
File Change History:
|
|
134
|
-
|
|
135
|
-
11/5/22 - 4:24 AM (target: v2.1.2):
|
|
136
|
-
- Code cleanup
|
|
137
|
-
- Transform from class functions to static methods;
|
|
138
|
-
- `TLDCache.load`
|
|
139
|
-
- `TLDCache.fetch_from_source`
|
|
140
|
-
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|