Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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()
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))
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')
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
def __init__(self, **kwargs):
super(Note, self).__init__(type_=self._TYPE, **kwargs)