class NodeType
An enumeration class that defines the three types of nodes that can exist in the reMarkable cloud storage system.
/tf/active/vicechatdev/e-ink-llm/cloudtest/local_replica.py
33 - 37
simple
Purpose
NodeType is an Enum class that provides type-safe constants for representing different node types in the reMarkable cloud ecosystem. It distinguishes between folders (containers), documents (imported files), and notebooks (native reMarkable files). This enum is used throughout the codebase to categorize and handle different types of content stored in reMarkable cloud, enabling type checking and preventing invalid node type values.
Source Code
class NodeType(Enum):
"""Types of nodes in reMarkable cloud"""
FOLDER = "folder"
DOCUMENT = "document"
NOTEBOOK = "notebook"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Enum | - |
Parameter Details
bases: Inherits from Enum base class, which provides enumeration functionality. No constructor parameters are needed as this is an Enum with predefined values.
Return Value
Instantiation returns a NodeType enum member. Each member has a name (FOLDER, DOCUMENT, NOTEBOOK) and a corresponding string value ('folder', 'document', 'notebook'). Accessing members returns the enum instance, and accessing .value returns the string representation.
Class Interface
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
FOLDER |
NodeType | Represents a folder/directory node in reMarkable cloud that can contain other nodes | class |
DOCUMENT |
NodeType | Represents a document node (imported PDF or EPUB file) in reMarkable cloud | class |
NOTEBOOK |
NodeType | Represents a notebook node (native reMarkable notebook with handwritten content) in reMarkable cloud | class |
Dependencies
enum
Required Imports
from enum import Enum
Usage Example
from enum import Enum
class NodeType(Enum):
FOLDER = "folder"
DOCUMENT = "document"
NOTEBOOK = "notebook"
# Access enum members
node_type = NodeType.FOLDER
print(node_type) # NodeType.FOLDER
print(node_type.value) # 'folder'
print(node_type.name) # 'FOLDER'
# Compare enum members
if node_type == NodeType.FOLDER:
print("This is a folder")
# Create from string value
node_from_string = NodeType('document')
print(node_from_string) # NodeType.DOCUMENT
# Iterate over all types
for node_type in NodeType:
print(f"{node_type.name}: {node_type.value}")
# Use in type hints
def process_node(node_type: NodeType) -> str:
return f"Processing {node_type.value}"
Best Practices
- Use NodeType members directly (e.g., NodeType.FOLDER) rather than string literals to ensure type safety
- When comparing node types, use identity comparison (==) with enum members rather than comparing string values
- Use NodeType in type hints to make function signatures more explicit and enable better IDE support
- To get the string value for API calls or serialization, use the .value attribute
- To create a NodeType from a string value (e.g., from API response), use NodeType('folder') which will raise ValueError if the string is invalid
- Enum members are singletons and immutable, so they can be safely used as dictionary keys or in sets
- Do not attempt to modify enum values or add new members at runtime
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class RemarkableNode 71.5% similar
-
class RemarkableNode_v1 69.9% similar
-
class RemarkableNode_v1 67.5% similar
-
class ReplicaNode 60.8% similar
-
class NodeLabels_v1 57.4% similar