psyinfra / onyo

text-based inventory system on top of git
ISC License
3 stars 5 forks source link

Editing comments is treated as noop #586

Closed bpoldrack closed 1 month ago

bpoldrack commented 6 months ago

Diff isn't considering (changes in) comments. Hence, not written.

bpoldrack commented 1 month ago

Note to myself:

Comments in differ shouldn't be hard -> CommentedMap._yaml_comment (attribute name from comments.comment_attrib) -> Comment.items -> keys -> list -> find CommentToken. This comes with .value and overwrites __eq__/__ne__. modify_asset needs to not raise NoopError, though. Bogus operation?

edit:

Actually, differ already works (we just don't get there). Comparing CommentToken doesn't work w/ builtin __eq__, though, because these objects are connected to filehandles which are obviously not the same. So, we need to compare CommentToken.value ourselves to detect a change.

Lastly, this is loosely related to (nested) dictionary support in that this business here would provide a reason for an Asset class or whatever sort of wrapper to put that code in. If the dictionary support finds reasons, too, we may need/want to do that.