class MoveOperations
An enumeration-style class that defines constants for file move operation behaviors, specifically whether to overwrite existing files or perform no operation.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/files/move_operations.py
1 - 8
simple
Purpose
This class serves as a simple enumeration to specify criteria for file move operations. It provides named constants that can be used to control the behavior when moving files, particularly whether existing files should be overwritten. This is a lightweight alternative to using Python's enum.Enum, providing integer constants that can be used as flags or options in file operation functions.
Source Code
class MoveOperations:
"""Specifies criteria for how to move files."""
none = 0
"""Specifies no move operation is specified."""
overwrite = 1
"""Specifies a file with the same name is to be overwritten if it exists."""
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
bases: This refers to the base classes from which MoveOperations inherits. In this case, it implicitly inherits from 'object' (the default base class in Python). No explicit base classes are defined.
Return Value
Instantiating this class returns a MoveOperations object, though the class is designed to be used via its class-level constants (none=0, overwrite=1) rather than through instantiation. The class attributes 'none' and 'overwrite' return integer values (0 and 1 respectively) that represent different move operation modes.
Class Interface
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
none |
int | Constant value (0) indicating that no move operation is specified. Used as a default or null operation flag. | class |
overwrite |
int | Constant value (1) indicating that files with the same name should be overwritten if they exist at the destination. | class |
Usage Example
# Using MoveOperations as an enumeration
from move_operations import MoveOperations
# Access the constants directly from the class
operation_mode = MoveOperations.overwrite
print(operation_mode) # Output: 1
# Use in conditional logic
if operation_mode == MoveOperations.overwrite:
print("Will overwrite existing files")
elif operation_mode == MoveOperations.none:
print("No move operation specified")
# Example usage in a hypothetical file move function
def move_file(source, destination, operation=MoveOperations.none):
if operation == MoveOperations.overwrite:
# Overwrite logic here
pass
elif operation == MoveOperations.none:
# Skip or raise error if file exists
pass
move_file('source.txt', 'dest.txt', MoveOperations.overwrite)
Best Practices
- This class is designed to be used without instantiation - access the constants directly via the class name (e.g., MoveOperations.overwrite)
- The class serves as a namespace for related constants rather than a traditional class with methods and state
- Consider using Python's enum.IntEnum for more robust enumeration behavior in production code, as it provides better type safety and IDE support
- Do not modify the class attributes at runtime as they are intended to be immutable constants
- When extending this pattern, consider adding more operation types as additional class attributes with unique integer values
- This pattern is useful for maintaining backward compatibility with systems that expect integer flags rather than enum objects
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class FileSystemObjectType 52.0% similar
-
class MoveCopyOptions 49.3% similar
-
class MoveCopyUtil 47.4% similar
-
class SharingOperationStatusCode 44.3% similar
-
class HttpMethod 43.9% similar