mt_metadata.common.comment ========================== .. py:module:: mt_metadata.common.comment Classes ------- .. autoapisummary:: mt_metadata.common.comment.Comment Module Contents --------------- .. py:class:: Comment(**data) Bases: :py:obj:`mt_metadata.base.MetadataBase` Base class for all metadata objects with Pydantic validation. MetadataBase extends DotNotationBaseModel (which inherits from Pydantic's BaseModel) to provide automatic validation according to metadata standards. It adds functionality beyond dictionaries, supporting JSON, XML, pandas Series, and other formats for metadata interchange. .. attribute:: _skip_equals Private attribute listing fields to skip in equality comparisons :type: list[str] .. attribute:: _fields Private attribute caching field information :type: dict[str, Any] .. rubric:: Notes - All field assignments are validated automatically via Pydantic - None values are converted to appropriate defaults (empty string or 0.0) - Supports nested attribute access via dot notation - Thread-safe for read operations after initialization .. py:attribute:: author :type: Annotated[str | None, Field(default=None, description='person who authored the comment', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['J. Pedantic']})] .. py:attribute:: time_stamp :type: Annotated[float | int | numpy.datetime64 | pandas.Timestamp | str | mt_metadata.common.mttime.MTime | None, Field(default_factory=lambda: MTime(time_stamp='1980-01-01T00:00:00+00:00'), description='Date and time of in UTC of when comment was made.', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['2020-02-01T09:23:45.453670+00:00']})] .. py:attribute:: value :type: Annotated[str | list | None, Field(default=None, description='comment string', alias=None, json_schema_extra={'units': None, 'required': False, 'examples': ['failure at midnight.']})] :value: None .. py:method:: validate_time(value, info) :classmethod: Validate that the value is a valid time. .. py:method:: validate_value(value, info) :classmethod: Validate that the value is a valid string or list. .. py:method:: set_variables() Validate that the value is a valid string. .. py:method:: as_string() Returns the comment as "{time_stamp} | {author} | {comment}" :returns: formatted comment :rtype: str .. py:method:: from_dict(value, skip_none=False) Parse input comment assuming "{time_stamp} | {author} | {comment}" :param value: _description_ :type value: str :param skip_none: _description_, by default False :type skip_none: bool, optional .. py:method:: read_dict(input_dict) can probably use from_dict method instead, but to keep consistency in EMTF XML metadata, this method is used to read the comment from a dictionary. :param input_dict: input dictionary containing comment data :type input_dict: dict :return: None :rtype: None .. py:method:: to_xml(string = False, required = True) Convert the Comment instance to XML format. :param string: If True, return the XML as a string. If False, return an ElementTree Element. :type string: bool, optional :param required: If True, include all required fields. :type required: bool, optional :return: XML representation of the Comment. :rtype: str | et.Element