Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AIScientists Dev WorldSeed dsl functions helpers

From Leeroopedia
Knowledge Sources
Domains DSL, Query
Last Updated 2026-10-26 18:00 GMT

Overview

Concrete shared helpers for DSL functions — dot-path entity walking, numeric parsing, and argument splitting — provided by the WorldSeed library.

Description

The helpers module provides four pure utility functions used across DSL function modules: `walk_entity_path(obj, path)` walks a dot-separated path on any object (Entity, dict, or arbitrary), checking dict keys, Entity `__contains__`, and attribute access; `try_numeric(expr)` attempts to parse a string as int then float; `split_args(args_str)` splits function arguments at top-level commas, respecting nested parentheses; `parse_kwargs(args_str)` parses `key=value` pairs into a dict, stripping quotes. These are the foundation for all DSL function argument parsing and entity property access.

Usage

Import these helpers when implementing a new DSL function that needs to parse keyword arguments or walk entity property paths.

Code Reference

Source Location

  • Repository: WorldSeed
  • File: src/worldseed/dsl/functions/helpers.py

Signature

def walk_entity_path(obj: object, path: str) -> object:
    """Walk a dot-separated path on any object (Entity, dict, etc.)."""

def try_numeric(expr: str) -> int | float | None:
    """Try to parse a string as a number."""

def split_args(args_str: str) -> list[str]:
    """Split function arguments, respecting nested parens."""

def parse_kwargs(args_str: str) -> dict[str, str]:
    """Parse DSL function keyword arguments into a dict."""

Import

from worldseed.dsl.functions.helpers import walk_entity_path, try_numeric, split_args, parse_kwargs

I/O Contract

Inputs

Name Type Required Description
obj object Yes (walk) Entity, dict, or any object to traverse
path str Yes (walk) Dot-separated property path
args_str str Yes (split/parse) Raw argument string from DSL expression
expr str Yes (try_numeric) String to attempt numeric parse

Outputs

Name Type Description
walk_entity_path returns None Value at path, or None if not found
try_numeric returns float \| None Parsed number or None
split_args returns list[str] Top-level comma-separated parts
parse_kwargs returns dict[str, str] Key-value pairs

Usage Examples

from worldseed.dsl.functions.helpers import walk_entity_path, parse_kwargs

# Walk a nested property on an entity
val = walk_entity_path(entity, "location.room")
# entity.data["location"]["room"] → "hallway"

# Parse DSL function arguments
kw = parse_kwargs("type='agent', where='alive == true'")
# kw = {"type": "agent", "where": "alive == true"}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment