🔍 Code Extractor

class NodeType

Maturity: 36

An enumeration class that defines the three types of nodes that can exist in the reMarkable cloud storage system.

File:
/tf/active/vicechatdev/e-ink-llm/cloudtest/local_replica.py
Lines:
33 - 37
Complexity:
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

    A dataclass representing a node (file or folder) in the reMarkable cloud storage system, containing metadata, hierarchy information, and component hashes for documents.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/discovery.py
  • class RemarkableNode_v1 69.9% similar

    A dataclass representing a node (folder or document) in the reMarkable cloud storage system, storing metadata, hashes, and local file paths.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/local_replica_v2.py
  • class RemarkableNode_v1 67.5% similar

    A dataclass representing a node (file or folder) in the reMarkable tablet's file system hierarchy, storing metadata, hashes, and local file paths.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/sync_replica_new.py
  • class ReplicaNode 60.8% similar

    A dataclass representing a node in a local replica of reMarkable cloud storage, containing comprehensive metadata about files, folders, and their synchronization state.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/local_replica.py
  • class NodeLabels_v1 57.4% similar

    A constants class that defines string labels for Neo4j graph database node types used in a controlled document management system (CDocs).

    From: /tf/active/vicechatdev/CDocs single class/db/schema_manager.py
← Back to Browse