utils

lakeformation.utils.to_var_name(s: str) str[source]

Convert string to variable name safe format. For example:

>>> to_var_name("us-east-1")
us_east_1
>>> to_var_name("arn:aws")
arn_aws
>>> to_var_name("a/b")
a__b
>>> to_var_name("database.table")
database_dot_table
lakeformation.utils.get_local_and_utc_now() Tuple[datetime.datetime, datetime.datetime][source]

Get current time in both local timezone format and utc format.

lakeformation.utils.get_diff_and_inter(dct1: Dict[str, Any], dct2: Dict[str, Any]) Tuple[ordered_set.OrderedSet, ordered_set.OrderedSet, ordered_set.OrderedSet][source]

Each deployed Object usually has a unique id. Mapper is a dictionary data structure that stores a collection of Object. Key is the Object id, value is the Object instance.

Given a new Mapper and a deployed Mapper, it is very common to find out which Object should be added, should be delayed and should be updated.

This utility function takes two parameter

  1. new object Mapper

  2. deployed object Mapper

Returns three set data structure

  1. to add object id set

  2. to delete object id set

  3. to update object id set

Parameters
  • dct1

  • dct2

Returns

lakeformation.utils.grouper_list(iterable: Iterable, n: int) List[list][source]

Evenly divide list into fixed-length piece, no filled value if chunk size smaller than fixed-length.

Example:

>>> list(grouper_list(range(10), n=3)
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]