šŸ” Code Extractor

function show_current_root

Maturity: 34

Fetches and displays the current root.docSchema from the reMarkable cloud sync service, showing metadata and analyzing document entries.

File:
/tf/active/vicechatdev/e-ink-llm/cloudtest/show_current_root.py
Lines:
8 - 80
Complexity:
moderate

Purpose

This function authenticates with the reMarkable cloud API, retrieves the current root document schema (which contains the file system structure), and provides a detailed analysis including the root hash, generation number, schema version, and a breakdown of all entries by type (folders, PDFs, notebooks). It's useful for debugging, understanding the reMarkable cloud storage structure, or auditing the current state of a user's documents.

Source Code

def show_current_root():
    print("šŸ“‹ Fetching Current Root.docSchema")
    print("=" * 50)
    
    # Authenticate
    auth = RemarkableAuth()
    session = auth.get_authenticated_session()
    
    if not session:
        print("āŒ Authentication failed")
        return
    
    try:
        # Get current root info
        print("šŸ” Step 1: Getting root info...")
        root_response = session.get("https://eu.tectonic.remarkable.com/sync/v4/root")
        root_response.raise_for_status()
        root_data = root_response.json()
        
        print(f"āœ… Root hash: {root_data['hash']}")
        print(f"āœ… Generation: {root_data.get('generation')}")
        print(f"āœ… Schema version: {root_data.get('schemaVersion')}")
        
        # Get root.docSchema content
        print(f"\nšŸ” Step 2: Fetching root.docSchema content...")
        root_content_response = session.get(f"https://eu.tectonic.remarkable.com/sync/v3/files/{root_data['hash']}")
        root_content_response.raise_for_status()
        root_content = root_content_response.text
        
        print(f"āœ… Content size: {len(root_content)} bytes")
        
        # Display content with line numbers
        print(f"\nšŸ“„ Current Root.docSchema Content:")
        print("-" * 100)
        lines = root_content.strip().split('\n')
        for i, line in enumerate(lines):
            print(f"Line {i:2d}: {line}")
        print("-" * 100)
        
        # Analyze entries
        print(f"\nšŸ“Š Analysis:")
        if len(lines) > 0:
            version = lines[0]
            entries = lines[1:] if len(lines) > 1 else []
            
            print(f"   Version: {version}")
            print(f"   Total entries: {len(entries)}")
            
            # Categorize entries
            types = {}
            for entry in entries:
                if ':' in entry:
                    parts = entry.split(':')
                    if len(parts) >= 4:
                        entry_type = parts[3]
                        if entry_type not in types:
                            types[entry_type] = 0
                        types[entry_type] += 1
            
            print(f"   Entry types:")
            for entry_type, count in types.items():
                type_name = {
                    '1': 'Unknown/Special',
                    '2': 'Folder', 
                    '4': 'PDF Document',
                    '5': 'Notebook'
                }.get(entry_type, f'Type {entry_type}')
                print(f"      Type {entry_type} ({type_name}): {count}")
        else:
            print("   āŒ Empty or invalid root.docSchema")
        
    except Exception as e:
        print(f"āŒ Error: {e}")

Return Value

This function returns None. It outputs all information directly to stdout via print statements, including authentication status, root metadata (hash, generation, schema version), the complete root.docSchema content with line numbers, and statistical analysis of entry types.

Dependencies

  • requests
  • auth

Required Imports

from auth import RemarkableAuth

Usage Example

from auth import RemarkableAuth

def show_current_root():
    # ... function code ...
    pass

# Simply call the function to display current root schema
show_current_root()

# Output will be printed to console showing:
# - Authentication status
# - Root hash and metadata
# - Complete root.docSchema content
# - Analysis of document types and counts

Best Practices

  • Ensure RemarkableAuth is properly configured before calling this function
  • This function makes network requests and may take time depending on connection speed
  • The function prints directly to stdout; redirect output if you need to capture it programmatically
  • Handle potential network failures gracefully - the function catches exceptions but may still fail on network issues
  • The API endpoint is hardcoded to 'eu.tectonic.remarkable.com' - may need modification for other regions
  • This is a read-only operation and does not modify any data on the reMarkable cloud
  • Consider rate limiting if calling this function repeatedly to avoid API throttling

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class RootCleaner 72.8% similar

    A class that completely clears the reMarkable cloud's root.docSchema file, removing all document references while maintaining the proper file structure and version.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/clear_root_docschema.py
  • function test_root_finding 70.8% similar

    A test function that analyzes a reMarkable tablet replica database JSON file to identify and list all root-level entries (folders and documents without parent nodes).

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/debug_root.py
  • class RootDocSchemaRepair 70.0% similar

    A repair tool for fixing corrupted root.docSchema entries in reMarkable cloud storage by recalculating document sizes and rebuilding the schema.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/fix_root_docschema.py
  • function verify_document_status 67.7% similar

    Verifies the current status and metadata of a specific test document in the reMarkable cloud sync system by querying the sync API endpoints and analyzing the document's location and properties.

    From: /tf/active/vicechatdev/e-ink-llm/cloudtest/verify_document_status.py
  • function main_v23 66.5% similar

    Clears all document references from the reMarkable Cloud root.docSchema, making the cloud interface appear completely empty while preserving the actual documents.

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