🔍 Code Extractor

class RemarkableNode

Maturity: 53

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

File:
/tf/active/vicechatdev/e-ink-llm/cloudtest/discovery.py
Lines:
38 - 60
Complexity:
simple

Purpose

This dataclass serves as a data structure to represent files and folders in the reMarkable cloud ecosystem. It stores essential metadata like name, type, parent relationships, timestamps, and document-specific component hashes (content, metadata, pagedata, PDF). It supports hierarchical organization through parent-child relationships and can represent both folders (collections) and documents. The class is designed to facilitate tree-like navigation and manipulation of reMarkable cloud content.

Source Code

class RemarkableNode:
    """Represents a node (file/folder) in reMarkable cloud"""
    hash: str
    name: str
    parent: Optional[str]
    node_type: NodeType
    
    # Optional metadata
    size: int = 0
    depth: int = 0
    local_path: str = ""
    created_time: Optional[str] = None
    last_modified: Optional[str] = None
    source: Optional[str] = None
    
    # Component hashes for documents
    content_hash: Optional[str] = None
    metadata_hash: Optional[str] = None
    pagedata_hash: Optional[str] = None
    pdf_hash: Optional[str] = None
    
    # Children for hierarchy
    children: List['RemarkableNode'] = field(default_factory=list)

Parameters

Name Type Default Kind
bases - -

Parameter Details

hash: Unique identifier for the node in the reMarkable cloud system. This is the primary key used to reference the node.

name: Display name of the file or folder as shown in the reMarkable interface.

parent: Hash of the parent node. None if this is a root-level node. Used to establish hierarchical relationships.

node_type: Enum value (NodeType) indicating whether this is a file or folder/collection.

size: Size of the node in bytes. Defaults to 0. Primarily relevant for files/documents.

depth: Depth level in the hierarchy tree, with 0 being root level. Defaults to 0.

local_path: Local filesystem path where the node's data is stored or cached. Empty string by default.

created_time: ISO format timestamp string indicating when the node was created. Optional.

last_modified: ISO format timestamp string indicating when the node was last modified. Optional.

source: Origin or source information for the node. Optional metadata field.

content_hash: Hash of the content component for documents. Used to identify and retrieve document content. Optional.

metadata_hash: Hash of the metadata component for documents. Used to identify and retrieve document metadata. Optional.

pagedata_hash: Hash of the pagedata component for documents. Used to identify and retrieve page-specific data. Optional.

pdf_hash: Hash of the PDF component for documents. Used to identify and retrieve the PDF version. Optional.

children: List of child RemarkableNode objects. Used to build hierarchical tree structures. Defaults to empty list.

Return Value

Instantiation returns a RemarkableNode object representing a single node in the reMarkable cloud hierarchy. As a dataclass, it automatically provides __init__, __repr__, __eq__, and other standard methods. The object can be used to navigate hierarchies through the parent and children attributes, and to access all metadata and component hashes associated with the node.

Class Interface

Methods

__init__(hash: str, name: str, parent: Optional[str], node_type: NodeType, size: int = 0, depth: int = 0, local_path: str = '', created_time: Optional[str] = None, last_modified: Optional[str] = None, source: Optional[str] = None, content_hash: Optional[str] = None, metadata_hash: Optional[str] = None, pagedata_hash: Optional[str] = None, pdf_hash: Optional[str] = None, children: List['RemarkableNode'] = None) -> None

Purpose: Initializes a new RemarkableNode instance with the provided attributes. Automatically generated by @dataclass decorator.

Parameters:

  • hash: Unique identifier for the node
  • name: Display name of the node
  • parent: Hash of parent node or None for root
  • node_type: NodeType enum indicating file or folder
  • size: Size in bytes (default 0)
  • depth: Hierarchy depth level (default 0)
  • local_path: Local filesystem path (default empty string)
  • created_time: Creation timestamp (default None)
  • last_modified: Last modification timestamp (default None)
  • source: Source information (default None)
  • content_hash: Content component hash (default None)
  • metadata_hash: Metadata component hash (default None)
  • pagedata_hash: Pagedata component hash (default None)
  • pdf_hash: PDF component hash (default None)
  • children: List of child nodes (default empty list)

