data_baseutils

utils

Database utility and convenience functions.

Classes

silence_stdout

Silence stdout

mkdtemp

Context manager for creating temporary directories

DelayedKeyboardInterrupt

Context manager that allows to delay a KeyboardInterrupt such that it also works in subthreads.

bcolors

List of colors for terminal output in bash.

Functions

chunkIt(seq, num)

Splits seq in num lists, with approximately equal size.

convertible_to_int(x)

Returns True if x can be converted to an integer, False otherwise

split_file_to_buffers(f, split_str)

Reads a file f and splits it wherever split_str is found.

first_line_to_key(stringios)

Convert a list of StringIO objects to a dictionary.

pandas_to_array(pdf, x_component_fun, y_component_fun, value_fun)

Convert a pandas dataframe, in which information is stored linearly to a 2D presentation.

select(df, **kwargs)

Selects rows from a dataframe based on the values of the columns

pooled_std(m, s, n)

Calculates the pooled standard deviation out of samples.

skit(*funcs, **kwargs)

Splits kwargs up to supply different functions with the right subset.

unique(list_)

Get the unique elements of a list

cache(function)

Decorator to cache the result of a function

fancy_dict_compare(dict_1, dict_2, dict_1_name, dict_2_name, path)

Compare two dictionaries recursively to find non-matching elements

wait_until_key_removed(db, key, delay)

Wait until a key is removed from a database.

get_file_or_folder_that_startswith(path, startswith)

Get the file or folder in a directory that starts with a certain string

get_file_or_folder_that_endswith(path, endswith)

Get the file or folder in a directory that ends with a certain string

flatten(l)

Flatten a nested list

synchronous_ddf_concat(ddf_path, meta, N, n, scheduler)

Concatenate a pickles dask dataframe to a pandas dataframe.

myrepartition(ddf, N)

Repartition a dask dataframe without generating more tasks.

df_colnames_to_str(df)

Convert the column names and index names of a dataframe to string.

colorize_key(key)

Colorizes a key based on its type.

colorize_str(key, bcolor)

Colorize a string with a terminal color.

calc_recursive_filetree(db, root_dir_path, max_lines, depth, max_depth, max_lines_per_key, lines, indent, all_files, colorize)

Fetches the contents of an db and formats them as a string representing a tree structure

rename_for_deletion(key)

Renames some key to indicate it’s in the process of being deleted.

delete_in_background(key)

Starts a background process that deletes a key

is_db(dir_to_data)

Check if a path is a DataBase.