hwt.pyUtils package

This package contains python utils used in this library.

Submodules

hwt.pyUtils.arrayQuery module

exception hwt.pyUtils.arrayQuery.DuplicitValueExc[source]

Bases: Exception

Exception which means that there are multiple items which this query selected but it should return only one

exception hwt.pyUtils.arrayQuery.NoValueExc[source]

Bases: Exception

Exception which means that query did not selected any item

hwt.pyUtils.arrayQuery.areSetsIntersets(setA, setB)[source]

Check if intersection of sets is not empty

hwt.pyUtils.arrayQuery.arr_all(iterable, fn)[source]
Returns:True if fn(item) for all items in interable or iterable is empty else False
hwt.pyUtils.arrayQuery.arr_any(iterable, fn)[source]
Returns:True if fn(item) for any item else False
hwt.pyUtils.arrayQuery.balanced_reduce(arr, opFn)[source]
hwt.pyUtils.arrayQuery.flatten(iterables, level=inf)[source]

Flatten nested lists, tuples, generators and maps

Parameters:level – maximum depth of flattening
hwt.pyUtils.arrayQuery.groupedby(collection, fn)[source]

same like itertools.groupby

Note:This function does not needs initial sorting like itertools.groupby
Attention:Order of pairs is not deterministic.
hwt.pyUtils.arrayQuery.grouper(n, iterable, padvalue=None)[source]

grouper(3, ‘abcdefg’, ‘x’) –> (‘a’,’b’,’c’), (‘d’,’e’,’f’), (‘g’,’x’,’x’)

hwt.pyUtils.arrayQuery.single(iterable, fn)[source]

Get value from iterable where fn(item) and check if there is not fn(other item)

Raises:
hwt.pyUtils.arrayQuery.take(iterrable, howMay)[source]
Returns:generator of first n items from iterrable
hwt.pyUtils.arrayQuery.where(iterable, fn)[source]
Returns:generator of items from iterable where fn(item)

hwt.pyUtils.fileHelpers module

hwt.pyUtils.fileHelpers.find_files(directory, pattern, recursive=True)[source]

Find files by pattern in directory

hwt.pyUtils.testUtils module

class hwt.pyUtils.testUtils.TestMatrix(*args, **kwargs)[source]

Bases: object

Class which instance is a decorator which executes unittest.TestCase test method with every combination of argumets

__init__(*args, **kwargs)[source]
Note:args, kwargs are lists of arguments which should be passed as a test arguments
split_args_kwargs(args)[source]

hwt.pyUtils.uniqList module

class hwt.pyUtils.uniqList.UniqList(initSeq: Optional[Sequence[T]] = None)[source]

Bases: typing.Generic, list

List of unique items

_UniqList__s
__init__(initSeq: Optional[Sequence[T]] = None)[source]

Initialize self. See help(type(self)) for accurate signature.

_get_set() → Set[T][source]
append(item: T) → bool[source]
Returns:True if the item was in list already
clear()[source]

Remove all items from list.

copy()[source]

Return a shallow copy of the list.

discard(item: T) → bool[source]
Returns:True if the item was in list already
extend(items: Sequence[T])[source]

Extend list by appending elements from the iterable.

insert(i: int, x: T)[source]

Insert object before index.

intersection_set(other: Set[T])[source]
pop(*args, **kwargs) → T[source]

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(item: T)[source]

Remove first occurrence of value.

Raises ValueError if the value is not present.