def create_test_directory(tree):

    # Note: This will create a directory with permissions 0o700
    temp_dir = tempfile.mkdtemp()

    resolve_path = lambda x: os.path.join(temp_dir, x)

    for i in tree:
        if isinstance(i, str) or isinstance(i, unicode):
            os.mkdir(resolve_path(i), 0o700)
        elif isinstance(i, tuple) and len(i) == 2:
            path, size = i
            with open(resolve_path(path), "w") as f:
                symbols = string.ascii_letters + string.digits
                for i in xrange(size):
                    f.write(random.choice(symbols))
        else:
            raise TypeError("All items in list must be string or two-tuple.")

    return temp_dir
Attach vmdk volume storage to VM instance.
dataset/ETHPy150Open brownhead/superzippy/superzippy/tests/file_utilities.py/create_test_directory--crossover with--dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/vmwareapi/volumeops.py/VMwareVolumeOps._attach_volume_vmdk