Re: [Python-Dev] os.path.normcase rationale?

2010-10-08 Thread Chris Withers
On 05/10/2010 12:04, Steven D'Aprano wrote: On Tue, 5 Oct 2010 07:21:15 pm Chris Withers wrote: On 25/09/2010 04:25, Steven D'Aprano wrote: 1. Return the case of a filename in some canonical form which depends on the file system? 2. Return the case of a filename as it is actually stored on

Re: [Python-Dev] os.path.normcase rationale?

2010-10-08 Thread Michael Foord
On 08/10/2010 09:41, Chris Withers wrote: On 05/10/2010 12:04, Steven D'Aprano wrote: On Tue, 5 Oct 2010 07:21:15 pm Chris Withers wrote: On 25/09/2010 04:25, Steven D'Aprano wrote: [snip...] FWIW, the use case that setuptools has (and for which it currently incorrectly uses normpath) is

Re: [Python-Dev] os.path.normcase rationale?

2010-10-08 Thread Ronald Oussoren
On 08 Oct, 2010,at 11:38 AM, Michael Foord fuzzy...@voidspace.org.uk wrote: On 08/10/2010 09:41, Chris Withers wrote: 4. Return the case of a filename in some arbitrarily-chosen canonical form which does not depend on the file system?AFAIK this is what the function is supposed to do: return a

Re: [Python-Dev] os.path.normcase rationale?

2010-10-05 Thread Chris Withers
On 25/09/2010 04:25, Steven D'Aprano wrote: 1. Return the case of a filename in some canonical form which depends on the file system? 2. Return the case of a filename as it is actually stored on disk? How do 1 and 2 differ? FWIW, the use case that setuptools has (and for which it

Re: [Python-Dev] os.path.normcase rationale?

2010-10-05 Thread Chris Withers
On 25/09/2010 15:45, Guido van Rossum wrote: The solution may well be OS specific. Solutions for Windows and OS X have already been pointed out. If it can't be done for other Unix versions, I think returning the input unchanged on those platform is a fine fallback (as it is for non-existent

Re: [Python-Dev] os.path.normcase rationale?

2010-10-05 Thread Steven D'Aprano
On Tue, 5 Oct 2010 07:21:15 pm Chris Withers wrote: On 25/09/2010 04:25, Steven D'Aprano wrote: 1. Return the case of a filename in some canonical form which depends on the file system? 2. Return the case of a filename as it is actually stored on disk? How do 1 and 2 differ? Case #1

Re: [Python-Dev] os.path.normcase rationale?

