def _parseInput(self, title=None, content=None, tags=None, notebook=None, resources=None, note=None): result = { "title": title, "content": content, "tags": tags, "notebook": notebook, "resources": resources, } result = tools.strip(result) # if get note without params if note and title is None and content is None and tags is None and notebook is None: content = config.EDITOR_OPEN if title is None and note: result['title'] = note.title if content: content = Editor.textToENML(content, format='other') result['content'] = content ''' if content != config.EDITOR_OPEN: if isinstance(content, str) and os.path.isfile(content): logging.debug("Load content from the file") content = open(content, "r").read() logging.debug("Convert content") ''' if tags: result['tags'] = tools.strip(tags.split(',')) if notebook: #notepadGuid = Notebooks().getNoteGUID(notebook) notepadGuid = self.getNoteGUID(notebook) if notepadGuid is None: #newNotepad = Notebooks().create(notebook) newNotepad = self.create(notebook) notepadGuid = newNotepad.guid result['notebook'] = notepadGuid logging.debug("Search notebook") return result
def _parseInput(self, title=None, content=None, tags=None, notebook=None, resources=None, note=None): result = { "title": title, "content": content, "tags": tags, "notebook": notebook, "resources": resources, } result = tools.strip(result) # if get note without params if note and title is None and content is None and tags is None and notebook is None: content = config.EDITOR_OPEN if title is None and note: result['title'] = note.title if content: content = Editor.textToENML(content,format='other') result['content'] = content ''' if content != config.EDITOR_OPEN: if isinstance(content, str) and os.path.isfile(content): logging.debug("Load content from the file") content = open(content, "r").read() logging.debug("Convert content") ''' if tags: result['tags'] = tools.strip(tags.split(',')) if notebook: #notepadGuid = Notebooks().getNoteGUID(notebook) notepadGuid = self.getNoteGUID(notebook) if notepadGuid is None: #newNotepad = Notebooks().create(notebook) newNotepad = self.create(notebook) notepadGuid = newNotepad.guid result['notebook'] = notepadGuid logging.debug("Search notebook") return result
def test_strip_str_data_success(self): data = 'text text text \t\n\r\"\'' self.assertEquals(strip(data), 'text text text')
def test_strip_dict_data_success(self): data = {'key \t\n\r\"\'': 'test'} self.assertEquals(strip(data), {'key': 'test'})
def test_strip_list_data_success(self): data = ['key \t\n\r\"\'', 'value \t\n\r\"\''] self.assertEquals(strip(data), ['key', 'value'])
def test_strip_none_data_success(self): self.assertFalse(strip(None))