ios_shell.utils module

Contains useful functions for parsing that are not themselves parsing functions.

ios_shell.utils.all_same(list: List[Any]) bool

Decide whether or not a list’s values are all the same

ios_shell.utils.apply_column_mask(data: str, mask: str) List[str]

Apply a mask to a single row of data.

Parameters
  • data – the row of data to break up

  • mask – a string with ‘-’ for every character to be included as an element

ios_shell.utils.format_string(format: str, kind: str, width: int, decimals: int) str

Construct an appropriate format string for the given type.

Parameters
  • format – the format the data is expected to conform to

  • kind – the type the data is expected to be

  • width – the number of characters the data may take up

  • decimals – the number of characters after a decimal a float is intended to use

ios_shell.utils.get_latitude(coord: str) float

Convert a string representing a latitude into a floating point number.

ios_shell.utils.get_longitude(coord: str) float

Convert a string representing a longitude into a floating point number.

ios_shell.utils.has_many_values(list: List[Any]) bool

Decide whether or not a list has more than one value

ios_shell.utils.is_section_heading(s: str) bool

Decide whether or not a string represents the beginning of a secion.

ios_shell.utils.is_table_mask(line: str) bool

Decide whether or not a string is a table mask.

A table mask starts with an indentation, then a ‘!’ character, and then a mixture of ‘ ‘ and ‘-’

ios_shell.utils.list_to_pandas(list: List[List[Any]], names: List[str])

Convert list of lists to pandas DataFrame

Parameters
  • list – the data as a list of data rows

  • names – the row names to be used in the pandas.DataFrame

Returns

a pandas.DataFrame if pandas is present, otherwise None

ios_shell.utils.to_date(contents: str) date

Convert a string representing a date into a usable object.

ios_shell.utils.to_datetime(value: str) datetime

Convert a string representing a date and time into a usable object.

ios_shell.utils.to_increment(description: str) timedelta
ios_shell.utils.to_time(contents: str, tzinfo=datetime.timezone.utc) time

Convert a string representing a time into a usable object.