24 lines
819 B
Python
24 lines
819 B
Python
|
# Copyright 2024 (c) Anna Schumaker.
|
||
|
"""A Thread class designed to easily sync up with the main thread."""
|
||
|
|
||
|
|
||
|
class Data:
|
||
|
"""A class for holding generic fields inspired by SimpleNamespace."""
|
||
|
|
||
|
def __init__(self, values_dict: dict = {}, **kwargs):
|
||
|
"""Initialize our Data class."""
|
||
|
self.__dict__.update(values_dict | kwargs)
|
||
|
|
||
|
def __eq__(self, rhs: any) -> bool:
|
||
|
"""Compare two Data classes."""
|
||
|
if isinstance(rhs, Data):
|
||
|
return self.__dict__ == rhs.__dict__
|
||
|
elif isinstance(rhs, dict):
|
||
|
return self.__dict__ == rhs
|
||
|
return False
|
||
|
|
||
|
def __repr__(self) -> str:
|
||
|
"""Get a string representation of the Data."""
|
||
|
items = (f"{k}={v!r}" for k, v in self.__dict__.items())
|
||
|
return f"{type(self).__name__}({', '.join(items)})"
|