Returns: None - constructor initializes the instance

__repr__() -> str

Purpose: Returns a string representation of the RemarkableNode instance showing all attributes. Automatically generated by @dataclass decorator.

Returns: String representation of the object in the format 'RemarkableNode(hash=..., name=..., ...)'

__eq__(other: object) -> bool

Purpose: Compares two RemarkableNode instances for equality based on all attributes. Automatically generated by @dataclass decorator.

Parameters:

  • other: Another object to compare with

Returns: True if all attributes are equal, False otherwise

Attributes

Name Type Description Scope
hash str Unique identifier for the node in the reMarkable cloud system instance
name str Display name of the file or folder instance
parent Optional[str] Hash of the parent node, None for root-level nodes instance
node_type NodeType Enum value indicating whether this is a file or folder instance
size int Size of the node in bytes, defaults to 0 instance
depth int Depth level in the hierarchy tree, 0 for root level instance
local_path str Local filesystem path where node data is stored or cached instance
created_time Optional[str] ISO format timestamp string of when the node was created instance
last_modified Optional[str] ISO format timestamp string of when the node was last modified instance
source Optional[str] Origin or source information for the node instance
content_hash Optional[str] Hash of the content component for documents instance
metadata_hash Optional[str] Hash of the metadata component for documents instance
pagedata_hash Optional[str] Hash of the pagedata component for documents instance
pdf_hash Optional[str] Hash of the PDF component for documents instance
children List[RemarkableNode] List of child RemarkableNode objects for building hierarchical tree structures instance

Dependencies

  • dataclasses
  • typing

Required Imports

from dataclasses import dataclass, field
from typing import List, Optional

Usage Example

from dataclasses import dataclass, field
from typing import List, Optional
from enum import Enum

class NodeType(Enum):
    FOLDER = 'CollectionType'
    DOCUMENT = 'DocumentType'

@dataclass
class RemarkableNode:
    hash: str
    name: str
    parent: Optional[str]
    node_type: NodeType
    size: int = 0
    depth: int = 0
    local_path: str = ''
    created_time: Optional[str] = None
    last_modified: Optional[str] = None
    source: Optional[str] = None
    content_hash: Optional[str] = None
    metadata_hash: Optional[str] = None
    pagedata_hash: Optional[str] = None
    pdf_hash: Optional[str] = None
    children: List['RemarkableNode'] = field(default_factory=list)

# Create a folder node
folder = RemarkableNode(
    hash='abc123',
    name='My Notebooks',
    parent=None,
    node_type=NodeType.FOLDER,
    depth=0
)

# Create a document node
document = RemarkableNode(
    hash='def456',
    name='Meeting Notes',
    parent='abc123',
    node_type=NodeType.DOCUMENT,
    size=1024,
    depth=1,
    content_hash='content123',
    metadata_hash='meta456',
    created_time='2023-01-15T10:30:00Z'
)

# Build hierarchy
folder.children.append(document)

# Access attributes
print(f'Document: {document.name}')
print(f'Parent: {document.parent}')
print(f'Has content: {document.content_hash is not None}')

Best Practices

  • Always provide required fields (hash, name, parent, node_type) when instantiating
  • Use None for parent when creating root-level nodes
  • Maintain consistency between parent hash and actual parent node relationships
  • Use the children list to build tree structures by appending child nodes
  • Set depth appropriately when building hierarchies (root=0, increment for each level)
  • For documents, populate component hashes (content_hash, metadata_hash, etc.) to enable content retrieval
  • Use NodeType enum values consistently to distinguish between folders and documents
  • Keep timestamps in ISO format for consistency
  • The dataclass is immutable by default unless frozen=False is specified; be aware of mutability when modifying children lists
  • When traversing hierarchies, check node_type to determine if a node can have children
  • Use local_path to track where node data is cached locally for offline access

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class RemarkableNode_v1 91.7% 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 91.6% 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 80.4% 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 71.5% 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 RemarkableDiscovery 66.6% similar

    Handles hierarchical discovery of reMarkable cloud content

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