From 11f2b70a38c7a8dbed276cd420a94e0e24bd3084 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 7 Oct 2009 10:58:13 -0400 Subject: [PATCH] Added the FileUtils module. --- src/FileUtils.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/FileUtils.py diff --git a/src/FileUtils.py b/src/FileUtils.py new file mode 100644 index 0000000..2b89adf --- /dev/null +++ b/src/FileUtils.py @@ -0,0 +1,29 @@ +""" +Utility functions for working with the filesystem, generally modeled +after useful shell commands. +""" + +import os + + +def rm_f(path): + """ + Remove (unlink) a file, ignoring any exceptions that may be + thrown. + """ + try: + os.remove(path) + except: + pass + + +def mkdir_p(path, mode): + """ + Create a directory hierarchy, ignoring any exceptions that may be + thrown. + """ + try: + os.makedirs(path, mode) + except: + pass + -- 2.44.2