sevnpy.io.MERGERLogReader

class sevnpy.io.logreader.MERGERLogReader(names: str | int | List[str | int] | None = None, IDs: str | int | List[str | int] | None = None)[source]

Bases: _OnlyOnePerSystemGetLast, _BSELogReader

Specialised LogReader for the event MERGER (see SEVN documentation)

Methods

__init__

body_regex

columnid_to_name

Get the column name based on their index

columns_summary

Get the column summary including their sorted index

header_regex

matching_pattern

Return the regex matching pattern of capturing names in the header and body of the object.

readfiles

Same as the method in the base class (readfiles()), but dropping possible duplicates.

readstring

Basic method to read logs from a string

summary

Get the total summary of the LogSchema

__init__(names: str | int | List[str | int] | None = None, IDs: str | int | List[str | int] | None = None)
Parameters:
  • log_event – name of the log event (or log events)

  • log_type – type of log event, S for SSE event, B for BSE event, S|B for both

  • body_schema – Schema of the log message

  • names – if not None, when matching the log message just consider systems with that name(s)

  • IDs – if not None, when matching the log message just consider systems with that ID(s)

__repr__()

Return repr(self).

__str__()

Return str(self).

__weakref__

list of weak references to the object

body_regex(capturing_names: Literal['default', 'all'] | List[str] | Tuple[str] = None) Tuple[str, List[str] | None]
Parameters:

list) (capturing_names (str or) – all column names will be matched. If a list is provided, only the specified capturing names will be matched. If None, none of the columns will be matched. Default value is “default”.

Returns:

the regex pattern for the body.

Return type:

header_regex_pattern

columnid_to_name(ids: int | List[int]) int | List[str]

Get the column name based on their index

Parameters:

ids (str, List[str|int]) – Integer or list of integers

Returns:

column_names – If the input is an integer return just the name of the column, otherwise a list with the column names corresponded to the indexes

Return type:

str, List[str|int]

columns_summary(show_description: bool = False) Dict[int, str]

Get the column summary including their sorted index

Parameters:

(bool) (show_description) – If True, include all the column description in outpt

Returns:

  • If show_description is False: A dictionary with the pair index:name

  • If show_description is True: A dictionary with the pair index:(name,description)

Return type:

column_summary_dictionary

header_regex(capturing_names: Literal['default', 'all'] | List[str] | Tuple[str] = None) Tuple[str, List[str] | None]
Parameters:

list) (capturing_names (str or) – all column names will be matched. If set to “default” all column names will be matched, except for log_type and event. If a list is provided, only the specified capturing names will be matched. If None, none of the columns will be matched. Default value is “default”.

Returns:

the regex pattern for the header.

Return type:

header_regex_pattern

matching_pattern(capturing_names: Literal['default', 'all', 'header_regex'] | List[str] = 'default') Tuple[str | List[str], str | List[str], str | List[str]]

Return the regex matching pattern of capturing names in the header and body of the object.

Parameters:

capturing_names (str or list) – A string or list of capturing names to match. If set to “all”, all column names will be matched. If set to “default” all column names will be matched, except for log_type and event. If a list is provided, only the specified capturing names will be matched. Default value is “default”.

Returns:

A tuple containing three elements:
  • A string representing the regex matching pattern.

  • A list of capturing names from the header and body.

  • A list of types of the matched capturing names from the header and body.

Return type:

tuple

Raises:

None.

readfiles(logfiles: str | List[str] | Tuple[str], capturing_cols: Literal['default', 'all', 'header'] | List[str | int] | Tuple[int | str, ...] = 'default', nproc: int = 1) SEVNDataLog

Same as the method in the base class (readfiles()), but dropping possible duplicates. This is used for Log entries that can produce multiple outputs do to check and repeat of SEVN, but only one should be considered in ouput (last by defaut, use the class _OnlyOnePerSystemGetFirst to maintain the first entry).

Parameters:
  • logfiles – Path to the logfile to read or list containing the path of the Logfiles

  • capturing_cols – Columns to capture If string it has to be a special value, otherwise a list of column names and/or indexes The special values are - “all”: return all the column names - “default”: return only the column names with a regex patter to catch a str an int or a float - “header”: return only the colum names of the header It is possible to include duplicated values, but they will be neglected in the output

  • nproc

    number of processes to be used for a parallel reading on multiple files.

    Note

    The number of processes will be anyway limited to number of logfiles to be read

Returns:

an instance of the SEVNDataLog containing the log information

Return type:

SEVNDataLog

readstring(string: str, capturing_cols: str | List[str | int] | Tuple[int | str, ...] = 'default') DataFrame

Basic method to read logs from a string

Parameters:
  • string – string containing the log

  • capturing_cols – Columns to capture If string it has to be a special value, otherwise a list of column names and/or indexes The special values are - “all”: return all the column names - “default”: return only the column names with a regex patter to catch a str an int or a float - “header”: return only the colum names of the header It is possible to include duplicated values, but they will be neglected in the output

Returns:

  • LogDataFrame – a pandas Dataframe containing the info from the read logfile without duplicates

  • .. note:: – This method returns simply a pandas Dataframe instead of the instance of the class SEVNDataLog returned by the method readfiles(). In order to access the additional information stored in The SEVNDataLog class, save the string to a file and use readfiles().

summary() Dict[str, Dict[str, str]]

Get the total summary of the LogSchema

Returns:

Return a dictionary containing the complete information of the log-schema. Each item is a pair name:info_dictionary and info_dictionary is a dictionary structures as follow {<item_name>: {“name”:<item_name>, “description”:<item_description>, “kind”:<item_kind>, “type”:<item_type>, “pattern”:<item_pattern>}}

Return type:

log_schema