From 9a05621d69bdc0903b6c4d0606eed1dfbe077289 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 6 Apr 2011 15:24:32 +0200 Subject: [PATCH] ox.makedirs --- ox/file.py | 10 +++++++++- ox/utils.py | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ox/file.py b/ox/file.py index 58742e8..cecf87e 100644 --- a/ox/file.py +++ b/ox/file.py @@ -11,7 +11,7 @@ import subprocess from ox.utils import json -__all__ = ['sha1sum', 'oshash', 'avinfo'] +__all__ = ['sha1sum', 'oshash', 'avinfo', 'makedirs'] def sha1sum(filename): sha1 = hashlib.sha1() @@ -80,3 +80,11 @@ def avinfo(filename): return info return {'path': filename, 'size': 0} + +def makedirs(path): + if not os.path.exists(path): + try: + os.makedirs(path) + except OSError, e: + if e.errno != 17: + raise diff --git a/ox/utils.py b/ox/utils.py index 27118a8..047ade2 100644 --- a/ox/utils.py +++ b/ox/utils.py @@ -13,4 +13,3 @@ except ImportError: except ImportError: from django.utils import simplejson as json -