def copy_to_by_path(self, new_relative_path, keep_both=False, reset_author_and_created=False): """Copies the folder with files to the destination Path. :type new_relative_path: str :type keep_both: bool :type reset_author_and_created: bool """ target_folder = Folder(self.context) target_folder.set_property("ServerRelativePath", SPResPath(new_relative_path)) def _copy_folder(): opts = MoveCopyOptions( keep_both=keep_both, reset_author_and_created_on_copy=reset_author_and_created) MoveCopyUtil.copy_folder_by_path( self.context, self._build_full_url(self.server_relative_path.DecodedUrl), self._build_full_url(new_relative_path), opts) self.ensure_property("ServerRelativePath", _copy_folder) return target_folder
def get_list_using_path(self, decoded_url): return_list = List(self.context) self.lists.add_child(return_list) from office365.sharepoint.types.resource_path import ResourcePath as SPResPath qry = ServiceOperationQuery(self, "GetListUsingPath", SPResPath(decoded_url), None, None, return_list) self.context.add_query(qry) return return_list
def get_by_path(self, decoded_url): from office365.sharepoint.types.resource_path import ResourcePath as SPResPath target_folder = Folder(self.context) qry = ServiceOperationQuery(self, "GetByPath", SPResPath(decoded_url), None, "parameters", target_folder) self.context.add_query(qry) return target_folder
def move_folder_by_path(context, srcPath, destPath, options): """ :param office365.sharepoint.utilities.move_copy_options.MoveCopyOptions options: :param str srcPath: :param str destPath: :param office365.sharepoint.client_context.ClientContext context: client context """ util = MoveCopyUtil(context) payload = { "srcPath": SPResPath(srcPath), "destPath": SPResPath(destPath), "options": options } qry = ServiceOperationQuery(util, "MoveFolderByPath", None, payload, None, None) qry.static = True context.add_query(qry) return util
def get_by_path(self, decoded_url): """ Get folder at the specified path. :param str decoded_url: Specifies the path for the folder. """ return Folder( self.context, ServiceOperationPath("GetByPath", SPResPath(decoded_url), self.resource_path))
def get_list_using_path(self, decoded_url): """ :type decoded_url: str """ return_list = List(self.context) self.lists.add_child(return_list) qry = ServiceOperationQuery(self, "GetListUsingPath", SPResPath(decoded_url), None, None, return_list) self.context.add_query(qry) return return_list
def move_folder_by_path(context, src_path, dest_path, options): """ Moves a folder from a source URL to a destination URL. :param str src_path: A full or server relative path that represents the source folder. :param str dest_path: A full or server relative path that represents the destination folder. :param office365.sharepoint.client_context.ClientContext context: client context :param office365.sharepoint.utilities.move_copy_options.MoveCopyOptions options: Contains options used to modify the behavior. """ util = MoveCopyUtil(context) payload = { "srcPath": SPResPath(context.create_safe_url(src_path, False)), "destPath": SPResPath(context.create_safe_url(dest_path, False)), "options": options } qry = ServiceOperationQuery(util, "MoveFolderByPath", None, payload) qry.static = True context.add_query(qry) return util
def copy_folder_by_path(context, src_path, dest_path, options=None): """ Copies a folder from a source URL to a destination URL. :param office365.sharepoint.client_context.ClientContext context: client context :param str src_path: A full or server relative path that represents the source folder. :param str dest_path: A full or server relative url that represents the destination folder. :param office365.sharepoint.utilities.move_copy_options.MoveCopyOptions or None options: """ result = ClientResult(context) util = MoveCopyUtil(context) payload = { "srcPath": SPResPath(context.create_safe_url(src_path, False)), "destPath": SPResPath(context.create_safe_url(dest_path, False)), "options": options } qry = ServiceOperationQuery(util, "CopyFolderByPath", None, payload, None, result) qry.static = True context.add_query(qry) return result
def move_to_using_path(self, new_path): """ Moves the folder and its contents to a new folder at the specified path. An exception is thrown if a folder with the same name as specified in the parameter already exists. :param str new_path: Specifies the destination path. """ params = SPResPath(new_path) qry = ServiceOperationQuery(self, "MoveToUsingPath", params) self.context.add_query(qry) return self
def add_item_using_path(self, leaf_name, object_type, folder_url): """ :type leaf_name: str :type object_type: int :type folder_url: str """ from office365.sharepoint.types.resource_path import ResourcePath as SPResPath parameters = ListItemCreationInformationUsingPath( leaf_name, object_type, folder_path=SPResPath(folder_url)) item = ListItem(self.context) qry = ServiceOperationQuery(self, "AddItemUsingPath", None, parameters, "parameters", item) self.context.add_query(qry) return item
def __init__(self, leaf_name, object_type, folder_path=None): """ Specifies the properties of the new list item. :param str leaf_name: Specifies the name of the list item that will be created. In the case of a document library, the name is equal to the filename of the list item. :param int object_type: Specifies the file system object type for the item that will be created. :param str or SPResPath folder_path: Specifies the path of the folder of the new list item. """ super(ListItemCreationInformationUsingPath, self).__init__() self.LeafName = leaf_name self.UnderlyingObjectType = object_type self.FolderPath = folder_path if isinstance( folder_path, SPResPath) else SPResPath(folder_path)
def move_to_by_path(self, new_relative_path, retain_editor_and_modified=False): """Moves the folder with files to the destination Path. :type new_relative_path: str :type retain_editor_and_modified: bool """ target_folder = Folder(self.context) target_folder.set_property("ServerRelativePath", SPResPath(new_relative_path)) def _move_folder(): MoveCopyUtil.move_folder_by_path(self.context, self._build_full_url(self.server_relative_path.DecodedUrl), self._build_full_url(new_relative_path), MoveCopyOptions( retain_editor_and_modified_on_move=retain_editor_and_modified)) self.ensure_property("ServerRelativePath", _move_folder) return target_folder
def move_to_using_path_with_parameters(self, new_relative_path, retain_editor_and_modified=False): """Moves the folder with files to the destination Path. :param str new_relative_path: A full URL path that represents the destination folder. :param bool retain_editor_and_modified: """ target_folder = Folder(self.context) target_folder.set_property("ServerRelativePath", SPResPath(new_relative_path)) def _move_folder(): opt = MoveCopyOptions( retain_editor_and_modified_on_move=retain_editor_and_modified) MoveCopyUtil.move_folder_by_path( self.context, self.server_relative_path.DecodedUrl, new_relative_path, opt) self.ensure_property("ServerRelativePath", _move_folder) return target_folder
def parent_web_path(self): """Returns the path of the parent web for the list.""" return self.properties.get('ParentWebPath', SPResPath())
def server_relative_path(self): """ The server-relative-path of the attachment. """ return self.properties.get("ServerRelativePath", SPResPath())
def resource_path(self): """ Gets the Web site–relative Path of the form """ return self.properties.get("ResourcePath", SPResPath())
def server_relative_path(self): """Gets the server-relative Path of the View. :rtype: SPResPath or None """ return self.properties.get("ServerRelativePath", SPResPath(None))
def file_name_as_path(self): """ The file name of the attachment as a SP.ResourcePath. """ return self.properties.get("FileNameAsPath", SPResPath())