1. Wagner Sartori Junior
  2. clevernote

Commits

trunet  committed c0847be

implemented production evernote API(no more using sandbox) and getting note content.

  • Participants
  • Parent commits e2195fc
  • Branches default

Comments (0)

Files changed (3)

File clConst.py

View file
 class clConst:
 		consumerKey = "wsartori"
 		consumerSecret = "d5115ae78bcf31df"
-		userStoreUri = "https://sandbox.evernote.com/edam/user"
-		noteStoreUriBase = "http://sandbox.evernote.com/edam/note/"
+		userStoreUri = "https://www.evernote.com/edam/user"
+		noteStoreUriBase = "http://www.evernote.com/edam/note/"

File clNotes.py

View file
 		self.noteStore = NoteStore.Client(noteStoreProtocol)
 
 	def syncNotes(self):
-		self.noteList = self.noteStore.findNotes(self.auth.getAuthToken(), self.notebook, 0, 9999)
+		filter = NoteTypes.NoteFilter()
+		filter.order = 1
+		filter.ascending = True
+		filter.notebookGuid = self.notebook.guid
+		self.noteList = self.noteStore.findNotes(self.auth.getAuthToken(), filter, 0, 9999)
 
 	def getNotes(self):
 		try:
 		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.order = 1
+		filter.ascending = True
+		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]
+			return self.noteStore.getNote(self.auth.getAuthToken(), note.notes[0].guid, True, False, False, False)
 		else:
 			return False

File clevernote.py

View file
 		elif auth and notebook:
 			self.auth = auth
 			self.notebook = notebook
+			self.notes = clNotes(self.auth, self.notebook)
 
 	def help_introduction(self):
 		print "Clevernote is a evernote command line interface"
 		try:
 			self.notebook
 		except:
-			try:
-				self.notebooks
-			except:
-				self.notebooks = clNotebooks(self.auth)
 			notebooks = self.notebooks.getNotebooks()
 			print "Found", len(notebooks), "notebooks:"
 			for notebook in notebooks:
 				print "- " + notebook.name
 		else:
-			try:
-				self.notes
-			except:
-				self.notes = clNotes(self.auth, self.notebook)
 			notes = self.notes.getNotes()
 			print "Found", len(notes), "notes:"
 			for note in notes:
 
 	def complete_ls(self, text, line, begidx, endidx):
 		try:
-			self.notebooks
+			self.notebook
 		except:
-			self.notebooks = clNotebooks(self.auth)
-		if not text:
-			nbList = []
-			[nbList.append(nb.name) for nb in self.notebooks.getNotebooks()]
-			completions = nbList
+			if not text:
+				nbList = []
+				[nbList.append(nb.name) for nb in self.notebooks.getNotebooks()]
+				completions = nbList
+			else:
+				nbList = []
+				[nbList.append(nb.name) for nb in self.notebooks.getNotebooks() if nb.name.startswith(text)]
+				completions = nbList
 		else:
-			nbList = []
-			[nbList.append(nb.name) for nb in self.notebooks.getNotebooks() if nb.name.startswith(text)]
-			completions = nbList
+			if not text:
+				noteList = []
+				[noteList.append(note.name) for note in self.notes.getNotes()]
+				completions = noteList
+			else:
+				noteList = []
+				[noteList.append(note.name) for note in self.notes.getNotes() if note.name.startswith(text)]
+				completions = noteList
 		return completions
 
 	def do_cd(self, line):
 		try:
 			self.notebook
 		except:
-			try:
-				self.notebooks
-			except:
-				self.notebooks = clNotebooks(self.auth)
 			notebook = self.notebooks.getNotebook(line)
 			if notebook:
 				notes = Clevernote(auth=self.auth, notebook=notebook)
 		else:
 			if (line == '..'):
 				return True
+			elif (line.startswith('..')):
+				#TODO:
+				#We can go to a new notebook already without
+				#have to cd again.
+				return True
 			else:
 				print "You are already in a notebook."
 
 	def complete_cd(self, text, line, begidx, endidx):
 		try:
-			self.notebooks
+			self.notebook
 		except:
-			self.notebooks = clNotebooks(self.auth)
-		if not text:
-			nbList = []
-			[nbList.append(nb.name) for nb in self.notebooks.getNotebooks()]
-			completions = nbList
+			if not text:
+				nbList = []
+				[nbList.append(nb.name) for nb in self.notebooks.getNotebooks()]
+				completions = nbList
+			else:
+				nbList = []
+				[nbList.append(nb.name) for nb in self.notebooks.getNotebooks() if nb.name.startswith(text)]
+				completions = nbList
+			return completions
 		else:
-			nbList = []
-			[nbList.append(nb.name) for nb in self.notebooks.getNotebooks() if nb.name.startswith(text)]
-			completions = nbList
-		return completions
+			pass
 
 	def help_cd(self):
 		print "Usage: cd <notebook>|.."
 		print "change the working notebook or back to root directory"
 
 	def do_mkdir(self, line):
-		try:
-			self.notebooks
-		except:
-			self.notebooks = clNotebooks(self.auth)
 		self.notebooks.createNotebook(line)
 
 	def do_rm(self, line):
-		try:
-			self.notebooks
-		except:
-			self.notebooks = clNotebooks(self.auth)
 		self.notebooks.deleteNotebook(line)
 
 	def do_cat(self, line):
 		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
 		else:
 			print "Note not found."
 
+	def complete_cat(self, text, line, begidx, endidx):
+		try:
+			self.notebook
+		except:
+			pass
+		else:
+			if not text:
+				noteList = []
+				[noteList.append(note.name) for note in self.notes.getNotes()]
+				completions = noteList
+			else:
+				noteList = []
+				[noteList.append(note.name) for note in self.notes.getNotes() if note.name.startswith(text)]
+				completions = noteList
+			return completions
+
 	def onecmd(self, line):
 		if line.strip().startswith("conn") or line.strip().startswith("help"):
 			super(Clevernote, self).onecmd(line)
 				print "Please, authenticate first"
 				return False
 			else:
+				try:
+					self.notebook
+				except:
+					try:
+						self.notebooks
+					except:
+						self.notebooks = clNotebooks(self.auth)
+				else:
+					try:
+						self.notes
+					except:
+						self.notes = clNotes(self.auth, self.notebook)
 				return super(Clevernote, self).onecmd(line)
 
 	def do_exit(self, goal):