Did I find the right examples for you? yes no

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)
create all needed directories, ignore EEXIST errors.

        def optional_makedirs(path):
    "create all needed directories, ignore EEXIST errors."
    try:
        os.makedirs(path)
    except os.error, exception:
        if exception.errno != errno.EEXIST:
            raise
        


src/p/y/PyPreval-0.0.0/pypreval/store.py   PyPreval(Download)
from __future__ import absolute_import
from .nulllock import NullLock
from .util import optional_makedirs
import os, cPickle
 
    def _make_transaction_path(self, id):
        "returns the path for transaction id."
        dir_id = int(id / self.transaction_per_directory)
        dir_name = self._make_name("t%07d" % dir_id)
        optional_makedirs(dir_name)
    def __init__(self, directory):
        self._lock = self.__class__.lock_manager()
        self._transid = 0
        self._directory = directory
        optional_makedirs(directory)

src/p/y/PyPreval-0.0.0/pypreval/test_util.py   PyPreval(Download)
 
from __future__ import absolute_import
from .util import optional_makedirs
from nose.tools import assert_raises
import errno, os
    def test_already_existing(self):
        "tests that calling optional_makedirs with the same path twice does not raise any errors"
        optional_makedirs(self.path)
        optional_makedirs(self.path)