Re: Remove directory tree without following symlinks

2016-04-24 Thread eryk sun
On Sun, Apr 24, 2016 at 5:42 AM, Albert-Jan Roskam wrote: > Aww, I kinda forgot about that already, but I came across this last > year [1]. Apparently, shutil.rmtree(very_long_path) failed under Win 7, > even with the "silly prefix". I believe very_long_path was a >

RE: Remove directory tree without following symlinks

2016-04-24 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Sat, 23 Apr 2016 15:22:35 -0500 > Subject: Re: Remove directory tree without following symlinks > To: python-list@python.org > > On Sat, Apr 23, 2016 at 4:34 AM, Albert-Jan Roskam > wrote: >> >>> From: eryk...@gmail.com >&

Re: Remove directory tree without following symlinks

2016-04-23 Thread Random832
On Sat, Apr 23, 2016, at 12:29, Nobody wrote: > On Linux, an alternative is to use fchdir() rather than chdir(), which > changes to a directory specified by an open file descriptor Of course, then there's also the risk of running out of open file descriptors. High-quality implementations of rm

Re: Remove directory tree without following symlinks

2016-04-23 Thread Random832
On Sat, Apr 23, 2016, at 06:24, Steven D'Aprano wrote: > "rm -r" gives me a NameError when I run it in my Python script :-) > > But seriously, where is that documented? I've read the man page for > rm, and it doesn't say anything about treatment of symlinks, nor is > there an option to follow/not

Re: Remove directory tree without following symlinks

2016-04-23 Thread eryk sun
On Sat, Apr 23, 2016 at 4:34 AM, Albert-Jan Roskam wrote: > >> From: eryk...@gmail.com >> Date: Fri, 22 Apr 2016 13:28:01 -0500 >> On Fri, Apr 22, 2016 at 12:39 PM, Albert-Jan Roskam >> wrote: >> > FYI, Just today I found out that shutil.rmtree

Re: Remove directory tree without following symlinks

2016-04-23 Thread Nobody
On Sat, 23 Apr 2016 00:56:33 +1000, Steven D'Aprano wrote: > I want to remove a directory, including all files and subdirectories under > it, but without following symlinks. I want the symlinks to be deleted, not > the files pointed to by those symlinks. Note that this is non-trivial to do

Re: Remove directory tree without following symlinks

2016-04-23 Thread Gregory Ewing
Steven D'Aprano wrote: But seriously, where is that documented? I've read the man page for rm, and it doesn't say anything about treatment of symlinks The Linux man page seems to be a bit deficient on this. The BSD version contains this sentence: The rm utility removes symbolic links,

Re: Remove directory tree without following symlinks

2016-04-23 Thread Steven D'Aprano
On Sat, 23 Apr 2016 06:13 pm, Paul Rubin wrote: > Steven D'Aprano writes: >> I want to remove a directory, including all files and subdirectories >> under it, but without following symlinks. I want the symlinks to be >> deleted, not the files pointed to by those symlinks. >

RE: Remove directory tree without following symlinks

2016-04-23 Thread Albert-Jan Roskam
> From: eryk...@gmail.com > Date: Fri, 22 Apr 2016 13:28:01 -0500 > Subject: Re: Remove directory tree without following symlinks > To: python-list@python.org > > On Fri, Apr 22, 2016 at 12:39 PM, Albert-Jan Roskam > <sjeik_ap...@hotmail.com> wrote: >

Re: Remove directory tree without following symlinks

2016-04-23 Thread Paul Rubin
Steven D'Aprano writes: > I want to remove a directory, including all files and subdirectories under > it, but without following symlinks. I want the symlinks to be deleted, not > the files pointed to by those symlinks. rm -r shouldn't follow symlinks like you mention. --

Re: Remove directory tree without following symlinks

2016-04-22 Thread eryk sun
On Fri, Apr 22, 2016 at 12:39 PM, Albert-Jan Roskam wrote: > FYI, Just today I found out that shutil.rmtree raises a WindowsError if the > dir is read- > only (or its contents). Using 'ignore_errors', won't help. Sure, no error is > raised, but the > dir is not deleted

RE: Remove directory tree without following symlinks

2016-04-22 Thread Albert-Jan Roskam
> From: st...@pearwood.info > Subject: Re: Remove directory tree without following symlinks > Date: Sat, 23 Apr 2016 03:14:12 +1000 > To: python-list@python.org > > On Sat, 23 Apr 2016 01:09 am, Random832 wrote: > > > On Fri, Apr 22, 2016, at 10:56, Steven D'Apran

Re: Remove directory tree without following symlinks

2016-04-22 Thread Steven D'Aprano
On Sat, 23 Apr 2016 01:09 am, Random832 wrote: > On Fri, Apr 22, 2016, at 10:56, Steven D'Aprano wrote: >> What should I use for "remove_tree"? Do I have to write my own, or does a >> solution already exist? > > In the os.walk documentation it provides a simple recipe and also > mentions

Re: Remove directory tree without following symlinks

2016-04-22 Thread Random832
On Fri, Apr 22, 2016, at 10:56, Steven D'Aprano wrote: > What should I use for "remove_tree"? Do I have to write my own, or does a > solution already exist? In the os.walk documentation it provides a simple recipe and also mentions shutil.rmtree --

Remove directory tree without following symlinks

2016-04-22 Thread Steven D'Aprano
I want to remove a directory, including all files and subdirectories under it, but without following symlinks. I want the symlinks to be deleted, not the files pointed to by those symlinks. E.g. if I have this tree: parent/ +-- spam/ : +-- a.txt : +-- b.txt : +-- eggs/ : : +-- c.txt :