2010-10-03 Thread Dan Villiom Podlaski Christiansen
On 3 Oct 2010, at 02:35, Nir Soffer wrote: On Sat, Sep 25, 2010 at 1:36 AM, James Y Knight f...@fuhm.net wrote: An OSX code sketch is available here (summary: call FSPathMakeRef to get an FSRef from a path string, then FSRefMakePath to make it back into a path, which will then have the

Re: [Python-Dev] os.path.normcase rationale?

2010-10-03 Thread James Y Knight
On Oct 3, 2010, at 9:18 AM, Dan Villiom Podlaski Christiansen wrote: A simpler alternative would probably be the F_GETPATH fcntl. An example: That requires that you have permission to open the file (and to actually do so which might have other effects), while the File Manager's FSRef method

Re: [Python-Dev] os.path.normcase rationale?

2010-10-02 Thread Nir Soffer
On Sat, Sep 25, 2010 at 1:36 AM, James Y Knight f...@fuhm.net wrote: An OSX code sketch is available here (summary: call FSPathMakeRef to get an FSRef from a path string, then FSRefMakePath to make it back into a path, which will then have the correct case). And note that it only works if the

Re: [Python-Dev] os.path.normcase rationale?

2010-09-26 Thread Paul Moore
On 25 September 2010 23:57, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Paul Moore wrote: Windows has (I believe) user definable filesystems, too, but the OS has get me the real filename style calls, Does it really, though? The suggestions I've seen for doing this involve abusing the

Re: [Python-Dev] os.path.normcase rationale?

2010-09-26 Thread Paul Moore
On 26 September 2010 09:01, Paul Moore p.f.mo...@gmail.com wrote: On 25 September 2010 23:57, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Paul Moore wrote: Windows has (I believe) user definable filesystems, too, but the OS has get me the real filename style calls, Does it really, though?

Re: [Python-Dev] os.path.normcase rationale?

2010-09-26 Thread Dirkjan Ochtman
On Sun, Sep 26, 2010 at 13:36, Paul Moore p.f.mo...@gmail.com wrote: Hmm, I can't find the one I was thinking of. GetLongFileName correctly sets the case of all but the final part, and FindFile can be used to find the last part, but that's not what I recall. GetFinalPathNameByHandle works,

Re: [Python-Dev] os.path.normcase rationale?

2010-09-26 Thread James Y Knight
On Sep 26, 2010, at 7:36 AM, Paul Moore wrote: On 26 September 2010 09:01, Paul Moore p.f.mo...@gmail.com wrote: On 25 September 2010 23:57, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Paul Moore wrote: Windows has (I believe) user definable filesystems, too, but the OS has get me the

Re: [Python-Dev] os.path.normcase rationale?

2010-09-26 Thread Paul Moore
On 26 September 2010 13:37, James Y Knight f...@fuhm.net wrote: Were you thinking of SHGetFileInfo? http://stackoverflow.com/questions/74451/getting-actual-file-name-with-proper-casing-on-windows It wasn't, but it looks possible. Only gives the last component, though, so you still have to

Re: [Python-Dev] os.path.normcase rationale?

2010-09-26 Thread Brian Curtin
On Sun, Sep 26, 2010 at 06:36, Paul Moore p.f.mo...@gmail.com wrote: On 26 September 2010 09:01, Paul Moore p.f.mo...@gmail.com wrote: On 25 September 2010 23:57, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Paul Moore wrote: Windows has (I believe) user definable filesystems, too, but

Re: [Python-Dev] os.path.normcase rationale?

2010-09-25 Thread Paul Moore
On 24 September 2010 23:43, Glenn Linderman v+pyt...@g.nevcal.com wrote: Hmm.  There is no need for the function on a case sensitive file system, because the name had better be spelled with matching case: that is, if it is spelled with non-matching case it is an attempt to reference a

Re: [Python-Dev] os.path.normcase rationale?

2010-09-25 Thread Stephen J. Turnbull
Paul Moore writes: In fact, with userfs, I believe it's possible to do massively pathological things like having a filesystem which treats anagrams as the same file (foo is the same file as oof or ofo). (More realistically, MacOS does Unicode normalisation). Nitpick: Mac OS X doesn't do

Re: [Python-Dev] os.path.normcase rationale?

2010-09-25 Thread Guido van Rossum
On Fri, Sep 24, 2010 at 8:25 PM, Steven D'Aprano st...@pearwood.info wrote: On Sat, 25 Sep 2010 09:22:47 am Guido van Rossum wrote: I think that, like os.path.realpath(), it should not fail if the file does not exist. Maybe the API could be called os.path.unnormpath(), since it is in a

Re: [Python-Dev] os.path.normcase rationale?

2010-09-25 Thread Greg Ewing
Paul Moore wrote: Windows has (I believe) user definable filesystems, too, but the OS has get me the real filename style calls, Does it really, though? The suggestions I've seen for doing this involve abusing the short/long filename translation machinery, and I'm not sure they're guaranteed

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Chris Withers
On 18/09/2010 23:36, Guido van Rossum wrote: course, exists() and isdir() etc. do, and so does realpath(), but the pure parsing functions don't. Yes, but: H:\echo foo TeSt.txt ... import os.path os.path.realpath('test.txt') 'H:\\test.txt' os.path.normcase('TeSt.txt') 'test.txt' Both feel

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Ned Batchelder
On 9/24/2010 6:13 AM, Chris Withers wrote: On 18/09/2010 23:36, Guido van Rossum wrote: course, exists() and isdir() etc. do, and so does realpath(), but the pure parsing functions don't. Yes, but: H:\echo foo TeSt.txt ... import os.path os.path.realpath('test.txt') 'H:\\test.txt'

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread R. David Murray
On Fri, 24 Sep 2010 11:13:46 +0100, Chris Withers ch...@simplistix.co.uk wrote: On 18/09/2010 23:36, Guido van Rossum wrote: course, exists() and isdir() etc. do, and so does realpath(), but the pure parsing functions don't. Yes, but: H:\echo foo TeSt.txt ... import os.path

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Guido van Rossum
On Fri, Sep 24, 2010 at 5:17 AM, R. David Murray rdmur...@bitdance.com wrote: On Fri, 24 Sep 2010 11:13:46 +0100, Chris Withers ch...@simplistix.co.uk wrote: On 18/09/2010 23:36, Guido van Rossum wrote: course, exists() and isdir() etc. do, and so does realpath(), but the pure parsing

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Paul Moore
On 24 September 2010 15:29, Guido van Rossum gu...@python.org wrote: I don't think we should try to reimplement what the filesystem does. I think we should just ask the filesystem (how exactly I haven't figured out yet but I expect it will be more OS-specific than filesystem-specific). It will

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Greg Ewing
Paul Moore wrote: I dug into this once, and as far as I could tell, it's possible to get the information on Windows, but there's no way on Linux to ask the filesystem. Maybe we could use a heuristic such as: 1) Search the directory for an exact match to the name given, return it if found.

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Glenn Linderman
On 9/24/2010 3:10 PM, Greg Ewing wrote: Paul Moore wrote: I dug into this once, and as far as I could tell, it's possible to get the information on Windows, but there's no way on Linux to ask the filesystem. Maybe we could use a heuristic such as: 1) Search the directory for an exact match

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Guido van Rossum
I think that, like os.path.realpath(), it should not fail if the file does not exist. Maybe the API could be called os.path.unnormpath(), since it is in a sense the opposite of normpath() (which removes case) ? But I would want to write it so that even on Unix it scans the filesystem, in case the

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread James Y Knight
On Sep 24, 2010, at 10:53 AM, Paul Moore wrote: On 24 September 2010 15:29, Guido van Rossum gu...@python.org wrote: I don't think we should try to reimplement what the filesystem does. I think we should just ask the filesystem (how exactly I haven't figured out yet but I expect it will be

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Greg Ewing
Guido van Rossum wrote: Maybe the API could be called os.path.unnormpath(), since it is in a sense the opposite of normpath() (which removes case) ? Cute, but not very intuitive. Something like actualpath() might be better -- although that's somewhat arbitrarily different from realpath(). --

Re: [Python-Dev] os.path.normcase rationale?

2010-09-24 Thread Steven D'Aprano
On Sat, 25 Sep 2010 09:22:47 am Guido van Rossum wrote: I think that, like os.path.realpath(), it should not fail if the file does not exist. Maybe the API could be called os.path.unnormpath(), since it is in a sense the opposite of normpath() (which removes case) ? But I would want to

Re: [Python-Dev] os.path.normcase rationale?

2010-09-18 Thread Guido van Rossum
On Sat, Sep 18, 2010 at 2:39 PM, Chris Withers ch...@simplistix.co.uk wrote: I'm curious as to why, with a file called Foo.txt on a case descriminating but case insensitive filesystem, os.path.normcase('FoO.txt') will return foo.txt rather than Foo.txt? Yes, I know the behaviour is