#
# Various IPP helpers
#
import os

#################################################################
def mkdir(directoryName):
    """From http://code.activestate.com/recipes/82465-a-friendly-mkdir/

    Works the way a good mkdir should :)
        - already exists, silently complete
        - regular file in the way, raise an exception
        - parent directory(ies) does not exist, make them as well
    """
    print 'Creating directory [%s]' % directoryName
    if os.path.isdir(directoryName):
        pass
    elif os.path.isfile(directoryName):
        raise OSError("a file with the same name as the desired " \
                      "dir, '%s', already exists." % directoryName)
    else:
        head, tail = os.path.split(directoryName)
        if head and not os.path.isdir(head):
            mkdir(head)
        if tail:
            os.mkdir(directoryName)

#################################################################
if __name__ == '__main__':
    print 'Not intended to be used independently'
