How to use the gkeepapi.node.Note 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.Note(id_='3')

        TEXT = 'Text'

        clean_node(n)
        n.text = TEXT
        self.assertTrue(n.dirty)
        self.assertEqual(TEXT, n.text)

        self.assertEqual('https://keep.google.com/u/0/#NOTE/3', n.url)
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 / kc.py View on Github external
text_width = max_x - min_x
        text_index = min_y
        if self.note.title:
            text_index += 1
            try:
                self.win.addstr(
                    min_y, min_x,
                    abbreviate(self.note.title, text_width).encode('UTF-8'),
                    curses.A_UNDERLINE
                )
            except curses.error:
                pass

        if max_y > text_index:
            if type(self.note) == gkeepapi.node.Note:
                entries = [abbreviate(line, text_width) for line in self.note.text.split("\n")]
            else:
                entries = [
                    (u'☒' if item.checked else u'☐') + abbreviate(item.text, max_x - min_x - 1) for item in self.note.items
                ]
            for i in range(min(max_y - text_index, len(entries))):
                try:
                    self.win.addstr(
                        i + text_index, min_x,
                        entries[i].encode('UTF-8'),
                    )
                except curses.error:
                    pass
        self.win.noutrefresh()
github adamyi / notes_to_keep / notes_to_keep / gkeep.py View on Github external
def uploadNote(keep, note, header, label, pfx, folders):
    log.info("Uploading note: " + note.title)
    gnote = g_node.Note()
    if pfx is not None:
        gnote.title = "[%s] %s" % (pfx, note.title)
    else:
        gnote.title = note.title
    if header:
        gnote.text = generateBody(note)
    else:
        gnote.text = parseHTML(note.data)
    # ts = g_node.NodeTimestamps()
    # ts.load({'created': note.date_created, 'edited': note.date_edited, 'updated': datetime.now()})
    # gnote.timestamps = ts
    if label is not None:
        gnote.labels.add(label)
    if folders:
        if keep.findLabel(note.folder) is not None:
            gnote.labels.add(keep.findLabel(note.folder))
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
return self._merged

    @merged.setter
    def merged(self, value):
        self._merged = value
        self.touch()

    @property
    def dirty(self):
        return super(Label, self).dirty or self.timestamps.dirty

    def __str__(self):
        return self.name

_type_map = {
    NodeType.Note: Note,
    NodeType.List: List,
    NodeType.ListItem: ListItem,
    NodeType.Blob: Blob,
}

def from_json(raw):
    """Helper to construct a node from a dict.

    Args:
        raw (dict): Raw node representation.

    Returns:
        Node: A Node object or None.
    """
    ncls = None
    _type = raw.get('type')
github kiwiz / gkeepapi / gkeepapi / __init__.py View on Github external
def createNote(self, title=None, text=None):
        """Create a new managed note. Any changes to the note will be uploaded when :py:meth:`sync` is called.

        Args:
            title (str): The title of the note.
            text (str): The text of the note.

        Returns:
            gkeepapi.node.List: The new note.
        """
        node = _node.Note()
        if title is not None:
            node.title = title
        if text is not None:
            node.text = text
        self.add(node)
        return node
github kiwiz / gkeepapi / gkeepapi / node.py View on Github external
def __init__(self, **kwargs):
        super(Note, self).__init__(type_=self._TYPE, **kwargs)