class FileSystemObjectType
An enumeration class that defines constants representing different file system object types (Invalid, File, Folder, Web).
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/files/system_object_type.py
1 - 17
simple
Purpose
This class serves as a namespace for enumeration constants that categorize file system objects. It provides standardized integer values to distinguish between invalid objects (-1), files (0), folders (1), and web/site objects (2). This pattern is commonly used for type checking and conditional logic when working with file system operations or SharePoint-like systems.
Source Code
class FileSystemObjectType:
"""Specifies the file system object type."""
def __init__(self):
pass
Invalid = -1
"""Enumeration whose values specify whether the object is invalid. The value = -1."""
File = 0
"""Enumeration whose values specify whether the object is a file. The value = 0."""
Folder = 1
"""Enumeration whose values specify whether the object is a folder. The value = 1."""
Web = 2
"""Enumeration whose values specify whether the object is a site. The values = 2."""
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
__init__: The constructor takes no parameters and performs no initialization. It exists only to allow instantiation of the class, though the class is primarily intended to be used as a static namespace for its class-level constants.
Return Value
Instantiation returns a FileSystemObjectType instance, though this is not the typical usage pattern. The class is designed to be used by accessing its class-level constants directly (e.g., FileSystemObjectType.File) rather than creating instances. Each constant returns an integer value representing a specific file system object type.
Class Interface
Methods
__init__(self) -> None
Purpose: Constructor that performs no initialization; exists for class instantiation though not typically needed
Returns: None - creates an empty instance of FileSystemObjectType
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Invalid |
int | Constant representing an invalid file system object with value -1 | class |
File |
int | Constant representing a file object with value 0 | class |
Folder |
int | Constant representing a folder/directory object with value 1 | class |
Web |
int | Constant representing a web/site object with value 2 | class |
Usage Example
# Typical usage - accessing class constants directly without instantiation
if obj_type == FileSystemObjectType.File:
print("This is a file")
elif obj_type == FileSystemObjectType.Folder:
print("This is a folder")
elif obj_type == FileSystemObjectType.Web:
print("This is a web/site object")
elif obj_type == FileSystemObjectType.Invalid:
print("Invalid object")
# Checking object type value
file_type = FileSystemObjectType.File # Returns 0
folder_type = FileSystemObjectType.Folder # Returns 1
web_type = FileSystemObjectType.Web # Returns 2
invalid_type = FileSystemObjectType.Invalid # Returns -1
# Less common - instantiation (not recommended)
fs_obj = FileSystemObjectType()
print(fs_obj.File) # Outputs: 0
Best Practices
- Use the class constants directly without instantiating the class (e.g., FileSystemObjectType.File instead of FileSystemObjectType().File)
- This class follows an enumeration pattern but predates Python's enum.Enum; consider using enum.IntEnum for new code
- The constants are class-level attributes, not instance attributes, making instantiation unnecessary
- Use these constants for type comparison rather than hardcoding integer values in your code
- The Invalid value (-1) should be used to represent error states or uninitialized objects
- This pattern is commonly found in SharePoint and Office 365 APIs for categorizing list items and objects
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class PageType 69.2% similar
-
class BaseType 65.4% similar
-
class CalendarType 64.9% similar
-
class TemplateFileType 62.1% similar
-
class SiteType 60.0% similar