🔍 Code Extractor

class ReplicaNode

Maturity: 50

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

File:
/tf/active/vicechatdev/e-ink-llm/cloudtest/local_replica.py
Lines:
41 - 90
Complexity:
moderate

Purpose

ReplicaNode serves as a data structure to track and manage individual items (documents, folders, notebooks) in a local replica of reMarkable cloud storage. It stores hierarchical information, file metadata, synchronization state, and component hashes for change detection. This class is used to maintain a complete representation of the reMarkable file system locally, enabling efficient sync operations and metadata tracking.

Source Code

class ReplicaNode:
    """Enhanced node for local replica with all metadata"""
    # Core identification
    uuid: str
    hash: str
    name: str
    node_type: str
    
    # Hierarchy
    parent_uuid: Optional[str]
    parent_path: str
    local_path: str
    depth: int
    
    # Metadata from reMarkable (using exact field names)
    createdTime: Optional[str] = None
    lastModified: Optional[str] = None
    lastOpened: Optional[str] = None
    lastOpenedPage: Optional[int] = None
    deleted: bool = False
    pinned: bool = False
    synced: bool = False
    version: int = 0
    source: Optional[str] = None
    metadatamodified: bool = False
    modified: bool = False
    parent: str = ""
    type: str = ""
    visibleName: str = ""
    
    # Component information
    content_hash: Optional[str] = None
    metadata_hash: Optional[str] = None
    pdf_hash: Optional[str] = None
    pagedata_hash: Optional[str] = None
    rm_files: List[str] = None
    
    # File information
    file_size: int = 0
    extracted_files: List[str] = None
    
    # Sync tracking
    sync_timestamp: str = ""
    sync_hash: str = ""
    
    def __post_init__(self):
        if self.rm_files is None:
            self.rm_files = []
        if self.extracted_files is None:
            self.extracted_files = []

Parameters

Name Type Default Kind
bases - -

Parameter Details

uuid: Unique identifier for the node, typically matching the reMarkable cloud UUID

hash: Hash value representing the current state of the node for change detection

name: Display name of the node (file or folder name)

node_type: Type of node (e.g., 'DocumentType', 'CollectionType')

parent_uuid: UUID of the parent node in the hierarchy, None for root-level items

parent_path: Full path to the parent node in the local replica structure

local_path: Full local filesystem path where this node's data is stored

depth: Depth level in the hierarchy tree (0 for root level)

createdTime: ISO timestamp when the item was created on reMarkable

lastModified: ISO timestamp when the item was last modified on reMarkable

lastOpened: ISO timestamp when the item was last opened on reMarkable

lastOpenedPage: Page number that was last opened for documents

deleted: Boolean flag indicating if the item is marked as deleted

pinned: Boolean flag indicating if the item is pinned in reMarkable UI

synced: Boolean flag indicating if the item has been synced

version: Version number of the item metadata

source: Source of the document (e.g., email, upload method)

metadatamodified: Boolean flag indicating if metadata has been modified

modified: Boolean flag indicating if content has been modified

parent: Parent UUID as stored in reMarkable metadata (duplicate of parent_uuid)

type: Type as stored in reMarkable metadata (duplicate of node_type)

visibleName: Visible name as stored in reMarkable metadata (duplicate of name)

content_hash: Hash of the content file for change detection

metadata_hash: Hash of the metadata file for change detection

pdf_hash: Hash of the PDF file if present

pagedata_hash: Hash of the pagedata file for notebooks

rm_files: List of reMarkable file extensions present (.content, .metadata, .pdf, etc.)

file_size: Total size in bytes of all files associated with this node

extracted_files: List of files extracted from the node's data

sync_timestamp: ISO timestamp of the last synchronization

sync_hash: Hash value at the time of last synchronization

Return Value

Instantiation returns a ReplicaNode object containing all metadata for a single item in the reMarkable replica. The object is immutable after creation (dataclass with frozen=False by default) and can be serialized to dict using dataclasses.asdict().

Class Interface

Methods

__post_init__(self) -> None

Purpose: Initializes mutable default values for rm_files and extracted_files lists after dataclass initialization

Returns: None - modifies instance attributes in place

Attributes

