public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/util/
Date: Tue, 23 Jul 2013 14:57:03 +0000 (UTC)	[thread overview]
Message-ID: <1374571894.eb054c34b1af6b908d4df808742113d42e218d12.dywi@gentoo> (raw)

commit:     eb054c34b1af6b908d4df808742113d42e218d12
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Tue Jul 23 09:31:34 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> 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


WARNING: multiple messages have this Message-ID (diff)
From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/util/
Date: Tue, 23 Jul 2013 09:38:19 +0000 (UTC)	[thread overview]
Message-ID: <1374571894.eb054c34b1af6b908d4df808742113d42e218d12.dywi@gentoo> (raw)
Message-ID: <20130723093819.5fTryOLwbT0qXKcYZZ5CdrknWH2V1o5K3-qh51seJMw@z> (raw)

commit:     eb054c34b1af6b908d4df808742113d42e218d12
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Tue Jul 23 09:31:34 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> 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


             reply	other threads:[~2013-07-23 14:57 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23 14:57 André Erdmann [this message]
2013-07-23  9:38 ` [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/util/ André Erdmann
  -- strict thread matches above, loose matches on Subject: below --
2016-07-07  4:19 [gentoo-commits] proj/R_overlay:master " Benda XU
2015-01-26 17:41 André Erdmann
2014-08-23 19:03 André Erdmann
2014-06-05 22:09 André Erdmann
2014-06-05 22:09 André Erdmann
2014-04-01 16:38 André Erdmann
2014-02-16 16:30 André Erdmann
2014-01-25 18:14 André Erdmann
2013-12-11 18:40 André Erdmann
2013-09-20 15:57 André Erdmann
2013-09-12 16:36 André Erdmann
2013-09-12 16:36 André Erdmann
2013-09-10 14:40 André Erdmann
2013-09-05 10:24 André Erdmann
2013-09-05  9:25 André Erdmann
2013-09-05  9:25 André Erdmann
2013-09-03 15:50 André Erdmann
2013-09-03 15:50 André Erdmann
2013-09-03 12:21 André Erdmann
2013-09-03  8:35 André Erdmann
2013-09-02 16:21 André Erdmann
2013-08-30 14:49 André Erdmann
2013-08-30 14:49 André Erdmann
2013-08-29 13:53 André Erdmann
2013-08-29 12:36 André Erdmann
2013-08-29 12:36 André Erdmann
2013-08-23 13:52 André Erdmann
2013-08-23 13:52 André Erdmann
2013-08-23 13:52 André Erdmann
2013-08-23 13:51 André Erdmann
2013-08-22  9:01 André Erdmann
2013-08-16  6:44 André Erdmann
2013-08-13  8:56 André Erdmann
2013-08-01 12:44 André Erdmann
2013-07-30 18:40 André Erdmann
2013-07-29 14:56 André Erdmann
2013-07-23 14:57 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-07-23 14:57 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-07-18 19:25 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-07-23  7:51 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-07-12 13:57 André Erdmann
2013-06-20 23:40 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-06-22 15:24 ` [gentoo-commits] proj/R_overlay:master " André Erdmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374571894.eb054c34b1af6b908d4df808742113d42e218d12.dywi@gentoo \
    --to=dywi@mailerd.de \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox