Skip to content

Latest commit

 

History

History
336 lines (219 loc) · 8.15 KB

File metadata and controls

336 lines (219 loc) · 8.15 KB

description: A representation of a path in the expression.

s2t.Path

View source on GitHub

A representation of a path in the expression.

s2t.Path(
    field_list: Sequence[s2t.Step]
)

Do not implement nonzero, eq, ne, et cetera as these are implicitly defined by cmp and len.

Args

`field_list` a list or tuple of fields leading from one node to another.

Raises

`ValueError` if any field is not a valid step (see is_valid_step).

Methods

as_proto

View source

as_proto()

Serialize a path as a proto.

This fails if there are any anonymous fields.

Returns
a Path proto.

concat

View source

concat(
    other_path: "Path"
) -> "Path"

get_child

View source

get_child(
    field_name: s2t.Step
) -> "Path"

Get the child path.

get_least_common_ancestor

View source

get_least_common_ancestor(
    other: "Path"
) -> "Path"

Get the least common ancestor, the longest shared prefix.

get_parent

View source

get_parent() -> "Path"

Get the parent path.

Returns
The parent path.
Raises
`ValueError` If this is the root path.

is_ancestor

View source

is_ancestor(
    other: "Path"
) -> bool

True if self is ancestor of other (i.e. a prefix).

prefix

View source

prefix(
    ending_index: int
) -> "Path"

suffix

View source

suffix(
    starting_index: int
) -> "Path"

__add__

View source

__add__(
    other: Union['Path', str]
) -> "Path"

__eq__

View source

__eq__(
    other: "Path"
) -> bool

Return self==value.

__ge__

View source

__ge__(
    other: "Path"
) -> bool

Return self>=value.

__gt__

View source

__gt__(
    other: "Path"
) -> bool

Return self>value.

__le__

View source

__le__(
    other: "Path"
) -> bool

Return self<=value.

__len__

View source

__len__() -> int

__lt__

View source

__lt__(
    other: "Path"
) -> bool

Return self<value.

__ne__

View source

__ne__(
    other: "Path"
) -> bool

Return self!=value.