

@_handle_object_not_found
def download(self, obj, directory, structure=True):
    '\n        Fetches the object from storage, and writes it to the specified\n        directory. The directory must exist before calling this method.\n\n        If the object name represents a nested folder structure, such as\n        "foo/bar/baz.txt", that folder structure will be created in the target\n        directory by default. If you do not want the nested folders to be\n        created, pass `structure=False` in the parameters.\n        '
    if (not os.path.isdir(directory)):
        raise exc.FolderNotFound(("The directory '%s' does not exist." % directory))
    obj_name = utils.get_name(obj)
    (path, fname) = os.path.split(obj_name)
    if structure:
        fullpath = os.path.join(directory, path)
        if (not os.path.exists(obj_name)):
            os.makedirs(fullpath)
        target = os.path.join(fullpath, fname)
    else:
        target = os.path.join(directory, fname)
    with open(target, 'wb') as dl:
        content = self.fetch(obj)
        try:
            dl.write(content)
        except UnicodeEncodeError:
            encoding = pyrax.get_encoding()
            dl.write(content.encode(encoding))

dataset/ETHPy150Open rackspace/pyrax/pyrax/object_storage.py StorageObjectManager.download/VarMisuse@102/285 `fullpath`->`obj_name`