From: SourceForge.net <no...@so...> - 2007-05-20 09:56:22
|
Patches item #1718975, was opened at 2007-05-15 01:37 Message generated for change (Comment added) made by laukpe You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312867&aid=1718975&group_id=12867 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Pekka Laukkanen (laukpe) Assigned to: Nobody/Anonymous (nobody) Summary: Patch for os.path.normcase bug 1648449 Initial Comment: Unfortunately there isn't any direct way to ask is the system case insensitive from the JVM. This patch is implemented so that at the end of the javapath.py there's _CASE_INSENSITIVE = samefile('foo', 'FOO') and normcase itself has the following code. def normcase(path): if _CASE_INSENSITIVE: path = path.lower() return path If having a new module global attribute doesn't sound like a good idea normcase can of course be implemented as follows. def normcase(path): if samefile('foo', 'FOO'): path = path.lower() return path If extra samefile call everyting normcase is used is considered waste there's at least one more possible way. if samefile('foo', 'FOO'): def normcase(path): return path.lower() else: def normcase(path): return path ---------------------------------------------------------------------- >Comment By: Pekka Laukkanen (laukpe) Date: 2007-05-20 12:56 Message: Logged In: YES user_id=1379331 Originator: YES Charlie, you are absolutely right. I promise to test my pathches better in the future. Just need to get Jython devenv somehow setup to my work machine too since it's the only Windows I have. I actually first implemented this patch using following test. Unfortunately that's not good either because os.curdir may also be '/' in posix and in that case the check below would return true. File(os.curdir.upper()).getCanonicalPath() == File(os.curdir.lower()).getCanonicalPath() You mentioned temp files and I got an idea that perhaps this could be implemented using the system temp directory -- there's no need to create it so there's no error checking required. Based on a little prototyping on console, copied below, it seems to work. C:\Temp>jython Jython 2.2b2 on java1.5.0_11 Type "copyright", "credits" or "license" for more information. >>> from java.io import File >>> from java.lang import System >>> tmp = System.getProperty('java.io.tmpdir') 'C:\\DOCUME~1\\pekkalau\\LOCALS~1\\Temp\\' >>> File(tmp.upper()).getCanonicalPath() 'C:\\Documents and Settings\\pekkalau\\Local Settings\\Temp' >>> File(tmp.lower()).getCanonicalPath() 'C:\\Documents and Settings\\pekkalau\\Local Settings\\Temp' Unfortunately I don't have time to write a new patch for this because I'm going to a business trip to China for two weeks today. I only take my work machine with me so I don't have Jython devenv with me. ---------------------------------------------------------------------- Comment By: Charles Groves (cgroves) Date: 2007-05-20 08:51 Message: Logged In: YES user_id=1174327 Originator: NO This doesn't work for me on Windows if 'foo'(or some case variant thereof) doesn't already exist. That makes sense to me since without a real path to base its calculations on, how is Java going to normalize to the existing case for a given filename? We could get around this by calling java.io.File.createTempFile and doing our path calculations based on that. Of course, then we'd have to handle not being able to create temp files at all. ---------------------------------------------------------------------- Comment By: Pekka Laukkanen (laukpe) Date: 2007-05-15 01:39 Message: Logged In: YES user_id=1379331 Originator: YES Note that the attached patch contains also argument type check for splitext that has been missing. Didn't want to create another patch only for that. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312867&aid=1718975&group_id=12867 |