Skip to content

Commit c9929e0

Browse files
committed
fix(serializabel)!: Use str verion of CryptoDataParamsBase objets in Markdown result
1 parent eb68754 commit c9929e0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cryptoparser/common/base.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ def __call__(self, obj, level):
6060

6161

6262
class Serializable(object): # pylint: disable=too-few-public-methods
63+
_MARKDOWN_RESULT_STRING_CLASSES = (
64+
CryptoDataParamsBase,
65+
ipaddress.IPv4Network,
66+
ipaddress.IPv6Network,
67+
urllib3.util.url.Url,
68+
)
6369
post_text_encoder = SerializableTextEncoder()
6470

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

241247
return cls.post_text_encoder(obj.name, level)
242-
elif isinstance(obj, (ipaddress.IPv4Network, ipaddress.IPv6Network, urllib3.util.url.Url)):
248+
elif attr.has(type(obj)):
249+
result = cls._markdown_result_complex(obj, level)
250+
elif isinstance(obj, cls._MARKDOWN_RESULT_STRING_CLASSES):
243251
return False, str(obj)
244252
elif isinstance(obj, datetime.timedelta):
245253
return False, str(obj.seconds)
246-
elif attr.has(type(obj)):
247-
result = cls._markdown_result_complex(obj, level)
248254
elif hasattr(obj, '_asdict'):
249255
result = cls._markdown_result(obj._asdict(), level)
250256
elif hasattr(obj, '__dict__') or isinstance(obj, dict):

0 commit comments

Comments
 (0)