mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
24 lines
759 B
Python
24 lines
759 B
Python
|
|
||
|
|
||
|
def pop_from_dict_by_set(dictionary: dict, valid_keys: set):
|
||
|
""" remove and create new dict with key value pairs of dictionary, where key is in valid_keys """
|
||
|
new_dictionary = {}
|
||
|
|
||
|
for key in list(dictionary.keys()):
|
||
|
if key in valid_keys:
|
||
|
new_dictionary[key] = dictionary.pop(key)
|
||
|
|
||
|
return new_dictionary
|
||
|
|
||
|
|
||
|
def check_kwargs_empty(kwargs_dict, raise_error=False) -> bool:
|
||
|
""" returns True if kwargs are empty, False otherwise, raises error if not empty """
|
||
|
|
||
|
if len(kwargs_dict) > 0:
|
||
|
if raise_error:
|
||
|
raise ValueError(f"{list(kwargs_dict.keys())} are not supported arguments. Look at the documentation for supported arguments.")
|
||
|
else:
|
||
|
return True
|
||
|
else:
|
||
|
return False
|