The field_writer.py module#

Summary#

check_field_type

write_field_c

write_field

write_c_dataframe

write_fields

Write fields representing a line of a keyword to buf.

write_comment_line

Writes the comment line to the buffer.

Module detail#

field_writer.check_field_type(field_type: type)#
field_writer.write_field_c(buf: IO[AnyStr], field_type: type, value: Any, width: int) None#
field_writer.write_field(buf: IO[AnyStr], field_type: type, value: Any, width: int) None#
field_writer.write_c_dataframe(buf: IO[AnyStr], fields: List[ansys.dyna.core.lib.field.Field], table: pandas.DataFrame, format: ansys.dyna.core.lib.format_type.format_type) None#
field_writer.write_fields(buf: IO[AnyStr], fields: List[ansys.dyna.core.lib.field.Field], values: List[Any] | None = None, format: ansys.dyna.core.lib.format_type.format_type | None = format_type.default) None#

Write fields representing a line of a keyword to buf.

Use the fixed column offsets and width

Parameters:
buf: IO

buffer to write to

fields: List

fields to write

values: List

optional - list of values for the field. If not set, use the value property of each field. used by TableCard

format: format_type

optional - format to write

>>> s=io.String()
>>> fields = [
… Field(“a”, int, 0, 10, 1),
… Field(“b”, str, 10, 10, “hello”)
… ]
>>> write_fields(s, fields)
>>> s.getvalue()
‘ 1 hello’
field_writer.write_comment_line(buf: IO[AnyStr], fields: List[ansys.dyna.core.lib.field.Field], format: ansys.dyna.core.lib.format_type.format_type | None = format_type.default) None#

Writes the comment line to the buffer.

Parameters:
buf: IO

buffer to write to

fields: List

fields to write

format: format_type

format to write in

>>> s=io.String()
>>> fields = [
… Field(“a”, int, 0, 10, 1),
… Field(“b”, str, 10, 10, “hello”)
… ]
>>> write_comment_line(s, fields)
>>> s.getvalue()
‘ a b’