From 832b76fc84a848a831963450f2537335acd7e852 Mon Sep 17 00:00:00 2001 From: gryf Date: Sat, 26 Nov 2016 16:10:45 +0100 Subject: [PATCH] Added forgotten utils module --- slack_backup/utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 slack_backup/utils.py diff --git a/slack_backup/utils.py b/slack_backup/utils.py new file mode 100644 index 0000000..a97fed5 --- /dev/null +++ b/slack_backup/utils.py @@ -0,0 +1,21 @@ +""" +Some utils functions. Jsut to not copypaste the code around +""" +import errno +import os +import logging + + +def makedirs(path): + """Create if not exists - version of os.makedirs.""" + try: + os.makedirs(path) + except OSError as err: + if err.errno != errno.EEXIST: + logging.error("Cannot create `%s'.", path) + raise + else: + if os.path.exists(path) and not os.path.isdir(path): + logging.error("Cannot create `%s'. There is some file on the " + "way; cannot proceed.", path) + raise