summaryrefslogtreecommitdiff
path: root/src/mailman/utilities/modules.py
diff options
context:
space:
mode:
authorBarry Warsaw2014-11-02 14:55:10 -0500
committerBarry Warsaw2014-11-02 14:55:10 -0500
commitdfc451f81ccc8b0947fb3fa42e94c55026984cf8 (patch)
treec9834271a2dc7fd7d998e5dd211a0ef047f8085e /src/mailman/utilities/modules.py
parent0b1ee6fc8d224291c68c964a1af6b481921a13b3 (diff)
parent1d9f6970b9a26ee576838b53f485b96365e3a6c2 (diff)
downloadmailman-dfc451f81ccc8b0947fb3fa42e94c55026984cf8.tar.gz
mailman-dfc451f81ccc8b0947fb3fa42e94c55026984cf8.tar.zst
mailman-dfc451f81ccc8b0947fb3fa42e94c55026984cf8.zip
Diffstat (limited to 'src/mailman/utilities/modules.py')
-rw-r--r--src/mailman/utilities/modules.py15
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