From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 4918E1381F3 for ; Tue, 23 Jul 2013 14:57:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4B7D0E09F7; Tue, 23 Jul 2013 14:57:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A1D09E09F7 for ; Tue, 23 Jul 2013 14:57:06 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B3D9833E99B for ; Tue, 23 Jul 2013 14:57:05 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 7BD6BE546E for ; Tue, 23 Jul 2013 14:57:03 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1374571894.eb054c34b1af6b908d4df808742113d42e218d12.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/util/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/util/common.py X-VCS-Directories: roverlay/util/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: eb054c34b1af6b908d4df808742113d42e218d12 X-VCS-Branch: master Date: Tue, 23 Jul 2013 14:57:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a23b0050-949b-49e4-9d85-77503cf2b90a X-Archives-Hash: 93e241f1a809e2e2d932c114b5555ac5 commit: eb054c34b1af6b908d4df808742113d42e218d12 Author: André Erdmann mailerd de> AuthorDate: Tue Jul 23 09:31:34 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Tue Jul 23 09:31:34 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=eb054c34 roverlay/util/common: try_unlink() Remove a file if it exists and ignore errors caused by non-existence. --- roverlay/util/common.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/roverlay/util/common.py b/roverlay/util/common.py index a2c155a..f27593a 100644 --- a/roverlay/util/common.py +++ b/roverlay/util/common.py @@ -8,9 +8,10 @@ __all__= [ 'dodir', 'for_all_files', 'get_dict_hash', 'keepenv', 'priosort', 'sysnop', - 'getsize', 'is_vcs_dir', 'headtail' + 'getsize', 'is_vcs_dir', 'headtail', 'try_unlink', ] +import errno import os import sys import logging @@ -26,6 +27,21 @@ def headtail ( iterable ): return ( iterable[0], iterable[1:] ) # --- end of headtail #py2 (...) --- +def try_unlink ( fspath ): + """Tries to remove a file. Does not fail if the file did not exist. + + arguments: + * fspath -- + """ + try: + os.unlink ( fspath ) + except OSError as oserr: + if oserr.errno == errno.ENOENT: + pass + else: + raise +# --- end of try_unlink (...) --- + def for_all_files ( files_or_dirs, func, args=(), kwargs={}, file_filter=None, ignore_missing=False From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7AF2F1381F3 for ; Tue, 23 Jul 2013 09:38:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E97C7E09B0; Tue, 23 Jul 2013 09:38:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 590D4E09B0 for ; Tue, 23 Jul 2013 09:38:22 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 57E9533E942 for ; Tue, 23 Jul 2013 09:38:21 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id C4DAEE5461 for ; Tue, 23 Jul 2013 09:38:19 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1374571894.eb054c34b1af6b908d4df808742113d42e218d12.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/util/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/util/common.py X-VCS-Directories: roverlay/util/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: eb054c34b1af6b908d4df808742113d42e218d12 X-VCS-Branch: gsoc13/next Date: Tue, 23 Jul 2013 09:38:19 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 0e04fff3-6001-494f-9973-8241c4efb34d X-Archives-Hash: 3b36902bbcd04baa5da96f837db4b9d7 Message-ID: <20130723093819.5fTryOLwbT0qXKcYZZ5CdrknWH2V1o5K3-qh51seJMw@z> commit: eb054c34b1af6b908d4df808742113d42e218d12 Author: André Erdmann mailerd de> AuthorDate: Tue Jul 23 09:31:34 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Tue Jul 23 09:31:34 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=eb054c34 roverlay/util/common: try_unlink() Remove a file if it exists and ignore errors caused by non-existence. --- roverlay/util/common.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/roverlay/util/common.py b/roverlay/util/common.py index a2c155a..f27593a 100644 --- a/roverlay/util/common.py +++ b/roverlay/util/common.py @@ -8,9 +8,10 @@ __all__= [ 'dodir', 'for_all_files', 'get_dict_hash', 'keepenv', 'priosort', 'sysnop', - 'getsize', 'is_vcs_dir', 'headtail' + 'getsize', 'is_vcs_dir', 'headtail', 'try_unlink', ] +import errno import os import sys import logging @@ -26,6 +27,21 @@ def headtail ( iterable ): return ( iterable[0], iterable[1:] ) # --- end of headtail #py2 (...) --- +def try_unlink ( fspath ): + """Tries to remove a file. Does not fail if the file did not exist. + + arguments: + * fspath -- + """ + try: + os.unlink ( fspath ) + except OSError as oserr: + if oserr.errno == errno.ENOENT: + pass + else: + raise +# --- end of try_unlink (...) --- + def for_all_files ( files_or_dirs, func, args=(), kwargs={}, file_filter=None, ignore_missing=False