From b92621cad710dccd132ae4c79de3256b8d04db74 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 24 May 2012 15:53:53 +0200 Subject: [PATCH] add a way on how to add workaround for older pythor versions Signed-off-by: Nico Schottelius --- doc/dev/logs/2012-05-24.makedirs.py-python3.1 | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 doc/dev/logs/2012-05-24.makedirs.py-python3.1 diff --git a/doc/dev/logs/2012-05-24.makedirs.py-python3.1 b/doc/dev/logs/2012-05-24.makedirs.py-python3.1 new file mode 100644 index 00000000..5ad82b29 --- /dev/null +++ b/doc/dev/logs/2012-05-24.makedirs.py-python3.1 @@ -0,0 +1,27 @@ +# From curl http://armstrong.cc/~steven/tmp/makedirs.py: + +#!/usr/bin/env python2 + +import os + +def makedirs(path, mode=0o777, exist_ok=False): + try: + os.makedirs(path, mode=mode, exist_ok=exist_ok) + except TypeError: + try: + os.makedirs(path, mode=mode) + except OSError as e: + if exist_ok and e.errno == 17: # File exists + pass + else: + raise + + +makedirs('/tmp/python/makedirs') + +try: + makedirs('/tmp/python/makedirs') +except OSError as e: + print(e) + +makedirs('/tmp/python/makedirs', exist_ok=True)