def to_dict(self, camel_attr=True) -> Dict: """Task `to_dict` function which will return key attribute for Task object.""" content = {} for attr, value in self.__dict__.items(): # Don't publish private variables if attr.startswith("_"): continue elif isinstance(value, TaskParams): content[snake2camel(attr)] = value.to_dict() else: content[snake2camel(attr)] = value return content
def to_dict(self) -> Dict: """Get object key attribute dict which determine by attribute `DEFAULT_ATTR`.""" content = { snake2camel(attr): value for attr, value in self.__dict__.items() } content.update(self.DEFAULT_ATTR) return content
def test_snake2camel(snake: str, expect: str): """Test function snake2camel, this is a base function for utils.string.""" assert expect == snake2camel( snake ), f"Test case {snake} do no return expect result {expect}."