python-utils 4.2.0__py3-none-any.whl → 4.2.1__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.
- python_utils/import_.py +37 -17
- {python_utils-4.2.0.dist-info → python_utils-4.2.1.dist-info}/METADATA +2 -1
- {python_utils-4.2.0.dist-info → python_utils-4.2.1.dist-info}/RECORD +5 -5
- {python_utils-4.2.0.dist-info → python_utils-4.2.1.dist-info}/WHEEL +1 -1
- {python_utils-4.2.0.dist-info → python_utils-4.2.1.dist-info}/licenses/LICENSE +0 -0
python_utils/import_.py
CHANGED
|
@@ -113,24 +113,44 @@ def import_global( # noqa: C901
|
|
|
113
113
|
globals_ = frame.f_globals
|
|
114
114
|
|
|
115
115
|
try:
|
|
116
|
-
# Relative imports are supported (from .spam import eggs)
|
|
116
|
+
# Relative imports are supported (from .spam import eggs). Each
|
|
117
|
+
# leading dot counts as one level, so ``..spam`` goes up two.
|
|
118
|
+
# An empty or dots-only name keeps the one-level path it had in
|
|
119
|
+
# 4.2.0, and with it the IndexError or ModuleNotFoundError.
|
|
120
|
+
multi_dot: bool = False
|
|
117
121
|
if not name_parts[0]:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
remainder: str = name.lstrip('.')
|
|
123
|
+
dots: int = len(name) - len(remainder)
|
|
124
|
+
if dots > 1 and remainder:
|
|
125
|
+
multi_dot = True
|
|
126
|
+
level = dots
|
|
127
|
+
name_parts = remainder.split('.')
|
|
128
|
+
else:
|
|
129
|
+
name_parts = name_parts[1:]
|
|
130
|
+
level = 1
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
module = __import__(
|
|
134
|
+
name=name_parts[0] or '.',
|
|
135
|
+
globals=globals_,
|
|
136
|
+
locals=locals_,
|
|
137
|
+
fromlist=name_parts[1:],
|
|
138
|
+
level=max(level, 0),
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Make sure we get the right part of a dotted import (i.e.
|
|
142
|
+
# spam.eggs should return eggs, not spam)
|
|
143
|
+
for attr in name_parts[1:]:
|
|
144
|
+
module = _get_attribute(module, attr, '.'.join(name_parts))
|
|
145
|
+
except ImportError as error:
|
|
146
|
+
# Every multi-dot name failed with ModuleNotFoundError in
|
|
147
|
+
# 4.2.0. Python raises a plain ImportError for some of them,
|
|
148
|
+
# such as going above the top-level package, which
|
|
149
|
+
# `except ModuleNotFoundError` misses. The subclass is
|
|
150
|
+
# caught by both.
|
|
151
|
+
if not multi_dot or isinstance(error, ModuleNotFoundError):
|
|
152
|
+
raise
|
|
153
|
+
raise ModuleNotFoundError(str(error), name=name) from error
|
|
134
154
|
|
|
135
155
|
# If no list of modules is given, autodetect from either __all__
|
|
136
156
|
# or a dir() of the module
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-utils
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.1
|
|
4
4
|
Summary: Python Utils is a module with some convenient utilities not included with the standard Python install
|
|
5
5
|
Keywords: utils,utilities,helpers,typing,typed,async,lazy-imports
|
|
6
6
|
Author: Rick van Hattem
|
|
@@ -37,6 +37,7 @@ Project-URL: Documentation, https://python-utils.readthedocs.io/
|
|
|
37
37
|
Project-URL: Repository, https://github.com/WoLpH/python-utils
|
|
38
38
|
Project-URL: Changelog, https://github.com/WoLpH/python-utils/releases
|
|
39
39
|
Project-URL: Funding, https://github.com/sponsors/wolph
|
|
40
|
+
Project-URL: Issues, https://github.com/wolph/python-utils/issues
|
|
40
41
|
Provides-Extra: docs
|
|
41
42
|
Provides-Extra: loguru
|
|
42
43
|
Provides-Extra: tests
|
|
@@ -8,14 +8,14 @@ python_utils/decorators.py,sha256=UyVuV7Phf8kjAt38uA-F9MFH2o8zM4t-fmlgt3KL5cc,82
|
|
|
8
8
|
python_utils/exceptions.py,sha256=B5wljs3Id6eQ9eRaur-ZMPGGmhHNwh9F08Sfw6fuLX4,1230
|
|
9
9
|
python_utils/formatters.py,sha256=rvbeP7H3h8Hll573PZkWsJPuHETjEHpWleb0tFck8MM,7031
|
|
10
10
|
python_utils/generators.py,sha256=dw-x72fitGgdeqLS4_xyspS81ayqExvT77THHoZBA5I,8307
|
|
11
|
-
python_utils/import_.py,sha256=
|
|
11
|
+
python_utils/import_.py,sha256=pR7CwgAa2-vyMV3WWdfVx-n3IsEWzbbFWQ7TPZA4xc0,7434
|
|
12
12
|
python_utils/logger.py,sha256=-QuF7Zfo7pxc4nTmAPc9Pm-oz5wsxXIX7NeCnYEPI6I,14043
|
|
13
13
|
python_utils/loguru.py,sha256=qsap-aXByGXsd4KrYmtneTSUARVIdeVu9xgmrFPtqSI,2696
|
|
14
14
|
python_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
python_utils/terminal.py,sha256=GL3n2_rT98LBNmxy-amY-hezGKStCo-9_d_pR-TMgv8,6823
|
|
16
16
|
python_utils/time.py,sha256=fZz00bpTeLXFFhbAo03LiMLWuzSJU4iPbyGSe7PYshU,16979
|
|
17
17
|
python_utils/types.py,sha256=VQLrKDRerOuhYxMhCaWWbUBnDXJhFx_G20gIfyolgug,4682
|
|
18
|
-
python_utils-4.2.
|
|
19
|
-
python_utils-4.2.
|
|
20
|
-
python_utils-4.2.
|
|
21
|
-
python_utils-4.2.
|
|
18
|
+
python_utils-4.2.1.dist-info/licenses/LICENSE,sha256=_Zrs9NZu-G6_aZT2g3Jv5_JREJQfhRNBC61EH6WDH-o,1501
|
|
19
|
+
python_utils-4.2.1.dist-info/WHEEL,sha256=3OmCxFA0ffBIsX4x0o8CdfSvZAOvO3mzEG8U_z5TvV4,80
|
|
20
|
+
python_utils-4.2.1.dist-info/METADATA,sha256=pX5DW8A_mect5mjxcpNTkdETgjxcnEnhtoclf8Y825o,16105
|
|
21
|
+
python_utils-4.2.1.dist-info/RECORD,,
|
|
File without changes
|