[Jython-checkins] jython: ClasspathPyImporter implements get_data(); addresses #2058.

jeff.allen jython-checkins at python.org
Sun May 17 10:11:29 CEST 2015


https://hg.python.org/jython/rev/67f36ecd9103
changeset:   7710:67f36ecd9103
user:        Raphael Jolly <rjolly at users.sourceforge.net>
date:        Thu Sep 26 11:21:58 2013 +0200
summary:
  ClasspathPyImporter implements get_data(); addresses #2058.

files:
  src/org/python/core/ClasspathPyImporter.java |  13 ++++++++++
  src/org/python/core/util/importer.java       |   2 +
  2 files changed, 15 insertions(+), 0 deletions(-)


diff --git a/src/org/python/core/ClasspathPyImporter.java b/src/org/python/core/ClasspathPyImporter.java
--- a/src/org/python/core/ClasspathPyImporter.java
+++ b/src/org/python/core/ClasspathPyImporter.java
@@ -5,6 +5,8 @@
 import java.io.InputStream;
 import java.util.Map;
 
+import org.python.core.util.FileUtil;
+import org.python.core.util.StringUtil;
 import org.python.core.util.importer;
 import org.python.expose.ExposedMethod;
 import org.python.expose.ExposedNew;
@@ -40,6 +42,17 @@
         this.path = path;
     }
 
+    public String get_data(String path) {
+        InputStream is = entries.get(makeEntry(path.replace("__pyclasspath__/", "")));
+        byte[] data;
+        try {
+            data = FileUtil.readBytes(is);
+        } catch (IOException ioe) {
+            throw Py.IOError(ioe);
+        }
+        return StringUtil.fromBytes(data);
+    }
+
     /**
      * Find the module for the fully qualified name.
      *
diff --git a/src/org/python/core/util/importer.java b/src/org/python/core/util/importer.java
--- a/src/org/python/core/util/importer.java
+++ b/src/org/python/core/util/importer.java
@@ -39,6 +39,8 @@
         searchOrder = makeSearchOrder();
     }
 
+    public abstract String get_data(String path);
+
     /**
      * Returns the separator between directories and files used by this type of importer.
      */

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list