コード例 #1
0
ファイル: evnwidgets.py プロジェクト: rdhyee/cos-integration
    def handle_save(self, b):

        if self.note is None:
            # create new note
            if not self.title_w.value:
                self.title_w.value = 'Untitled'
            self.content = self.body_w.value
            body = markdown2.markdown(self.content, extras=self.extras)
            try:
                self.note = self.ewu.create_note(self.title_w.value, body, notebookGuid=self.notebook_w.value)
            except Exception as e:
                self.status_w.value = str(e) # should get this right
        else:
            # figure out new changes
            # pass body if it has changed
            if not self.title_w.value:
                self.title_w.value = 'Untitled'
            if self.body_w.value <> self.content:
                try:
                    self.content = self.body_w.value
                    body = markdown2.markdown(self.content, extras=self.extras)
                    self.note = ewu.update_note(self.note, title=self.title_w.value, 
                                                content=body, notebookGuid=self.notebook_w.value)
                except Exception as e:
                    self.status_w.value = str(e) # should get this right
            else:
                try:
                    self.note = ewu.update_note(self.note, title=self.title_w.value, 
                                                notebookGuid=self.notebook_w.value)
                except Exception as e:
                    self.status_w.value = str(e) # should get this right
コード例 #2
0
ファイル: evnwidgets.py プロジェクト: rdhyee/cos-integration
    def handle_save(self, b):

        if self.note is None:
            # create new note
            if not self.title_w.value:
                self.title_w.value = 'Untitled'
            self.content = self.body_w.value
            body = markdown2.markdown(self.content, extras=self.extras)
            try:
                # use default notebook for now -- have to figure out how to wire notebook selection in
                self.note = self.ewu.create_note(self.title_w.value, body)
            except Exception as e:
                print(e)
                
        else:
            # figure out new changes
            # pass body if it has changed
            if not self.title_w.value:
                self.title_w.value = 'Untitled'
            if self.body_w.value <> self.content:
                try:
                    self.content = self.body_w.value
                    body = markdown2.markdown(self.content, extras=self.extras)
                    self.note = ewu.update_note(self.note, title=self.title_w.value, 
                                                content=body)
                except Exception as e:
                    print (e)
                    
            else:
                try:
                    self.note = ewu.update_note(self.note, title=self.title_w.value)
                except Exception as e:
                    print (e)