EPICS Database

Functions and classes for parsing from template/db files using tree-sitter-epics.

class py_tree_sitter_epics.epicsdb.Database(*, documentation: str | None, records: list[Record])

Represents an EPICS database file.

Added in version 0.3.0.

documentation: str | None

Toplevel documentation of the datbase file.

The documentation is the first comment block prefixed by #|, for example:

#| This is
#| a database
#| toplevel documentation.

# ...

Added in version 0.3.0.

records: list[Record]

Records present in this database file.

Added in version 0.3.0.

class py_tree_sitter_epics.epicsdb.DbParser

To handle tree-sitter parsing.

Deprecated since version 0.3.0: Use parse_str() instead

build_records_list() list

From a tree-sitter node built a list of object ‘db’ class.

Deprecated since version 0.3.0: Use parse_str() and the Record.fields instead.

parse(text: str) None

Parse the text in argument to build the tree of the object.

Deprecated since version 0.3.0: Use parse_str() instead

exception py_tree_sitter_epics.epicsdb.DbParserError(message: str)

DbParser class exception.

Raised when parsing a .db file that tree-sitter-epics-db couldn’t parse.

Represents a Record Link.

Create a Link Class from a link field.

Returns:

The Link, or None on parse error.

Deprecated since version 0.3.0: Use parse() instead.

static parse(field: str) Link | None

Create a Link from the value of a “link” field.

Returns:

The Link, or None on parse error.

Added in version 0.3.0.

record_name: str

The name of the linked record.

Added in version 0.3.0.

The type of link.

Added in version 0.3.0.

class py_tree_sitter_epics.epicsdb.Record(*, type: str, name: str, documentation: str | None, fields: dict[str, str], infos: dict[str, str])

Represents an EPICS record.

property description: str | None

The documentation or description of the record.

Deprecated since version 0.3.0: Use documentation instead

documentation: str | None

The documentation of the record.

The documentation is obtained from adjacent comments before the record, or the DESC field, if none defined. For example:

# This is
# the record documentation
record(ai, "...") {
    # ...
}

Or:

record(ai, "...") {
    field(DESC, "This is the record documentation")
}

Added in version 0.3.0.

fields: dict[str, str]

The fields declared in this record.

infos: dict[str, str]

The info items declared in this record.

List the incoming links specified in this record.

List the outgoing links specified in this record.

name: str

The name of the record.

Added in version 0.3.0.

property record_name: str

The name of the record.

Deprecated since version 0.3.0: Use name instead

property record_type: str

The type of the record.

Deprecated since version 0.3.0: Use type instead

type: str

The type of the record, for example ai.

Added in version 0.3.0.

property unit: str | None

The unit of the record.

This is equivalent to fetching the EGU field.

py_tree_sitter_epics.epicsdb.parse_bytes(b: bytes) Database

Parse the given bytes in EPICS Database format.

Added in version 0.3.0.

py_tree_sitter_epics.epicsdb.parse_file(file: str | os.PathLike) Database

Parse the given .db file.

Added in version 0.3.0.

py_tree_sitter_epics.epicsdb.parse_str(s: str) Database

Parse the given string in EPICS Database format.

Added in version 0.3.0.