本文整理汇总了Python中everpad.basetypes.Note类的典型用法代码示例。如果您正苦于以下问题:Python Note类的具体用法?Python Note怎么用?Python Note使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Note类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_alternatives
def init_alternatives(self):
try:
conflict_items = self.app.provider.get_note_alternatives(self.note.id)
if conflict_items:
template = self.ui.alternativeVersions.text()
conflicts = map(
lambda item: Note.from_tuple(self.app.provider.get_note(
item,
)), self.note.conflict_items,
)
text = template % ', '.join(map(
lambda note: '<a href="%d">%s</a>' % (
note.id, note.title,
), conflicts,
))
self.ui.alternativeVersions.setText(text)
self.ui.alternativeVersions.linkActivated.connect(
lambda id: self.app.indicator.open(
Note.from_tuple(self.app.provider.get_note(int(id))),
)
)
else:
self.ui.alternativeVersions.hide()
except DBusException:
self.ui.alternativeVersions.hide()
示例2: test_notes_with_notebook_and_places
def test_notes_with_notebook_and_places(self):
"""Test notes with notebook and places"""
notebook = Notebook.from_tuple(
self.service.create_notebook('test', None),
)
notes = []
get_place = lambda num: '123' if num < 50 else '456'
for i in range(100):
notes.append(Note.from_tuple(self.service.create_note(Note(
id=NONE_ID,
title='New note',
content="New note content",
tags=['123', '345'],
notebook=notebook.id,
created=NONE_VAL,
updated=NONE_VAL,
place=get_place(i),
).struct)))
filtered = []
for num, note in enumerate(notes):
if not num % 2:
self.service.update_note(note.struct) # mark note exist
filtered.append(note)
notes = filtered # notes.remove(note) not work, wtf
self.assertEqual(
self._to_ids(notes), self._to_ids(map(
Note.from_tuple, self.service.find_notes(
'', dbus.Array([], signature='i'),
dbus.Array([], signature='i'), 0,
100, Note.ORDER_UPDATED_DESC, -1,
),
)),
)
filtered = []
for num, note in enumerate(notes):
note.title += '*'
if num % 2:
self.service.delete_note(note.id)
with self.assertRaises(DBusException):
self.service.update_note(note.struct)
else:
updated = Note.from_tuple(
self.service.update_note(note.struct),
)
self.assertEqual(note.title, updated.title)
filtered.append(updated)
self.assertEqual(len(filtered),
self.service.get_notebook_notes_count(notebook.id),
)
self.assertEqual(set(['123', '456']), set(map(
lambda place: Place.from_tuple(place).name,
self.service.list_places(),
)))
示例3: match
def match(self, context):
if not context.isValid():
return
query = context.query()
search = query.__str__() # PyQt is shit
if len(search) < 3:
return
if search.lower() in 'create note':
action = Plasma.QueryMatch(self.runner)
action.setText("Create new note in everpad")
action.setType(Plasma.QueryMatch.ExactMatch)
action.setIcon(KIcon("everpad"))
action.setData(str(CREATE))
context.addMatch(query, action)
if search.lower() in 'settings and management':
action = Plasma.QueryMatch(self.runner)
action.setText("Open everpad settings")
action.setType(Plasma.QueryMatch.ExactMatch)
action.setIcon(KIcon("everpad"))
action.setData(str(SETTINGS))
context.addMatch(query, action)
blank = dbus.Array([], signature='i')
for note_struct in provider.find_notes(
search, blank, blank, 0,
1000, Note.ORDER_TITLE, -1,
):
note = Note.from_tuple(note_struct)
action = Plasma.QueryMatch(self.runner)
action.setText(note.title)
action.setSubtext(html2text(note.content))
action.setType(Plasma.QueryMatch.ExactMatch)
action.setIcon(KIcon("everpad"))
action.setData(str(note.id))
context.addMatch(query, action)
示例4: update_title
def update_title(self):
title = self.note_edit.title
if self.note.conflict_parent:
title += self.tr(" alternative of: %s") % (
Note.from_tuple(self.app.provider.get_note(self.note.conflict_parent)).title,
)
self.setWindowTitle(self.tr("Everpad / %s") % title)
示例5: notebook_selected
def notebook_selected(self, index):
self.notesModel.setRowCount(0)
item = self.notebooksModel.itemFromIndex(index)
if hasattr(item, 'notebook'):
notebook_id = item.notebook.id
else:
notebook_id = 0
notebook_filter = [notebook_id] if notebook_id > 0 else dbus.Array([], signature='i')
notes = self.app.provider.find_notes(
'', notebook_filter, dbus.Array([], signature='i'),
0, 2 ** 31 - 1, Note.ORDER_TITLE, -1,
) # fails with sys.maxint in 64
for note_struct in notes:
note = Note.from_tuple(note_struct)
self.notesModel.appendRow(QNoteItemFactory(note).make_items())
sort_order = self.sort_order
if sort_order is None:
sort_order = self.app.settings.value('list-notes-sort-order')
if sort_order:
logicalIndex, order = sort_order
order = Qt.SortOrder.values[order]
self.ui.notesList.sortByColumn(int(logicalIndex), order)
示例6: link_clicked
def link_clicked(self, url):
if url.scheme() == 'evernote':
note_guid = url.toString().split('/')[6]
note = Note.from_tuple(
self.app.provider.get_note_by_guid(note_guid),
)
self.app.open(note)
else:
webbrowser.open(url.toString())
示例7: search_all
def search_all(search, results):
for note_struct in provider.find_notes(
search, dbus.Array([], signature="i"), dbus.Array([], signature="i"), 0, 100, Note.ORDER_TITLE, -1
):
note = Note.from_tuple(note_struct)
# TODO: Fix so it can return system lang encoding
tags = ", ".join([tag.title().encode("ascii", errors="replace") for tag in note.tags])
results.append(
u"%s%s%s%s%s"
% (note.id, SPLIT_CHARACTER, tags, SPLIT_CHARACTER, note.title.encode("ascii", errors="replace"))
)
示例8: create
def create(self, attach=None):
note_struct = Note( # maybe replace NONE's to somthing better
id=NONE_ID,
title=self.tr("New note"),
content=self.tr("New note content"),
tags=dbus.Array([], signature="i"),
notebook=NONE_ID,
created=NONE_VAL,
updated=NONE_VAL,
place="",
).struct
note = Note.from_tuple(self.app.provider.create_note(note_struct))
editor = self.open(note)
if attach:
editor.resource_edit.add_attach(attach)
示例9: preview
def preview(self, scope, uri):
obj = json.loads(uri)
note = Note.from_tuple(provider.get_note(obj['id']))
preview = Unity.GenericPreview.new(
note.title, html2text(note.content), None,
)
edit = Unity.PreviewAction.new("edit", "Edit", None)
image = None
for _res in provider.get_note_resources(note.id):
res = Resource.from_tuple(_res)
if 'image' in res.mime:
image = 'file://%s' % res.file_path
if image:
preview.props.image_source_uri = image
edit.connect('activated', self.handle_uri)
preview.add_action(edit)
return preview
示例10: __init__
def __init__(self, note, *args, **kwargs):
"""init dialog and connect signals"""
QDialog.__init__(self, *args, **kwargs)
self.app = QApplication.instance()
self.canceled = False
self.ui = Ui_ShareNote()
self.ui.setupUi(self)
self.setWindowIcon(get_icon())
self.note = Note.from_tuple(
self.app.provider.get_note(note.id),
)
self.app.data_changed.connect(self.data_changed)
self.ui.cancelButton.clicked.connect(self.cancel)
self.ui.copyButton.clicked.connect(self.copy_url)
if not self.note.share_url:
self.start_sharing()
self.update()
示例11: search
def search(self, search, results):
if self.notebook_filter_id:
notebooks = [self.notebook_filter_id]
else:
notebooks = dbus.Array([], signature='i')
if self.place_filter_id:
place = self.place_filter_id
else:
place = 0
tags = dbus.Array(self.tag_filter_ids, signature='i')
for note_struct in provider.find_notes(
search, notebooks, tags, place,
100, Note.ORDER_TITLE,
):
note = Note.from_tuple(note_struct)
results.append(str(note.id),
'everpad-note', self.category, "text/html", note.title,
''.join(BeautifulSoup(note.content).findAll(text=True)),
'')
示例12: setUp
def setUp(self):
self.service = ProviderService()
self.service._session = get_db_session()
models.Note.session = self.service._session
self.app = app
app.update(self.service)
notebook = Notebook.from_tuple(
self.service.create_notebook('test', None),
)
self.note = Note.from_tuple(self.service.create_note(Note(
id=NONE_ID,
title='New note',
content="New note content",
tags=[],
notebook=notebook.id,
created=NONE_VAL,
updated=NONE_VAL,
place='',
).struct))
示例13: test_note_resources
def test_note_resources(self):
"""Test note resources"""
notebook = Notebook.from_tuple(
self.service.create_notebook('test', None),
)
struct = self.service.create_note(Note(
id=NONE_ID,
title='New note',
content="New note content",
tags=[],
notebook=notebook.id,
created=NONE_VAL,
updated=NONE_VAL,
place='',
).struct)
note = Note.from_tuple(self.service.update_note(struct))
resources = []
for i in range(100):
resources.append(Resource(
id=NONE_ID,
file_name="name/%d" % i,
file_path="path/%d" % i,
mime='image/png',
hash='',
))
self.service.update_note_resources(note.struct,
map(lambda resource: resource.struct, resources),
)
received = map(Resource.from_tuple,
self.service.get_note_resources(note.id))
self.assertEqual(
self._file_names(resources), self._file_names(received),
)
received = received[:50]
self.service.update_note_resources(note.struct,
map(lambda resource: resource.struct, received),
)
new_received = map(Resource.from_tuple,
self.service.get_note_resources(note.id))
self.assertEqual(
self._file_names(new_received), self._file_names(received),
)
示例14: update
def update(self):
self.menu.clear()
if get_auth_token():
for note_struct in self.app.provider.find_notes(
"", dbus.Array([], signature="i"), dbus.Array([], signature="i"), 0, 20, Note.ORDER_UPDATED_DESC
):
note = Note.from_tuple(note_struct)
self.menu.addAction(note.title[:40], Slot()(partial(self.open, note=note)))
self.menu.addSeparator()
self.menu.addAction(self.tr("Create Note"), self.create)
if self.app.provider.get_status() == STATUS_SYNC:
action = self.menu.addAction(self.tr("Sync in progress"))
action.setEnabled(False)
else:
self.menu.addAction(
self.tr("Last sync: %s") % self.app.provider.get_last_sync(), Slot()(self.app.provider.sync)
)
self.menu.addAction(self.tr("Settings and Management"), self.show_management)
self.menu.addSeparator()
self.menu.addAction(self.tr("Exit"), self.exit)
示例15: create
def create(self, attach=None, notebook_id=NONE_ID):
note_struct = Note( # maybe replace NONE's to somthing better
id=NONE_ID,
title=self.tr('New note'),
content=self.tr("New note content"),
tags=dbus.Array([], signature='i'),
notebook=notebook_id,
created=NONE_VAL,
updated=NONE_VAL,
conflict_parent=NONE_VAL,
conflict_items=dbus.Array([], signature='i'),
place='',
share_date=NONE_VAL,
share_url='',
).struct
note = Note.from_tuple(
self.app.provider.create_note(note_struct),
)
editor = self.open(note)
if attach:
editor.resource_edit.add_all_attach(attach)