🔍 Code Extractor

class RemarkableNode_v1

Maturity: 46

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

File:
/tf/active/vicechatdev/e-ink-llm/cloudtest/local_replica_v2.py
Lines:
21 - 49
Complexity:
simple

Purpose

RemarkableNode serves as a data structure to represent files and folders from a reMarkable tablet's cloud storage. It tracks unique identifiers (UUID), content hashes for change detection, metadata from the device, and local file system paths after synchronization. This class is typically used in sync operations to maintain a mapping between cloud resources and local files, enabling efficient incremental updates by comparing hashes.

Source Code

class RemarkableNode:
    """Simple node representation"""
    uuid: str
    hash: str
    name: str
    node_type: str  # "folder" or "document"
    parent_uuid: Optional[str]
    
    # Component hashes
    content_hash: Optional[str] = None
    metadata_hash: Optional[str] = None
    pdf_hash: Optional[str] = None
    pagedata_hash: Optional[str] = None
    rm_hashes: List[str] = None
    
    # Metadata from reMarkable
    metadata: Dict[str, Any] = None
    
    # Local paths (set in phase 2)
    local_path: str = ""
    extracted_files: List[str] = None
    
    def __post_init__(self):
        if self.rm_hashes is None:
            self.rm_hashes = []
        if self.metadata is None:
            self.metadata = {}
        if self.extracted_files is None:
            self.extracted_files = []

Parameters

Name Type Default Kind
bases - -

Parameter Details

uuid: Unique identifier for the node in the reMarkable cloud system. This is the primary key used to identify documents and folders.

hash: Overall hash value representing the current state of the node, used for change detection during synchronization.

name: Human-readable name of the document or folder as displayed on the reMarkable device.

node_type: Type of the node, must be either 'folder' or 'document'. Determines how the node should be processed.

parent_uuid: UUID of the parent folder containing this node. None for root-level items.

content_hash: Hash of the content file (.content) for this node. Optional, used for detecting content changes.

metadata_hash: Hash of the metadata file (.metadata) for this node. Optional, used for detecting metadata changes.

pdf_hash: Hash of the PDF file if the document is or contains a PDF. Optional.

pagedata_hash: Hash of the pagedata file containing page-specific information. Optional.

rm_hashes: List of hashes for .rm files (reMarkable's proprietary drawing format). Defaults to empty list if not provided.

metadata: Dictionary containing metadata from the reMarkable device (e.g., timestamps, version info). Defaults to empty dict if not provided.

local_path: Local file system path where this node's files are stored. Set during phase 2 of synchronization. Defaults to empty string.

extracted_files: List of file paths that have been extracted locally for this node. Defaults to empty list if not provided.

Return Value

Instantiation returns a RemarkableNode object with all specified attributes initialized. The __post_init__ method ensures that mutable default values (rm_hashes, metadata, extracted_files) are properly initialized as empty collections if not provided, preventing shared mutable default issues.

Class Interface

Methods

__post_init__(self) -> None

Purpose: Initializes mutable default values after dataclass initialization to prevent shared state between instances

Returns: None. Modifies instance attributes in-place.

Attributes

Name Type Description Scope
uuid str Unique identifier for the node in the reMarkable cloud system instance
hash str Overall hash value representing the current state of the node instance
name str Human-readable name of the document or folder instance
node_type str Type of the node: 'folder' or 'document' instance
parent_uuid Optional[str] UUID of the parent folder, None for root-level items instance
content_hash Optional[str] Hash of the content file for change detection instance
metadata_hash Optional[str] Hash of the metadata file for change detection instance
pdf_hash Optional[str] Hash of the PDF file if present instance
pagedata_hash Optional[str] Hash of the pagedata file containing page-specific information instance
rm_hashes List[str] List of hashes for .rm files (reMarkable drawing format) instance
metadata Dict[str, Any] Dictionary containing metadata from the reMarkable device instance
local_path str Local file system path where this node's files are stored instance
extracted_files List[str] List of file paths that have been extracted locally for this node instance

Required Imports

from dataclasses import dataclass
from typing import Dict, List, Optional, Any

Usage Example

from dataclasses import dataclass
from typing import Dict, List, Optional, Any

@dataclass
class RemarkableNode:
    uuid: str
    hash: str
    name: str
    node_type: str
    parent_uuid: Optional[str]
    content_hash: Optional[str] = None
    metadata_hash: Optional[str] = None
    pdf_hash: Optional[str] = None
    pagedata_hash: Optional[str] = None
    rm_hashes: List[str] = None
    metadata: Dict[str, Any] = None
    local_path: str = ""
    extracted_files: List[str] = None
    
    def __post_init__(self):
        if self.rm_hashes is None:
            self.rm_hashes = []
        if self.metadata is None:
            self.metadata = {}
        if self.extracted_files is None:
            self.extracted_files = []

# Create a folder node
folder = RemarkableNode(
    uuid="abc-123",
    hash="hash123",
    name="My Folder",
    node_type="folder",
    parent_uuid=None
)

# Create a document node with metadata
document = RemarkableNode(
    uuid="def-456",
    hash="hash456",
    name="My Document",
    node_type="document",
    parent_uuid="abc-123",
    content_hash="content_hash_123",
    metadata_hash="meta_hash_123",
    pdf_hash="pdf_hash_123",
    metadata={"lastModified": "1234567890", "version": 1}
)

# Access attributes
print(document.name)  # "My Document"
print(document.rm_hashes)  # []
print(document.metadata)  # {"lastModified": "1234567890", "version": 1}

# Update local path after extraction
document.local_path = "/path/to/local/file"
document.extracted_files = ["/path/to/local/file.pdf", "/path/to/local/file.rm"]

Best Practices

  • Always specify uuid, hash, name, node_type, and parent_uuid when creating instances as these are required fields.
  • Use node_type='folder' for directories and node_type='document' for files to ensure proper processing.
  • The __post_init__ method automatically initializes mutable defaults (rm_hashes, metadata, extracted_files) to prevent shared state between instances.
  • Set local_path and extracted_files during the extraction/download phase (phase 2) after the node has been created.
  • Use the hash fields (content_hash, metadata_hash, pdf_hash, pagedata_hash) to detect changes and avoid unnecessary re-downloads.
  • The metadata dictionary should contain raw metadata from the reMarkable device for reference and debugging.
  • Parent-child relationships are maintained through parent_uuid, allowing tree structure reconstruction.
  • This is a pure data class with no methods beyond __post_init__, so it's safe to serialize/deserialize using dataclasses.asdict().

Related Versions

Other versions of this component:

  • RemarkableNode_v1

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/sync_replica_new.py | Maturity: N/A

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class RemarkableNode 91.7% 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 ReplicaNode 83.2% 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 NodeType 69.9% similar

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

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

    A class that synchronizes reMarkable cloud documents to a local replica directory, downloading and organizing folders and documents in a hierarchical structure.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/sync_replica_new.py
← Back to Browse