MCPcopy Create free account
hub / github.com/cdgriffith/Box / has_comments

Function has_comments

box/comments.py:248–260  ·  view source on GitHub ↗

True when any Box / BoxList in the tree has a key, item or document comment.

(obj, _seen=None)

Source from the content-addressed store, hash-verified

246
247
248def has_comments(obj, _seen=None) -> bool:
249 """True when any Box / BoxList in the tree has a key, item or document comment."""
250 store = getattr(obj, "_comment_store", None)
251 if store is None:
252 return False
253 if obj._comment_store(create=False) or obj._comment_document(create=False):
254 return True
255 seen = _seen if _seen is not None else set()
256 if id(obj) in seen:
257 return False
258 seen.add(id(obj))
259 values = obj.values() if isinstance(obj, dict) else obj # a list or a frozen list (tuple)
260 return any(has_comments(value, seen) for value in values)
261
262
263def _add_eol_comment(out, key, text):

Callers 1

dump_yamlFunction · 0.85

Calls 2

_comment_storeMethod · 0.45
_comment_documentMethod · 0.45

Tested by

no test coverage detected