How to use the gkeepapi.node.Category 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_category_fields(self):
        n = node.Category()
        n.category = node.CategoryValue.TV

        CATEGORY = node.CategoryValue.Books

        clean_node(n)
        n.category = CATEGORY
        self.assertTrue(n.dirty)
        self.assertEqual(CATEGORY, n.category)
github kiwiz / gkeepapi / test / test_nodes.py View on Github external
def test_fields(self):
        n = node.NodeAnnotations()

        CATEGORY = node.CategoryValue.Books
        CATEGORY_2 = node.CategoryValue.TV

        clean_node(n)
        n.category = None
        self.assertTrue(n.dirty)
        self.assertEqual(None, n.category)

        sub = node.Category()
        sub.category = CATEGORY
        clean_node(sub)

        clean_node(n)
        n.append(sub)
        self.assertTrue(n.dirty)
        self.assertEqual(CATEGORY, n.category)

        clean_node(n)
        sub.category = CATEGORY_2
        self.assertTrue(n.dirty)
        self.assertEqual(CATEGORY_2, n.category)

        clean_node(n)
        n.remove(sub)
        self.assertTrue(n.dirty)
github kiwiz / gkeepapi / test / test_nodes.py View on Github external
def Category():
            c = node.Category()
            c.category = node.CategoryValue.Books
            return c
        a, b = generate_save_load(Category)
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def from_json(cls, raw):
        """Helper to construct an annotation from a dict.

        Args:
            raw (dict): Raw annotation representation.

        Returns:
            Node: An Annotation object or None.
        """
        bcls = None
        if 'webLink' in raw:
            bcls = WebLink
        elif 'topicCategory' in raw:
            bcls = Category
        elif 'taskAssist' in raw:
            bcls = TaskAssist
        elif 'context' in raw:
            bcls = Context

        if bcls is None:
            logger.warning('Unknown annotation type: %s', raw.keys())
            return None
        annotation = bcls()
        annotation.load(raw)

        return annotation
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def category(self, value):
        node = self._get_category_node()
        if value is None:
            if node is not None:
                del self._annotations[node.id]
        else:
            if node is None:
                node = Category()
                self._annotations[node.id] = node

            node.category = value
        self._dirty = True
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def __init__(self):
        super(Category, self).__init__()
        self._category = None
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def _get_category_node(self):
        for annotation in self._annotations.values():
            if isinstance(annotation, Category):
                return annotation
        return None