Skip to content

Commit

Permalink
fix(serializabel)!: Use str verion of CryptoDataParamsBase objets in …
Browse files Browse the repository at this point in the history
…Markdown result
  • Loading branch information
c0r0n3r committed Nov 13, 2023
1 parent eb68754 commit c9929e0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cryptoparser/common/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def __call__(self, obj, level):


class Serializable(object): # pylint: disable=too-few-public-methods
_MARKDOWN_RESULT_STRING_CLASSES = (
CryptoDataParamsBase,
ipaddress.IPv4Network,
ipaddress.IPv6Network,
urllib3.util.url.Url,
)
post_text_encoder = SerializableTextEncoder()

@staticmethod
Expand Down Expand Up @@ -239,12 +245,12 @@ def _markdown_result(cls, obj, level=0): # pylint: disable=too-many-branches
return cls.post_text_encoder(obj.value, level)

return cls.post_text_encoder(obj.name, level)
elif isinstance(obj, (ipaddress.IPv4Network, ipaddress.IPv6Network, urllib3.util.url.Url)):
elif attr.has(type(obj)):
result = cls._markdown_result_complex(obj, level)
elif isinstance(obj, cls._MARKDOWN_RESULT_STRING_CLASSES):
return False, str(obj)
elif isinstance(obj, datetime.timedelta):
return False, str(obj.seconds)
elif attr.has(type(obj)):
result = cls._markdown_result_complex(obj, level)
elif hasattr(obj, '_asdict'):
result = cls._markdown_result(obj._asdict(), level)
elif hasattr(obj, '__dict__') or isinstance(obj, dict):
Expand Down

0 comments on commit c9929e0

Please sign in to comment.