diff options
| author | Benjamin Peterson <benjamin@python.org> | 2011-05-30 16:15:05 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2011-05-30 16:15:05 (GMT) |
| commit | c6c5e0461174d60b9d8ef35336e9576dbdc6121c (patch) | |
| tree | 1c03f9845997f30aaafb967ba5ec4ec681d86d18 /Lib/packaging/database.py | |
| parent | 758888d437c4c2d398ec322ff1596e1620f5f0dd (diff) | |
| parent | 1ae2998f3edaac9d0e98a62847b5d541f5f50ce0 (diff) | |
| download | cpython-c6c5e0461174d60b9d8ef35336e9576dbdc6121c.zip cpython-c6c5e0461174d60b9d8ef35336e9576dbdc6121c.tar.gz cpython-c6c5e0461174d60b9d8ef35336e9576dbdc6121c.tar.bz2 | |
merge heads
Diffstat (limited to 'Lib/packaging/database.py')
| -rw-r--r-- | Lib/packaging/database.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/packaging/database.py b/Lib/packaging/database.py index b107148..22d4b13 100644 --- a/Lib/packaging/database.py +++ b/Lib/packaging/database.py @@ -18,7 +18,7 @@ __all__ = [ 'get_distributions', 'get_distribution', 'get_file_users', 'provides_distribution', 'obsoletes_distribution', 'enable_cache', 'disable_cache', 'clear_cache', -] + 'get_file_path', 'get_file'] # TODO update docs @@ -627,3 +627,17 @@ def get_file_users(path): for dist in get_distributions(): if dist.uses(path): yield dist + + +def get_file_path(distribution_name, relative_path): + """Return the path to a resource file.""" + dist = get_distribution(distribution_name) + if dist != None: + return dist.get_resource_path(relative_path) + raise LookupError('no distribution named %r found' % distribution_name) + + +def get_file(distribution_name, relative_path, *args, **kwargs): + """Open and return a resource file.""" + return open(get_file_path(distribution_name, relative_path), + *args, **kwargs) |
