From 02f81e110a95955edd0ea5939176c73bc39c4238 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 26 Jun 2015 12:29:34 +0300 Subject: [PATCH] pkgutil: Add get_data(), depends on pkg_resources.resource_stream(). --- pkgutil/pkgutil.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgutil/pkgutil.py b/pkgutil/pkgutil.py index e69de29b..79354779 100644 --- a/pkgutil/pkgutil.py +++ b/pkgutil/pkgutil.py @@ -0,0 +1,8 @@ +import pkg_resources + +def get_data(package, resource): + f = pkg_resources.resource_stream(package, resource) + try: + return f.read() + finally: + f.close()