CybOXProject / mixbox

A library of common code leveraged by python-cybox, python-maec, and python-stix
BSD 3-Clause "New" or "Revised" License
8 stars 15 forks source link

Improve __str__ representation of fields. #32

Closed gtback closed 8 years ago

gtback commented 8 years ago

It would be useful to include the name of the fields when printing them:

Instead of:

<mixbox.fields.IdField at 0x107a91890>: 'example:Object-8c092727-cc8b-40cf-b132-0ef3b84c7fe6',
<mixbox.fields.IdrefField at 0x107a918d0>: None,
<mixbox.fields.TypedField at 0x107a91910>: None,
<mixbox.fields.IdField: 'id'>: 'example:Object-8c092727-cc8b-40cf-b132-0ef3b84c7fe6',
<mixbox.fields.IdrefField: 'idref'>: None
<mixbox.fields.TypedField: 'title'>: None,

Note that this is really only useful when digging into the guts of Entities and examining its _fields

gtback commented 8 years ago

Nevermind. Instead of just doing x._fields, you can do

{str(k): v for k, v in x._fields.items()}