Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107503

RE: Remove directory tree without following symlinks

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Albert-Jan Roskam <sjeik_appie@hotmail.com>
Newsgroups comp.lang.python
Subject RE: Remove directory tree without following symlinks
Date Fri, 22 Apr 2016 17:39:10 +0000
Lines 23
Message-ID <mailman.0.1461346817.32212.python-list@python.org> (permalink)
References <571a5be6$0$1590$c3e8da3$5496439d@news.astraweb.com> <DUB123-W22A605538041FB2749C64B836F0@phx.gbl>
Mime-Version 1.0
Content-Type text/plain; charset="windows-1256"
Content-Transfer-Encoding base64
X-Trace news.uni-berlin.de bFadWoKfeYtHlUxEmZlb/AL5HXdz5k4T6dAC7tO2HXQg==
Return-Path <sjeik_appie@hotmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'removes': 0.05; 'raises': 0.07; 'read-only': 0.07; '22,': 0.09; 'mentions': 0.09; 'raised,': 0.09; 'windowserror': 0.09; '2016': 0.16; 'fyi,': 0.16; 'os.walk': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'recipe': 0.16; 'subject:Remove': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.16; 'tree': 0.18; '&gt;': 0.18; 'to:2**1': 0.21; 'symbolic': 0.22; 'am,': 0.23; 'appears': 0.23; 'bit': 0.23; '(or': 0.23; 'help.': 0.23; 'seems': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'testing': 0.25; 'error': 0.27; 'fri,': 0.27; "skip:' 10": 0.28; 'sure,': 0.29; 'that.': 0.30; 'url:mailman': 0.30; 'probably': 0.31; 'date:': 0.31; 'option': 0.31; 'anyone': 0.32; 'url:python': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'url:listinfo': 0.34; 'so,': 0.35; 'dir': 0.35; 'subject:': 0.35; 'but': 0.36; 'should': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; "won't": 0.38; 'version': 0.38; 'does': 0.39; 'from:': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'skip:u 10': 0.61; 'confirm': 0.62; 'today': 0.65; 'improvement.': 0.66; 'email name:python-list': 0.67; 'charset:windows-1256': 0.67; 'links,': 0.76; 'email name:steve': 0.84; 'subject:tree': 0.84; '+1000': 0.91
X-TMN [mh6XRe4CzIivX7B4/SFXynCpFMQZMWkR]
X-Originating-Email [sjeik_appie@hotmail.com]
Importance Normal
In-Reply-To <571a5be6$0$1590$c3e8da3$5496439d@news.astraweb.com>
X-OriginalArrivalTime 22 Apr 2016 17:39:10.0539 (UTC) FILETIME=[E0D6F1B0:01D19CBD]
X-Content-Filtered-By Mailman/MimeDel 2.1.22
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <DUB123-W22A605538041FB2749C64B836F0@phx.gbl>
X-Mailman-Original-References <571a3ba2$0$1597$c3e8da3$5496439d@news.astraweb.com>, <1461337766.365000.586700849.0DDBDB0B@webmail.messagingengine.com>, <mailman.16.1461337768.2861.python-list@python.org>, <571a5be6$0$1590$c3e8da3$5496439d@news.astraweb.com>
Xref csiph.com comp.lang.python:107503

Show key headers only | View raw



> From: steve@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'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
> 
> Thanks for that.

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 either! A 'force' option would be a nice improvement.



> The os.walk recipe is described as a simple version of shutil.rmtree. The
> documentation for rmtree seems lacking to me, but after testing it, it
> appears to work as I want it: it removes symbolic links, it does not follow
> them.
>
> Is anyone else able to confirm that my understanding is correct? If so, the
> documentation should probably be a bit clearer.
> 
> 
> 
> -- 
> Steven
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
 		 	   		  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Remove directory tree without following symlinks Steven D'Aprano <steve@pearwood.info> - 2016-04-23 00:56 +1000
  Re: Remove directory tree without following symlinks Random832 <random832@fastmail.com> - 2016-04-22 11:09 -0400
    Re: Remove directory tree without following symlinks Steven D'Aprano <steve@pearwood.info> - 2016-04-23 03:14 +1000
      RE: Remove directory tree without following symlinks Albert-Jan Roskam <sjeik_appie@hotmail.com> - 2016-04-22 17:39 +0000
      Re: Remove directory tree without following symlinks eryk sun <eryksun@gmail.com> - 2016-04-22 13:28 -0500
      RE: Remove directory tree without following symlinks Albert-Jan Roskam <sjeik_appie@hotmail.com> - 2016-04-23 09:34 +0000
      Re: Remove directory tree without following symlinks eryk sun <eryksun@gmail.com> - 2016-04-23 15:22 -0500
      Re: Remove directory tree without following symlinks eryk sun <eryksun@gmail.com> - 2016-04-24 14:42 -0500
  Re: Remove directory tree without following symlinks Paul Rubin <no.email@nospam.invalid> - 2016-04-23 01:13 -0700
    Re: Remove directory tree without following symlinks Steven D'Aprano <steve@pearwood.info> - 2016-04-23 20:24 +1000
      Re: Remove directory tree without following symlinks Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-23 23:37 +1200
      Re: Remove directory tree without following symlinks Random832 <random832@fastmail.com> - 2016-04-23 17:04 -0400
  Re: Remove directory tree without following symlinks Nobody <nobody@nowhere.invalid> - 2016-04-23 17:29 +0100
    Re: Remove directory tree without following symlinks Random832 <random832@fastmail.com> - 2016-04-23 17:07 -0400

csiph-web