Skip to content

Commit 3e40285

Browse files
committed
-
1 parent 6e5c4de commit 3e40285

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

python_toolbox/address_tools/object_to_string.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ def shorten_address(address, root=None, namespace={}):
255255
'''
256256
Shorten an address by dropping redundant intermediate nodes.
257257
258-
For example, 'garlicsim.synchronous_crunching.simulate' could be shortened
259-
to 'garlicsim.simulate', because the `simulate` function is available at
260-
this shorter address as well. blocktododoc
258+
For example, 'python_toolbox.caching.cached_property.CachedProperty' could
259+
be shortened to 'python_toolbox.caching.CachedProperty', because the
260+
`CachedProperty` class is available at this shorter address as well.
261261
262262
Note: `root` and `namespace` are only provided in order to access the
263263
object. This function doesn't do root- or namespace-shortening.

python_toolbox/import_tools.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,17 @@ def import_by_path(path, name=None, keep_in_sys_modules=True):
190190

191191
def find_module(module_name, path=None, look_in_zip=True, legacy_output=False):
192192
'''
193-
blocktododoc
193+
Search for a module by name and return its filename.
194194
195-
Gives funky output when `legacy_output=True and look_in_zip=True`.
195+
When `path=None`, search for a built-in, frozen or special module and
196+
continue search in `sys.path`.
197+
198+
When `legacy_output=True`, instead of returning the module's filename,
199+
returns a tuple `(file, filename, (suffix, mode, type))`.
200+
201+
When `look_in_zip=True`, also looks in zipmodules.
202+
203+
todo: Gives funky output when `legacy_output=True and look_in_zip=True`.
196204
'''
197205
# todo: test
198206
if look_in_zip:
@@ -213,7 +221,7 @@ def find_module(module_name, path=None, look_in_zip=True, legacy_output=False):
213221

214222
if legacy_output:
215223
return result
216-
else: # not legacy_output
224+
else: # legacy_output is False
217225
file_, path_, description_ = result
218226
if file_ is not None:
219227
file_.close()
@@ -222,9 +230,9 @@ def find_module(module_name, path=None, look_in_zip=True, legacy_output=False):
222230

223231
def _find_module_in_some_zip_path(module_name, path=None):
224232
'''
225-
Return whether a module by the name `module_name` exists in a zip archive.
226-
blocktododoc
227-
Used internally by `exists`.
233+
If a module called `module_name` exists in a zip archive, get its path.
234+
235+
If the module is not found, raises `ImportError`.
228236
'''
229237
original_path_argument = path
230238

@@ -276,4 +284,10 @@ def _find_module_in_some_zip_path(module_name, path=None):
276284

277285

278286
def _module_address_to_partial_path(module_address):
287+
'''
288+
Convert a dot-seperated address to a path-seperated address.
289+
290+
For example, on Linux, `'python_toolbox.caching.cached_property'` would be
291+
converted to `'python_toolbox/caching/cached_property'`.
292+
'''
279293
return os.path.sep.join(module_address.split('.'))

0 commit comments

Comments
 (0)