From 4eca48d72418c6ef495aefe0a9be983193666778 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 26 Jun 2015 02:17:32 +0300 Subject: [PATCH] pkg_resources: Implement resource_stream(). This module is not part of CPython stdlib, but rather of setuptools. But so happens that it's functionality either lies on critical path, or should be duplicated, in pkgutil module. --- pkg_resources/pkg_resources.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pkg_resources/pkg_resources.py diff --git a/pkg_resources/pkg_resources.py b/pkg_resources/pkg_resources.py new file mode 100644 index 00000000..b7488f04 --- /dev/null +++ b/pkg_resources/pkg_resources.py @@ -0,0 +1,9 @@ +import os +import os.path + +def resource_stream(package, resource): + p = __import__(package) + d = os.path.dirname(p.__file__) + if d[0] != "/": + d = os.getcwd() + "/" + d + return open(d + "/" + resource, "rb")