utils#
- wow_sdm.utils.get_values(enum_class) OrderedSet[source]#
Get all values from an enum class.
Example:
>>> class Color: ... RED = 1 ... GREEN = 2 ... BLUE = 3 >>> get_values(Color) OrderedSet([1, 2, 3])
- wow_sdm.utils.group_by(iterable: Iterable[VT], get_key: Callable[[VT], KT]) Dict[KT, List[VT]][source]#
Group items by it’s key, with type hint.
Example:
>>> class Record: ... def __init__(self, product: str, date: str, sale: int): ... self.product = product ... self.date = date ... self.sale = sale >>> records = [ ... Record("apple", "2020-01-01", 10), ... Record("apple", "2020-01-02", 20), ... Record("apple", "2020-01-03", 30), ... Record("banana", "2020-01-01", 10), ... Record("banana", "2020-01-02", 20), ... Record("banana", "2020-01-03", 30), ... ] >>> group_by(records, lambda x: x.product) { "apple": [ Record("apple", "2020-01-01", 10), Record("apple", "2020-01-02", 20), Record("apple", "2020-01-03", 30), ], "banana": [ Record("banana", "2020-01-01", 10), Record("banana", "2020-01-02", 20), Record("banana", "2020-01-03", 30), ], }
- wow_sdm.utils.concat_lists(*lists) list[source]#
Concatenate multiple lists into one list.
Example:
>>> concat_lists([1, 2], [3, 4], [5, 6]) [1, 2, 3, 4, 5, 6]
- wow_sdm.utils.apply(path: Path, content: str, real_run: bool = False, verbose: bool = True)[source]#
Apply a content to a file (Write to the file in
World of Warcraft\WTF\...).- Parameters:
path – The file path to write to.
content – The content to write.
real_run – If True, do not write to the file.
verbose – If True, print log.