How to use the poetry.toml.prettify.parser.recdesc.capture_from function in poetry

To help you get started, we’ve selected a few poetry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def two(ts2):
        c = (
            capture_from(ts2)
            .find(value)
            .and_find(space_element)
            .and_find(punctuation_element(TYPE_OP_COMMA))
            .and_find(space_element)
            .and_find(array_internal)
        )
        return c.value(), c.pending_tokens
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def space_element(token_stream):
    captured = capture_from(token_stream).find(zero_or_more_tokens(TYPE_WHITESPACE))
    return (
        WhitespaceElement([t for t in captured.value() if t]),
        captured.pending_tokens,
    )
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def one(ts1):
        c = capture_from(ts1).find(key_value_pair).and_find(table_body_elements)
        return c.value(), c.pending_tokens
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def value(token_stream):
    captured = (
        capture_from(token_stream)
        .find(atomic_element)
        .or_find(array_element)
        .or_find(inline_table_element)
    )
    return (
        captured.value("Expected a primitive value, array or an inline table"),
        captured.pending_tokens,
    )
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def key_value(ts):
        ca = (
            capture_from(ts)
            .find(string_element)
            .and_find(space_element)
            .and_find(punctuation_element(TYPE_OP_ASSIGNMENT))
            .and_find(space_element)
            .and_find(value)
        )
        return ca.value(), ca.pending_tokens
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def line_terminator_tokens(token_stream):
    captured = (
        capture_from(token_stream).find(comment_tokens).or_find(token(TYPE_NEWLINE))
    )
    return captured.value(), captured.pending_tokens
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def zero(ts0):
        c = (
            capture_from(ts0)
            .and_find(line_terminator_element)
            .and_find(space_element)
            .and_find(array_internal)
        )
        return c.value(), c.pending_tokens
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def more(ts):
            c = (
                capture_from(ts)
                .find(token(token_type))
                .and_find(zero_or_more_tokens(token_type))
            )
            return c.value(), c.pending_tokens

        def two(ts):
            c = capture_from(ts).find(token(TYPE_WHITESPACE))
            return c.value(), c.pending

        def zero(ts):
            return tuple(), ts

        captured = capture_from(token_stream).find(more).or_find(two).or_find(zero)
        return captured.value(), captured.pending_tokens
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
c = (
            capture_from(ts2)
            .find(value)
            .and_find(space_element)
            .and_find(punctuation_element(TYPE_OP_COMMA))
            .and_find(space_element)
            .and_find(array_internal)
        )
        return c.value(), c.pending_tokens

    def three(ts3):
        c = capture_from(ts3).find(space_element).and_find(line_terminator_element)
        return c.value(), c.pending_tokens

    captured = (
        capture_from(ts)
        .find(zero)
        .or_find(one)
        .or_find(two)
        .or_find(three)
        .or_find(value)
        .or_empty()
    )
    return captured.value(), captured.pending_tokens
github python-poetry / poetry / poetry / toml / prettify / parser / parser.py View on Github external
def single(ts1):
        c1 = (
            capture_from(ts1)
            .find(zero_or_more_tokens(TYPE_WHITESPACE))
            .and_find(token(TYPE_OP_SQUARE_LEFT_BRACKET))
            .and_find(zero_or_more_tokens(TYPE_WHITESPACE))
            .and_find(table_header_name_tokens)
            .and_find(zero_or_more_tokens(TYPE_WHITESPACE))
            .and_find(token(TYPE_OP_SQUARE_RIGHT_BRACKET))
            .and_find(zero_or_more_tokens(TYPE_WHITESPACE))
            .and_find(line_terminator_tokens)
        )

        return c1.value(), c1.pending_tokens