Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add(self, node):
"""Register a top level node (and its children) for syncing up to the server. There's no need to call this for nodes created by
:py:meth:`createNote` or :py:meth:`createList` as they are automatically added.
LoginException: If :py:meth:`login` has not been called.
Args:
node (gkeepapi.node.Node): The node to sync.
Raises:
Invalid: If the parent node is not found.
"""
if node.parent_id != _node.Root.ID:
raise exception.InvalidException('Not a top level node')
self._nodes[node.id] = node
self._nodes[node.parent_id].append(node, False)
def add(self, text, checked=False, sort=None):
"""Add a new sub item to the list. This item must already be attached to a list.
Args:
text (str): The text.
checked (bool): Whether this item is checked.
sort (int): Item id for sorting.
"""
if self.parent is None:
raise exception.InvalidException('Item has no parent')
node = self.parent.add(text, checked, sort)
self.indent(node)
return node