1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

Implement better __repr__ generator

This commit is contained in:
thatmattlove
2021-09-16 15:35:12 -07:00
parent 1e1dce1e30
commit bb1e66c2ef
8 changed files with 62 additions and 24 deletions

View File

@@ -9,7 +9,8 @@ from pydantic import HttpUrl, BaseModel, BaseConfig
# Project
from hyperglass.log import log
from hyperglass.util import snake_to_camel
from hyperglass.util import snake_to_camel, repr_from_attrs
from hyperglass.types import Series
class HyperglassModel(BaseModel):
@@ -45,6 +46,10 @@ class HyperglassModel(BaseModel):
)
return snake_to_camel(snake_field)
def _repr_from_attrs(self, attrs: Series[str]) -> str:
"""Alias to `hyperglass.util:repr_from_attrs` in the context of this model."""
return repr_from_attrs(self, attrs)
def export_json(self, *args, **kwargs):
"""Return instance as JSON."""