def createNote(title,content,tags,notebook,geeknote=None,\ skipnotebook=False): #-------------------Trunc texts------------------- notebook=notebook.strip() notebook=truncStr(notebook,MAX_NOTEBOOK_TITLE_LEN) title=title.strip() title=truncStr(title,MAX_NOTE_TITLE_LEN) #-------Make sure title doesnt start with #------- tp=textparse.TextParser('markdown') _h_re=re.compile(tp._h_re_base %'1,', re.X | re.M) m=_h_re.match(title) if m: title=m.group(6) m=_h_re.match(notebook) if m: notebook=m.group(6) if tags is not None and len(tags.split(','))>=MAX_NOTE_TAGS: tags=u','.join(tags.split(',')[:MAX_NOTE_TAGS]) #---------------------Connect--------------------- if geeknote is None: geeknote=GeekNoteConnector() geeknote.connectToEvertone() #-----------------Create notebook----------------- if not skipnotebook: result=createNoteBook(notebook,geeknote) if skipnotebook or result==0: #----------------------Write---------------------- inputdata=geeknote._parseInput(title,content,tags,notebook,None) out.preloader.setMessage('Creating note...') result=bool(geeknote.getEvernote().createNote(**inputdata)) if result: out.successMessage("Note has been successfully saved.") else: out.failureMessage("Error while saving the note.")
def createNote(title,content,tags,notebook,geeknote=None,\ skipnotebook=False): #-------------------Trunc texts------------------- notebook = notebook.strip() notebook = truncStr(notebook, MAX_NOTEBOOK_TITLE_LEN) title = title.strip() title = truncStr(title, MAX_NOTE_TITLE_LEN) #-------Make sure title doesnt start with #------- tp = textparse.TextParser('markdown') _h_re = re.compile(tp._h_re_base % '1,', re.X | re.M) m = _h_re.match(title) if m: title = m.group(6) m = _h_re.match(notebook) if m: notebook = m.group(6) if tags is not None and len(tags.split(',')) >= MAX_NOTE_TAGS: tags = u','.join(tags.split(',')[:MAX_NOTE_TAGS]) #---------------------Connect--------------------- if geeknote is None: geeknote = GeekNoteConnector() geeknote.connectToEvertone() #-----------------Create notebook----------------- if not skipnotebook: result = createNoteBook(notebook, geeknote) if skipnotebook or result == 0: #----------------------Write---------------------- inputdata = geeknote._parseInput(title, content, tags, notebook, None) out.preloader.setMessage('Creating note...') result = bool(geeknote.getEvernote().createNote(**inputdata)) if result: out.successMessage("Note has been successfully saved.") else: out.failureMessage("Error while saving the note.")
def createNoteBook(title,geeknote=None,verbose=True): #-------------------Trunc title------------------- title=title.strip() title=truncStr(title,MAX_NOTEBOOK_TITLE_LEN) #-------Make sure title doesnt start with #------- tp=textparse.TextParser('markdown') _h_re=re.compile(tp._h_re_base %'1,', re.X | re.M) m=_h_re.match(title) if m: title=m.group(6) #---------------------Connect--------------------- if geeknote is None: geeknote=GeekNoteConnector() geeknote.connectToEvertone() #-----------------Check if exists----------------- notebooks=geeknote.getEvernote().findNotebooks() out.preloader.stop() if not isinstance(title,unicode): title=unicode(title,'utf8') notebooks=[unicode(ii.name,'utf8') for ii in notebooks] if title in notebooks: out.successMessage('Notebook already exists.') return 0 else: out.preloader.setMessage("Creating notebook...") result = geeknote.getEvernote().createNotebook(name=title) if result: out.successMessage("Notebook has been successfully created.") return 0 else: out.failureMessage("Error while the process " "of creating the notebook.") return tools.exitErr()
def createNoteBook(title, geeknote=None, verbose=True): #-------------------Trunc title------------------- title = title.strip() title = truncStr(title, MAX_NOTEBOOK_TITLE_LEN) #-------Make sure title doesnt start with #------- tp = textparse.TextParser('markdown') _h_re = re.compile(tp._h_re_base % '1,', re.X | re.M) m = _h_re.match(title) if m: title = m.group(6) #---------------------Connect--------------------- if geeknote is None: geeknote = GeekNoteConnector() geeknote.connectToEvertone() #-----------------Check if exists----------------- notebooks = geeknote.getEvernote().findNotebooks() out.preloader.stop() if not isinstance(title, unicode): title = unicode(title, 'utf8') notebooks = [unicode(ii.name, 'utf8') for ii in notebooks] if title in notebooks: out.successMessage('Notebook already exists.') return 0 else: out.preloader.setMessage("Creating notebook...") result = geeknote.getEvernote().createNotebook(name=title) if result: out.successMessage("Notebook has been successfully created.") return 0 else: out.failureMessage("Error while the process " "of creating the notebook.") return tools.exitErr()
def test_success_message_success(self): successMessage('success') sys.stdout.seek(0) self.assertEquals(sys.stdout.read(), 'success\n')