[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-17 Thread Eryk Sun
On 11/7/22, Eryk Sun wrote: > > def isjunction(path): > """Test whether a path is a junction. > """ > try: > st = os.lstat(path) > except (OSError, ValueError, AttributeError): > return False > return bool(st.st_reparse_tag & stat

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-09 Thread Stephen J. Turnbull
Paul Moore writes: > While I frequently advocate on the side of "not every 3-line function needs > to be in the stdlib", there are a lot of convenience functions for Unix in > the stdlib IMO "is_*" functions aren't exactly "convenience" functions, even if they're only a couple of lines impleme

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-08 Thread Paul Moore
On Tue, 8 Nov 2022 at 23:34, Steven D'Aprano wrote: > > Most Python coders are using Windows. Surely it is time to do better > for them than "just roll your own"? While I frequently advocate on the side of "not every 3-line function needs to be in the stdlib", there are a lot of convenience fun

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-08 Thread Steven D'Aprano
On Tue, Nov 08, 2022 at 09:55:04PM +, Barry wrote: > But anyone that is suitably motivated can implement this. This is true for every function in a Turing Complete language. Perhaps we should start using iota or jot? :-) https://en.wikipedia.org/wiki/Iota_and_Jot A "suitably motivated" per

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-08 Thread Barry
On 8 Nov 2022, at 17:56, Charles Machalow wrote:I would argue that just because it was easy for one to implement doesn't mean it's easy for others. That is true of so many things in life!I would have had no idea how to implement this without extra Googling and confusion.Having the abstraction mak

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-08 Thread Charles Machalow
I would argue that just because it was easy for one to implement doesn't mean it's easy for others. I would have had no idea how to implement this without extra Googling and confusion. Having the abstraction makes it easier for others. - Charlie Scott Machalow On Tue, Nov 8, 2022 at 1:12 AM Eryk

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-08 Thread Eryk Sun
On 11/8/22, Charles Machalow wrote: > > Funny enough in PowerShell, for prints an "l" for both symlinks and > junctions.. so it kind of thinks of it as a link of some sort too I guess. As does Python already in many cases. For example, os.lstat() doesn't traverse a mount point (junction). On Wind

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-08 Thread Steven D'Aprano
On Mon, Nov 07, 2022 at 07:31:36PM -, Charles Machalow wrote: > I propose adding a mechanism to both pathlib.Path and os.path to check > if a given path is a junction or not. Currently is_symlink/islink > return False for junctions. +1 on a function is_junction. I am neutral on the questio

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-07 Thread Ram Rachum
+1 on adding Path.is_junction() that returns False on non-Windows systems. (I'm a Windows user and I use junctions as well.) On Tue, Nov 8, 2022 at 9:24 AM Charles Machalow wrote: > I'm not technical enough here to try to argue which it is closer to. We > can say it's like so and so in implement

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-07 Thread Charles Machalow
I'm not technical enough here to try to argue which it is closer to. We can say it's like so and so in implementation, but I just liken it a certain way. I think for regular users it makes most sense to just have a specific function rather than expecting folks to know concept similarities... a sim

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-07 Thread Eryk Sun
On 11/8/22, Charles Machalow wrote: > I tend to prefer adding isjunction instead of changing ismount since I tend > to not think about junctions as being mounts (but closer to symlinks).. Junctions are mount points that are similar to Unix bind mounts where it counts -- in the behavior that's imp

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-07 Thread Charles Machalow
I tend to prefer adding isjunction instead of changing ismount since I tend to not think about junctions as being mounts (but closer to symlinks).. but I guess either way the closeness of the concepts is a different story than the specific ask here. In other words: for clarity, adding a specific me

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-07 Thread Eryk Sun
On 11/7/22, Charles Machalow wrote: > So would you be for specific methods to check if a given path is a > junction? I'd prefer for ismount() to be modified to always return true for a junction. This would be a significant rewrite of the current implementation, which is only true for a junction t

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-07 Thread Charles Machalow
So would you be for specific methods to check if a given path is a junction? On Mon, Nov 7, 2022, 4:49 PM Eryk Sun wrote: > On 11/7/22, Charles Machalow wrote: > > > > Junctions are contextually similar to symlinks on Windows. > > Junctions (i.e. IO_REPARSE_TAG_MOUNT_POINT) are implemented to b

[Python-ideas] Re: Add mechanism to check if a path is a junction (for Windows)

2022-11-07 Thread Eryk Sun
On 11/7/22, Charles Machalow wrote: > > Junctions are contextually similar to symlinks on Windows. Junctions (i.e. IO_REPARSE_TAG_MOUNT_POINT) are implemented to behave as mount points for local volumes, so there are a couple of important differences. In a remote path, a junction gets resolved o