INNER CODE UNIT · Python

table_body

torognes/vsearch · completion/scripts/extract_cli_options.py:33

def table_body(text: str, anchor: str, path: str) -> str:
    """The text between anchor's opening '{{' and its closing '},};'."""
    start = text.find(anchor)
    if start < 0:
        sys.exit(f'{path}: no {anchor.rstrip(" =")} table found. The table was '
                 'renamed or removed; this script needs updating.')
    opening = text.find('{{', start)
    closing = text.find('},};', opening)
    if opening < 0 or closing < 0:
        sys.exit(f'{path}: could not delimit the {anchor.rstrip(" =")} table. '
                 'It no longer opens with "{{" and closes with "},};"; this '
                 'script needs updating.')
    return text[opening + 2:closing]


def extract(path: str) -> dict:
    with open(path, encoding='utf-8') as handle:
        text = strip_comments(handle.read())

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…