def download(self, obj, directory, structure=True):
        """
        Fetches the object from storage, and writes it to the specified
        directory. The directory must exist before calling this method.

        If the object name represents a nested folder structure, such as
        "foo/bar/baz.txt", that folder structure will be created in the target
        directory by default. If you do not want the nested folders to be
        created, pass `structure=False` in the parameters.
        """
        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(fullpath):
                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))
def download ( self , obj , directory , structure = True ) : 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 ( fullpath ) : 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 ) )
Fetches the object from storage, and writes it to the specified
        directory. The directory must exist before calling this method.

        If the object name represents a nested folder structure, such as
        "foo/bar/baz.txt", that folder structure will be created in the target
        directory by default. If you do not want the nested folders to be
        created, pass `structure=False` in the parameters.