class RemarkableNode_v1
A dataclass representing a node (file or folder) in the reMarkable tablet's file system hierarchy, storing metadata, hashes, and local file paths.
/tf/active/vicechatdev/e-ink-llm/cloudtest/sync_replica_new.py
29 - 57
simple
Purpose
RemarkableNode serves as a data structure to represent both folders and documents in the reMarkable tablet's file system. It stores unique identifiers, content hashes for various file components (.content, .metadata, .pdf, .pagedata, .rm files), parent-child relationships, and local file system paths. This class is designed to match the structure used in local_replica_v2.py and facilitates synchronization between the reMarkable device and local storage by tracking file states through hash values.
Source Code
class RemarkableNode:
"""Simple node representation matching local_replica_v2.py"""
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 this node in the reMarkable file system. This is the primary key used to identify files and folders.
hash: Overall hash value representing the current state of this node. Used for change detection and synchronization.
name: Display name of the file or folder as shown in the reMarkable interface.
node_type: Type of node, either 'folder' for directories or 'document' for files. Determines how the node is processed.
parent_uuid: UUID of the parent folder containing this node. None for root-level items.
content_hash: Hash of the .content file which contains structural information about the document. Optional, only present for documents.
metadata_hash: Hash of the .metadata file containing document metadata like creation time, modification time, etc. Optional.
pdf_hash: Hash of the .pdf file if the document is a PDF. Optional, only present for PDF documents.
pagedata_hash: Hash of the .pagedata file containing page-specific data. Optional.
rm_hashes: List of hashes for .rm files (one per page) containing the actual drawing/annotation data. Defaults to empty list.
metadata: Dictionary containing parsed metadata from the reMarkable device, such as timestamps, version info, etc. Defaults to empty dict.
local_path: File system path where this node's files are stored locally. Set during phase 2 of processing. Defaults to empty string.
extracted_files: List of file paths that have been extracted/downloaded for this node. Defaults to empty list.
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 mutable default issues
Returns: None - modifies instance attributes in place
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
uuid |
str | Unique identifier for this node in the reMarkable file system | instance |
hash |
str | Overall hash value representing the current state of this node | instance |
name |
str | Display name of the file or folder | instance |
node_type |
str | Type of 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 containing document structure | instance |
metadata_hash |
Optional[str] | Hash of the .metadata file containing document metadata | instance |
pdf_hash |
Optional[str] | Hash of the .pdf file for PDF documents | instance |
pagedata_hash |
Optional[str] | Hash of the .pagedata file containing page-specific data | instance |
rm_hashes |
List[str] | List of hashes for .rm files (one per page) containing drawing/annotation data | instance |
metadata |
Dict[str, Any] | Dictionary containing parsed metadata from the reMarkable device | instance |
local_path |
str | File system path where this node's files are stored locally | instance |
extracted_files |
List[str] | List of file paths that have been extracted/downloaded for this node | instance |
Required Imports
from dataclasses import dataclass
from typing import Dict, Any, Optional, List
Usage Example
from dataclasses import dataclass
from typing import Dict, Any, Optional, List
@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="abc123",
hash="hash123",
name="My Folder",
node_type="folder",
parent_uuid=None
)
# Create a document node with full metadata
document = RemarkableNode(
uuid="def456",
hash="hash456",
name="My Document",
node_type="document",
parent_uuid="abc123",
content_hash="content_hash_123",
metadata_hash="metadata_hash_123",
pdf_hash="pdf_hash_123",
rm_hashes=["page1_hash", "page2_hash"],
metadata={"lastModified": "1234567890", "version": 1}
)
# Access attributes
print(document.name)
print(document.node_type)
print(len(document.rm_hashes))
# Update local path after extraction
document.local_path = "/path/to/local/storage/def456"
document.extracted_files = ["/path/to/local/storage/def456.pdf", "/path/to/local/storage/def456.content"]
Best Practices
- Always provide required parameters (uuid, hash, name, node_type, parent_uuid) when instantiating a RemarkableNode.
- Use None for parent_uuid when creating root-level nodes.
- Set node_type to either 'folder' or 'document' - no other values should be used.
- The __post_init__ method automatically initializes mutable defaults, so you can safely omit rm_hashes, metadata, and extracted_files parameters.
- Update local_path only after files have been extracted to the local file system (phase 2 processing).
- Use rm_hashes list to track individual page hashes for multi-page documents.
- Store parsed metadata from the reMarkable device in the metadata dictionary for easy access.
- Hash values (content_hash, metadata_hash, pdf_hash, pagedata_hash) should be computed using a consistent hashing algorithm (likely SHA256 based on context).
- This is an immutable-style dataclass - consider creating new instances rather than modifying existing ones for better tracking of changes.
- The uuid field serves as the primary identifier and should be unique across all nodes in the file system.
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class RemarkableNode 91.6% similar
-
class ReplicaNode 83.4% similar
-
class NodeType 67.5% similar
-
class RemarkableReplicaSync 63.9% similar