How to use the gkeepapi.node.List function in gkeepapi

To help you get started, we’ve selected a few gkeepapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kiwiz / gkeepapi / test / test_nodes.py View on Github external
def test_fields(self):
        n = node.List()

        TEXT = 'Text'

        clean_node(n)
        n.add('Text')
        self.assertTrue(n.dirty)
        self.assertEqual(u'☐ %s' % TEXT, n.text)
github kiwiz / gkeepapi / test / test_nodes.py View on Github external
def test_save_load(self):
        a, b = generate_save_load(lambda: node.Node(type_=node.NodeType.Note))
        self.assertEqual(a, b)

        a, b = generate_save_load(lambda: node.TopLevelNode(type_=node.NodeType.Note))
        self.assertEqual(a, b)

        a, b = generate_save_load(node.Note)
        self.assertEqual(a, b)

        a, b = generate_save_load(node.List)
        self.assertEqual(a, b)

        a, b = generate_save_load(node.ListItem)
        self.assertEqual(a, b)
github kiwiz / keep-cli / keep_cli / widget / edit.py View on Github external
def _save(self):
        title = self.w_title.get_edit_text()
        if self.note.title != title:
            self.note.title = title

        if not isinstance(self.note, gkeepapi.node.List):
            text = self.w_text.get_edit_text()
            if self.note.text != text:
                self.note.text = text
            return

        old_items = set((item.id for item in self.note.items))

        for i, w_item in enumerate(self.w_list.body):
            item = gkeepapi.node.ListItem(id_=w_item.id, parent_id=self.note.id)
            if w_item.id in old_items:
                item = self.note.get(w_item.id)
                old_items.remove(w_item.id)

            if item.checked != w_item.checked:
                item.checked = w_item.checked
            text = w_item.getText()
github kiwiz / gkeepapi / gkeepapi / __init__.py View on Github external
def createList(self, title=None, items=None):
        """Create a new list and populate it. Any changes to the note will be uploaded when :py:meth:`sync` is called.

        Args:
            title (str): The title of the list.
            items (List[(str, bool)]): A list of tuples. Each tuple represents the text and checked status of the listitem.

        Returns:
            gkeepapi.node.List: The new list.
        """
        if items is None:
            items = []

        node = _node.List()
        if title is not None:
            node.title = title
        for text, checked in items:
            node.add(text, checked)
        self.add(node)
        return node
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def subitems(self):
        """Get subitems for this item.

        Returns:
            list[gkeepapi.node.ListItem]: Subitems.
        """
        return List.items_sort(
            self._subitems.values()
        )
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def __init__(self, **kwargs):
        super(List, self).__init__(type_=self._TYPE, **kwargs)
github kiwiz / keep-cli / keep_cli / commands.py View on Github external
def get(args: argparse.Namespace, keep: gkeepapi.Keep, config: dict):
    _sync(args, keep, config, True)
    note =_ensure_note(keep, args.note)
    none = not (args.title or args.text or args.unchecked or args.checked or args.labels)

    if none or args.title:
        print(note.title)

    if none or args.text:
        if isinstance(note, gkeepapi.node.List):
            none_completion = not (args.unchecked or args.checked)
            entries = []
            if none_completion or args.unchecked:
                entries += note.unchecked
            if none_completion or args.checked:
                entries += note.checked
            for entry in entries:
                print(entry)

        else:
            print(note.text)

    if none or args.labels:
        for label in note.labels.all():
            print(label)