pysbr package

Submodules

pysbr.utils module

pysbr.utils.build_yaml_path(fname: str, subpath: str = 'pysbr/config') → pathlib.PosixPath

Build an absolute path to the .yaml file specified by fname and subpath.

pysbr.utils.datetime_to_timestamp(dt: datetime.datetime) → int

Convert datetime to Unix timestamp in milliseconds

pysbr.utils.datetime_to_timestamp_aware(dt: datetime.datetime, tz: Optional[str] = None) → int

DEPRECATED Convert datetime object to Unix timestamp, in milliseconds.

tz refers to the timezone to use (see pytz documentation for list of

available timezones). If None, uses system timezone.

pysbr.utils.dump_json(d, path: str)

Write json to file specified by path.

Raises

FileNotFoundError

pysbr.utils.dump_yaml(d, path)

Write yaml to file specified by path.

Raises

FileNotFoundError

pysbr.utils.get_project_root() → pathlib.PosixPath

Get pathlib representation of project’s root folder.

pysbr.utils.iso_str_to_timestamp(iso_str: str) → int

Convert iso str to Unix timestamp in milliseconds.

pysbr.utils.iso_zulu_to_offset(iso_str: str) → str

Convert ISO string in Zulu time to UTC offset.

Does not check the contents of the ISO string - assumes it is a correctly formatted ISO string in Zulu time.

pysbr.utils.load_json(path) → Dict

Read json from file specified by path.

Raises

FileNotFoundError

pysbr.utils.load_yaml(path: str) → Dict

Read yaml from file specified by path.

Raises

FileNotFoundError

pysbr.utils.make_list(item: Any) → List

Return item inside a list, if it isn’t already a list.

pysbr.utils.str_format(s: str, indent_: int = 0, dedent_l1: bool = False, squish: bool = False) → str

Format and return string s.

Parameters
  • indent – The number of tabs to indent each line of the string with.

  • dedent_l1 – Dedent line 1. This is added as an argument because if inserting a multiline string into a template string, only the first line gets the indentation from the template string.

  • squish – If true, compress the string into one line.

pysbr.utils.timestamp_to_datetime(ts: int) → datetime.datetime

Convert Unix timestamp (in milliseconds) to datetime.

The returned datetime object is aware, and uses the system timezone.

pysbr.utils.timestamp_to_datetime_aware(ts: int, tz: Optional[str] = None) → datetime.datetime

DEPRECATED Convert Unix timestamp ts to timezone aware datetime object.

tz refers to the timezone to use (see pytz documentation for list of

available timezones). If None, uses system timezone.

pysbr.utils.timestamp_to_iso_str(ts: int) → str

Convert Unix timestamp (in milliseconds) to ISO string.

Module contents