INNER CODE UNIT · Python

_top_level_value

christopherkarani/Wax · Resources/hermes/wax-memory-plugin/cli.py:136

def _top_level_value(text: str, key: str) -> Optional[str]:
    lines = _without_yaml_comments(text).splitlines()
    for index, line in enumerate(lines):
        if not line.strip() or line != line.lstrip():
            continue
        pair = _mapping_pair(line)
        if not pair or pair[0] != key:
            continue
        if pair[1]:
            return pair[1]
        nested = []
        for later in lines[index + 1:]:
            if later.strip() and later == later.lstrip():
                break
            nested.append(later)
        return "\n".join(nested)
    return None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…