How to use the gkeepapi.node.Label 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.NodeLabels()

        LABEL = 'Label'

        sub = node.Label()
        sub.name = LABEL
        clean_node(sub)

        clean_node(n)
        n.add(sub)
        self.assertTrue(n.dirty)
        self.assertEqual(sub, n.get(sub.id))
        self.assertEqual([sub], n.all())

        clean_node(n)
        n.remove(sub)
        self.assertTrue(n.dirty)
        self.assertEqual([], n.all())
github kiwiz / gkeepapi / test / test_nodes.py View on Github external
def test_save_load(self):
        a, b = generate_save_load(node.Label)
        self.assertEqual(a, b)
github kiwiz / gkeepapi / test / test_nodes.py View on Github external
clean_node(n)
        n.archived = ARCHIVED
        self.assertTrue(n.dirty)
        self.assertEqual(ARCHIVED, n.archived)

        clean_node(n)
        n.pinned = PINNED
        self.assertTrue(n.dirty)
        self.assertEqual(PINNED, n.pinned)

        clean_node(n)
        n.title = TITLE
        self.assertTrue(n.dirty)
        self.assertEqual(TITLE, n.title)

        l = node.Label()
        l.name = LABEL
        clean_node(l)

        clean_node(n)
        n.labels.add(l)
        self.assertTrue(n.dirty)

        clean_node(n)
        n.labels.remove(l)
        self.assertTrue(n.dirty)
github kiwiz / gkeepapi / gkeepapi / __init__.py View on Github external
def _parseUserInfo(self, raw):
        labels = {}
        if 'labels' in raw:
            for label in raw['labels']:
                # If the mainId field exists, this is an update.
                if label['mainId'] in self._labels:
                    node = self._labels[label['mainId']]
                    # Remove this key from our list of labels.
                    del self._labels[label['mainId']]
                    logger.debug('Updated label: %s', label['mainId'])
                else:
                    # Otherwise, this is a brand new label.
                    node = _node.Label()
                    logger.debug('Created label: %s', label['mainId'])
                node.load(label)
                labels[label['mainId']] = node

        # All remaining labels are deleted.
        for label_id in self._labels:
            logger.debug('Deleted label: %s', label_id)

        self._labels = labels
github kiwiz / gkeepapi / gkeepapi / __init__.py View on Github external
def createLabel(self, name):
        """Create a new label.

        Args:
            name (str): Label name.

        Returns:
            gkeepapi.node.Label: The new label.

        Raises:
            LabelException: If the label exists.
        """
        if self.findLabel(name):
            raise exception.LabelException('Label exists')
        node = _node.Label()
        node.name = name
        self._labels[node.id] = node # pylint: disable=protected-access
        return node