CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-gntp

tessl install tessl/pypi-gntp@1.0.0

Growl Notification Transport Protocol for Python

Agent Success

Agent success rate when using this tile

80%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.25x

Baseline

Agent success rate without this tile

64%

task.mdevals/scenario-10/

GNTP Message Parser

Build a utility that parses raw GNTP protocol messages and extracts key information from them.

Requirements

Your task is to implement a message parser that can:

  1. Parse incoming GNTP protocol messages from raw string format
  2. Extract and return the message type (e.g., REGISTER, NOTICE, SUBSCRIBE, OK, ERROR)
  3. Extract all headers from the message as a dictionary
  4. Handle binary resource sections if present in the message
  5. Validate that the message follows proper GNTP protocol format

The parser should accept a raw GNTP message string and return a structured representation containing:

  • The message type
  • A dictionary of all headers
  • Any binary resources (if present)

Implementation

@generates

API

def parse_gntp_message(raw_message: str) -> dict:
    """
    Parse a raw GNTP protocol message.

    Args:
        raw_message: Raw GNTP message string

    Returns:
        Dictionary containing:
        - 'message_type': str (e.g., 'REGISTER', 'NOTICE', 'OK', 'ERROR')
        - 'headers': dict of header key-value pairs
        - 'resources': list of binary resources (if any)

    Raises:
        ValueError: If the message format is invalid
    """
    pass

Test Cases

  • Parsing a valid GNTP REGISTER message returns correct message type and headers @test
  • Parsing a valid GNTP NOTICE message returns correct message type and headers @test
  • Parsing a GNTP OK response returns message type 'OK' with appropriate headers @test
  • Parsing an invalid message raises ValueError @test

Dependencies { .dependencies }

gntp { .dependency }

Provides GNTP protocol implementation for parsing messages.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/gntp@1.0.x
tile.json