Anonymous avatar Anonymous committed 052feee

setuptools/pkg_resources support for pkgdata

Comments (0)

Files changed (1)

 import os
 from cStringIO import StringIO
+    from pkg_resources import resource_stream, resource_exists
+except ImportError:
+    def resource_exists(package_or_requirement, resource_name):
+        return False
+    def resource_stream(package_of_requirement, resource_name):
+        raise NotImplementedError
 def getResource(identifier, pkgname=__name__):
     Acquire a readable object for a given package name and identifier.
     rather than use it as a file-like object.  For example, you may
     be handing data off to a C API.
+    if resource_exists(pkgname, identifier):
+        return resource_stream(pkgname, identifier)
     mod = sys.modules[pkgname]
     fn = getattr(mod, '__file__', None)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.