summaryrefslogtreecommitdiff
path: root/src/mailman/utilities/modules.py
diff options
context:
space:
mode:
authorBarry Warsaw2014-09-27 18:16:22 -0400
committerBarry Warsaw2014-09-27 18:16:22 -0400
commitb3500aefb15c63ccf60ab4508868f770ffd2d309 (patch)
tree049e083e3ce28e7e504c1945f0dd8e2cf09dd40b /src/mailman/utilities/modules.py
parenteef73255db608785a55c055cbbfb800603671ff6 (diff)
parent03647b16eb75cc841bb15c3c48ac5f18f77118b8 (diff)
downloadmailman-b3500aefb15c63ccf60ab4508868f770ffd2d309.tar.gz
mailman-b3500aefb15c63ccf60ab4508868f770ffd2d309.tar.zst
mailman-b3500aefb15c63ccf60ab4508868f770ffd2d309.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