pycsamt.jones.components#

Classes

JComponentMixin()

Lightweight facade to manage Jones (J-format) components on a host object.

class pycsamt.jones.components.JComponentMixin[source]#

Bases: object

Lightweight facade to manage Jones (J-format) components on a host object. The host is expected to expose a mapping-like container (self.sections or self.components). Keys are normalized to lowercase for stable lookups.

The mixin centralizes small CRUD helpers (cget/cset/chas/ cdrop/snapshot) and offers typed accessors for frequent J parts such as banner, info, head, heads, blocks, and derived data objects (z, tip, res).

It also provides compose_headers which serializes the header portion of a J file by calling write() on available components. If a combined heads component is present, it takes precedence over separate banner/head/info parts to avoid duplication.

cget(key, default=None)[source]#
Parameters:
Return type:

Any

cset(key, obj)[source]#
Parameters:
Return type:

None

chas(key)[source]#
Parameters:

key (str)

Return type:

bool

cdrop(key)[source]#
Parameters:

key (str)

Return type:

None

snapshot(keys=None)[source]#
Parameters:

keys (Iterable[str] | None)

Return type:

dict[str, Any]

get_banner()[source]#
Return type:

Any

set_banner(obj)[source]#
Parameters:

obj (Any)

Return type:

None

get_info()[source]#
Return type:

Any

set_info(obj)[source]#
Parameters:

obj (Any)

Return type:

None

get_head()[source]#
Return type:

Any

set_head(obj)[source]#
Parameters:

obj (Any)

Return type:

None

get_heads()[source]#
Return type:

Any

set_heads(obj)[source]#
Parameters:

obj (Any)

Return type:

None

get_blocks()[source]#
Return type:

Any

set_blocks(obj)[source]#
Parameters:

obj (Any)

Return type:

None

get_z()[source]#
Return type:

Any

set_z(obj)[source]#
Parameters:

obj (Any)

Return type:

None

get_tip()[source]#
Return type:

Any

set_tip(obj)[source]#
Parameters:

obj (Any)

Return type:

None

get_res()[source]#
Return type:

Any

set_res(obj)[source]#
Parameters:

obj (Any)

Return type:

None

compose_headers(*, prefer_heads=True, join=False)[source]#

Serialize header lines by querying available components. If prefer_heads is True and a heads component is present, it is used exclusively. Otherwise the mixin attempts banner + head + info in that order.

When join is True, returns a single string joined with newlines. Otherwise returns a list of lines.

Parameters:
Return type:

list[str] | str