From: Finn B. <bc...@us...> - 2001-06-04 10:43:44
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv28938 Modified Files: Options.java imp.java Log Message: Support for case sensitive imports on case-ignoring filesystem (like windows). Index: Options.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Options.java,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** Options.java 2001/03/04 18:04:31 2.7 --- Options.java 2001/06/04 10:42:59 2.8 *************** *** 74,77 **** --- 74,85 ---- public static String proxyDebugDirectory = null; + /** + * If true, Jython will use the first module found on sys.path + * where java File.isFile() returns true. Setting this to true + * have no effect on unix-type filesystems. On Windows/HPS+ + * systems setting it to true will enable Jython-2.0 behaviour. + */ + public static boolean caseok = false; + // // ####### END OF OPTIONS *************** *** 144,147 **** --- 152,159 ---- prop+"'"); } + + Options.caseok = + getBooleanOption("options.caseok", Options.pollStandardIn); + // additional initializations which must happen after the registry // is guaranteed to be initialized. Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -r2.43 -r2.44 *** imp.java 2001/05/28 22:43:21 2.43 --- imp.java 2001/06/04 10:42:59 2.44 *************** *** 295,299 **** // First check for packages File dir = new File(dirName, name); ! if (dir.isDirectory() && (new File(dir, "__init__.py").isFile() || new File(dir, "__init__$py.class").isFile())) --- 295,299 ---- // First check for packages File dir = new File(dirName, name); ! if (dir.isDirectory() && caseok(dir, name) && (new File(dir, "__init__.py").isFile() || new File(dir, "__init__$py.class").isFile())) *************** *** 314,319 **** Py.writeDebug("import", "trying source " + pyFile.getPath()); ! if (pyFile.isFile()) { ! if (classFile.isFile()) { Py.writeDebug("import", "trying precompiled " + classFile.getPath()); --- 314,319 ---- Py.writeDebug("import", "trying source " + pyFile.getPath()); ! if (pyFile.isFile() && caseok(pyFile, pyName)) { ! if (classFile.isFile() && caseok(classFile, className)) { Py.writeDebug("import", "trying precompiled " + classFile.getPath()); *************** *** 334,338 **** // If no source, try loading precompiled Py.writeDebug("import", "trying " + classFile.getPath()); ! if (classFile.isFile()) { return createFromPyClass(modName, makeStream(classFile), false, classFile.getPath()); --- 334,338 ---- // If no source, try loading precompiled Py.writeDebug("import", "trying " + classFile.getPath()); ! if (classFile.isFile() && caseok(classFile, className)) { return createFromPyClass(modName, makeStream(classFile), false, classFile.getPath()); *************** *** 340,343 **** --- 340,354 ---- } return null; + } + + private static boolean caseok(File file, String filename) { + if (Options.caseok) + return true; + try { + File canFile = new File(file.getCanonicalPath()); + return filename.equals(canFile.getName()); + } catch (IOException exc) { + return false; + } } |