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.TopLevelNode(type_=node.NodeType.Note)
COLOR = node.ColorValue.White
ARCHIVED = True
PINNED = True
TITLE = 'Title'
LABEL = 'x'
clean_node(n)
n.color = COLOR
self.assertTrue(n.dirty)
self.assertEqual(COLOR, n.color)
clean_node(n)
n.archived = ARCHIVED
self.assertTrue(n.dirty)
self.assertEqual(ARCHIVED, n.archived)
clean_node(n)
def __init__(self):
super(Colors, self).__init__([
Color(color) for color in gkeepapi.node.ColorValue
], 3, 1, 0, urwid.LEFT)
def __init__(self, app: 'application.Application'):
self.application = app
self.w_pinned = urwid.CheckBox('Pinned', state='mixed', has_mixed=True)
self.w_archived = urwid.CheckBox('Archived', state=False, has_mixed=True)
self.w_trashed = urwid.CheckBox('Trashed', state=False, has_mixed=True)
self.w_note = urwid.CheckBox('Note', state=True)
self.w_list = urwid.CheckBox('List', state=True)
self.w_labels = labels.Labels()
self.w_colors = edit.Colors()
self.w_labels.setLabels(app.keep.labels(), gkeepapi.node.ColorValue.White)
self.w_header = urwid.Text(u'', align=urwid.RIGHT)
self.w_footer = urwid.Text(u'', align=urwid.RIGHT)
super(Search, self).__init__(urwid.Pile([
urwid.Text(('buTEXT', 'Search'), align=urwid.CENTER),
urwid.Divider(),
urwid.Text(('bTEXT', 'State')),
self.w_pinned,
self.w_archived,
self.w_trashed,
urwid.Divider(),
def __init__(self, invalid_color):
import gkeepapi
colors = [color.name for color in gkeepapi.node.ColorValue]
super(InvalidColor, self).__init__('Invalid color: {}. Available colors: {}'.format(
invalid_color, ', '.join(colors)
))
def get_color(color):
if not color:
return
color = color.title()
if color and not hasattr(gkeepapi.node.ColorValue, color):
raise InvalidColor(color)
return getattr(gkeepapi.node.ColorValue, color)
# -*- coding: utf-8 -*-
import click
import gkeepapi
import sys
from google_keep_tasks.exceptions import InvalidColor
from google_keep_tasks.management import cli
COLORS = {
gkeepapi.node.ColorValue.Gray: {'bg': 'black', 'fg': 'white'},
gkeepapi.node.ColorValue.Red: {'bg': 'red', 'fg': 'white'},
gkeepapi.node.ColorValue.Green: {'bg': 'green'},
gkeepapi.node.ColorValue.Yellow: {'bg': 'green', 'fg': 'black'},
gkeepapi.node.ColorValue.Blue: {'bg': 'cyan', 'fg': 'white'},
gkeepapi.node.ColorValue.DarkBlue: {'bg': 'blue', 'fg': 'white'},
gkeepapi.node.ColorValue.Purple: {'bg': 'magenta', 'fg': 'white'},
gkeepapi.node.ColorValue.White: {'bg': 'white', 'fg': 'black'},
}
def get_color(color):
if not color:
return
color = color.title()
if color and not hasattr(gkeepapi.node.ColorValue, color):
raise InvalidColor(color)
import gkeepapi
import enum
class Attribute(enum.Enum):
Title = 'title'
Text = 'text'
Selected = 'selected'
TextColor = ('', '#222')
MutedColor = ('', '#666')
ColorMap = {
gkeepapi.node.ColorValue.White: ('white', 'h231'),
gkeepapi.node.ColorValue.Red: ('dark red', 'h210'),
gkeepapi.node.ColorValue.Orange: ('light red', 'h222'),
gkeepapi.node.ColorValue.Yellow: ('yellow', 'h228'),
gkeepapi.node.ColorValue.Green: ('dark green', 'h192'),
gkeepapi.node.ColorValue.Teal: ('dark cyan', 'h159'),
gkeepapi.node.ColorValue.Blue: ('light blue', 'h117'),
gkeepapi.node.ColorValue.DarkBlue: ('dark blue', 'h111'),
gkeepapi.node.ColorValue.Purple: ('dark magenta', 'h141'),
gkeepapi.node.ColorValue.Pink: ('light magenta', 'h218'),
gkeepapi.node.ColorValue.Brown: ('brown', 'h181'),
gkeepapi.node.ColorValue.Gray: ('light gray', 'h188'),
}
def _(*attrs):
return ','.join(attrs)
Palette = [
(Attribute.Selected.value, 'black', 'dark gray', '', TextColor[1], 'h242'),
raw = config.get('labels', [])
if raw:
for i in raw:
l = keep.findLabel(i)
labels.append(l)
if l is None:
logger.warning('Label not found: %s', i)
config['labels'] = labels
if 'colors' in config:
colors = []
for i in config.get('colors', []):
try:
c = gkeepapi.node.ColorValue(i.upper())
colors.append(c)
except ValueError:
logger.warning('Color not found: %s', i)
config['colors'] = colors
return cls(name, query, labels, colors, pinned, archived, trashed)
# -*- coding: utf-8 -*-
import click
import gkeepapi
import sys
from google_keep_tasks.exceptions import InvalidColor
from google_keep_tasks.management import cli
COLORS = {
gkeepapi.node.ColorValue.Gray: {'bg': 'black', 'fg': 'white'},
gkeepapi.node.ColorValue.Red: {'bg': 'red', 'fg': 'white'},
gkeepapi.node.ColorValue.Green: {'bg': 'green'},
gkeepapi.node.ColorValue.Yellow: {'bg': 'green', 'fg': 'black'},
gkeepapi.node.ColorValue.Blue: {'bg': 'cyan', 'fg': 'white'},
gkeepapi.node.ColorValue.DarkBlue: {'bg': 'blue', 'fg': 'white'},
gkeepapi.node.ColorValue.Purple: {'bg': 'magenta', 'fg': 'white'},
gkeepapi.node.ColorValue.White: {'bg': 'white', 'fg': 'black'},
}
def get_color(color):
if not color:
return
color = color.title()
if color and not hasattr(gkeepapi.node.ColorValue, color):
raise InvalidColor(color)
return getattr(gkeepapi.node.ColorValue, color)
def get_click_color(ctx, param, value):
def _load(self, raw):
super(TopLevelNode, self)._load(raw)
self._color = ColorValue(raw['color']) if 'color' in raw else ColorValue.White
self._archived = raw['isArchived'] if 'isArchived' in raw else False
self._pinned = raw['isPinned'] if 'isPinned' in raw else False
self._title = raw['title'] if 'title' in raw else ''
self.labels.load(raw['labelIds'] if 'labelIds' in raw else [])
self.collaborators.load(
raw['roleInfo'] if 'roleInfo' in raw else [],
raw['shareRequests'] if 'shareRequests' in raw else [],
)
self.moved = 'moved' in raw