Esempio n. 1
0
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))
        else:
            gnote.labels.add(keep.createLabel(note.folder))
    keep.add(gnote)
    # make things slower to sync everytime instead of sync one time finally
    # however, syncing one time is more error-prone.
    # in this way, if a sync has an issue, it only affects one single note.
    keep.sync()
Esempio n. 2
0
    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)
Esempio n. 3
0
    def test_str(self):
        n = node.Note()

        TITLE = 'Title'
        TEXT = 'Test'

        self.assertEqual('', n.text)

        n.title = TITLE
        n.text = TEXT
        self.assertEqual('%s\n%s' % (TITLE, TEXT), str(n))
        self.assertEqual(TEXT, n.text)
Esempio n. 4
0
    def test_dirty(self):
        n = node.Note()

        clean_node(n)
        n.text = ''
        self.assertTrue(n.dirty)