diff options
| author | Abhilash Raj | 2014-10-02 20:16:00 +0530 |
|---|---|---|
| committer | Abhilash Raj | 2014-10-02 20:16:00 +0530 |
| commit | 6d4af22c8ee51e1b097ec0370cadd3f5a6b95c08 (patch) | |
| tree | 2f5a8b9723f670bdc4179f7dbdbb0322ab966fd9 /src/mailman/utilities/modules.py | |
| parent | 556631243a206f1680d6737227c34e2d66d85748 (diff) | |
| parent | 5166ae93e5c51285661f4ac251c0d4b9390fe785 (diff) | |
| download | mailman-6d4af22c8ee51e1b097ec0370cadd3f5a6b95c08.tar.gz mailman-6d4af22c8ee51e1b097ec0370cadd3f5a6b95c08.tar.zst mailman-6d4af22c8ee51e1b097ec0370cadd3f5a6b95c08.zip | |
Diffstat (limited to 'src/mailman/utilities/modules.py')
| -rw-r--r-- | src/mailman/utilities/modules.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mailman/utilities/modules.py b/src/mailman/utilities/modules.py index 5dfec95db..9ff0e50cd 100644 --- a/src/mailman/utilities/modules.py +++ b/src/mailman/utilities/modules.py @@ -22,6 +22,7 @@ from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'call_name', + 'expand_path', 'find_components', 'find_name', 'scan_module', @@ -31,7 +32,7 @@ __all__ = [ import os import sys -from pkg_resources import resource_listdir +from pkg_resources import resource_filename, resource_listdir @@ -110,3 +111,15 @@ def find_components(package, interface): continue for component in scan_module(module, interface): yield component + + + +def expand_path(url): + """Expand a python: path, returning the absolute file system path.""" + # Is the context coming from a file system or Python path? + if url.startswith('python:'): + resource_path = url[7:] + package, dot, resource = resource_path.rpartition('.') + return resource_filename(package, resource + '.cfg') + else: + return url |
