1. Wagner Sartori Junior
  2. clevernote

Commits

trunet  committed e2195fc

initial cat command to show note content

  • Participants
  • Parent commits c63d1ae
  • Branches default

Comments (0)

Files changed (2)

File clNotes.py

View file
 import thrift.protocol.TBinaryProtocol as TBinaryProtocol
 import thrift.transport.THttpClient as THttpClient
 import evernote.edam.notestore.NoteStore as NoteStore
+import evernote.edam.notestore.ttypes as NoteTypes
 from clConst import clConst
 
 class clNotes:
 			self.syncNotes()
 		return self.noteList.notes
 
+	def getNote(self, title):
+		try:
+			self.noteList
+		except:
+			self.syncNotes()
+		filter = NoteTypes.NoteFilter()
+		#This is not working and I don't know why
+		#I can't filter with notebookGuid AND words
+		#filter.notebookGuid = self.notebook.guid
+		filter.words = title
+		note = self.noteStore.findNotes(self.auth.getAuthToken(), filter, 0, 9999)
+		if (len(note.notes) == 1):
+			return note.notes[0]
+		else:
+			return False

File clevernote.py

View file
 			self.notebooks = clNotebooks(self.auth)
 		self.notebooks.deleteNotebook(line)
 
+	def do_cat(self, line):
+		try:
+			self.notebook
+		except:
+			print "You're not in a notebook."
+		else:
+			try:
+				self.notes
+			except:
+				self.notes = clNotes(self.auth, self.notebook)
+			note = self.notes.getNote(line)
+		if note:
+			print "Title:", note.title
+			print note.content
+		else:
+			print "Note not found."
+
 	def onecmd(self, line):
 		if line.strip().startswith("conn") or line.strip().startswith("help"):
 			super(Clevernote, self).onecmd(line)