Name Type Description Scope
uuid str Unique identifier for the node matching reMarkable cloud UUID instance
hash str Hash value representing current state for change detection instance
name str Display name of the node instance
node_type str Type of node (DocumentType, CollectionType, etc.) instance
parent_uuid Optional[str] UUID of parent node, None for root-level items instance
parent_path str Full path to parent node in local replica instance
local_path str Full local filesystem path for this node's data instance
depth int Depth level in hierarchy tree (0 for root) instance
createdTime Optional[str] ISO timestamp of creation on reMarkable instance
lastModified Optional[str] ISO timestamp of last modification on reMarkable instance
lastOpened Optional[str] ISO timestamp of last opening on reMarkable instance
lastOpenedPage Optional[int] Page number last opened for documents instance
deleted bool Flag indicating if item is marked as deleted instance
pinned bool Flag indicating if item is pinned in reMarkable UI instance
synced bool Flag indicating if item has been synced instance
version int Version number of item metadata instance
source Optional[str] Source of document (email, upload method, etc.) instance
metadatamodified bool Flag indicating if metadata has been modified instance
modified bool Flag indicating if content has been modified instance
parent str Parent UUID as stored in reMarkable metadata (duplicate field) instance
type str Type as stored in reMarkable metadata (duplicate field) instance
visibleName str Visible name as stored in reMarkable metadata (duplicate field) instance
content_hash Optional[str] Hash of content file for change detection instance
metadata_hash Optional[str] Hash of metadata file for change detection instance
pdf_hash Optional[str] Hash of PDF file if present instance
pagedata_hash Optional[str] Hash of pagedata file for notebooks instance
rm_files List[str] List of reMarkable file extensions present (.content, .metadata, etc.) instance
file_size int Total size in bytes of all associated files instance
extracted_files List[str] List of files extracted from node's data instance
sync_timestamp str ISO timestamp of last synchronization instance
sync_hash str Hash value at time of last synchronization instance

Dependencies

  • dataclasses

Required Imports

from dataclasses import dataclass
from typing import Optional, List

Usage Example

from dataclasses import dataclass
from typing import Optional, List

@dataclass
class ReplicaNode:
    uuid: str
    hash: str
    name: str
    node_type: str
    parent_uuid: Optional[str]
    parent_path: str
    local_path: str
    depth: int
    createdTime: Optional[str] = None
    lastModified: Optional[str] = None
    deleted: bool = False
    rm_files: List[str] = None
    extracted_files: List[str] = None
    
    def __post_init__(self):
        if self.rm_files is None:
            self.rm_files = []
        if self.extracted_files is None:
            self.extracted_files = []

# Create a new replica node for a document
node = ReplicaNode(
    uuid='abc123-def456',
    hash='hash_value_123',
    name='My Document',
    node_type='DocumentType',
    parent_uuid='parent_uuid_789',
    parent_path='/root/folder',
    local_path='/local/replica/abc123-def456',
    depth=2,
    createdTime='2024-01-15T10:30:00Z',
    lastModified='2024-01-16T14:20:00Z',
    deleted=False,
    rm_files=['.content', '.metadata', '.pdf']
)

# Access node properties
print(f"Node: {node.name} at {node.local_path}")
print(f"Files: {node.rm_files}")
print(f"Modified: {node.lastModified}")

# Convert to dictionary for serialization
from dataclasses import asdict
node_dict = asdict(node)

Best Practices

  • Always instantiate with all required parameters (uuid, hash, name, node_type, parent_uuid, parent_path, local_path, depth)
  • The __post_init__ method automatically initializes rm_files and extracted_files to empty lists if None is passed
  • Use dataclasses.asdict() to convert the node to a dictionary for JSON serialization
  • The class maintains duplicate fields (parent/parent_uuid, type/node_type, visibleName/name) to match reMarkable's metadata format exactly
  • Hash fields (hash, content_hash, metadata_hash, pdf_hash, pagedata_hash, sync_hash) should be computed using consistent hashing algorithms for change detection
  • Timestamps (createdTime, lastModified, lastOpened, sync_timestamp) should use ISO 8601 format for consistency
  • The depth field should be calculated based on the node's position in the hierarchy tree
  • rm_files list should contain file extensions present for this node (e.g., ['.content', '.metadata', '.pdf'])
  • This is an immutable-style dataclass; create new instances rather than modifying existing ones for state changes
  • The class is designed for use in sync operations, so sync_timestamp and sync_hash should be updated after successful synchronization

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class RemarkableNode_v1 83.4% 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 RemarkableNode_v1 83.2% 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 80.4% 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 RemarkableReplicaSync 74.6% 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
  • class RemarkableLocalReplica 65.4% similar

    Builds and maintains a complete local replica of reMarkable cloud

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