예제 #1
0
파일: note.py 프로젝트: HazenBabcock/APyEC
    def saveNote(self, note_content, use_current_time = True):
        """
        Save XML and create a git commit.
        """

        # Save XML.
        xml = ElementTree.Element("note")
        note_content.contentToXML(xml, use_current_time)
        misc.pSaveXML(self.fullname, xml)
        
        # git commit.
        misc.gitAddCommit(self.notebook.getDirectory(),
                          self.filename,
                          "update " + self.name)

        # Append current version to the list of versions.
        self.versions.append(misc.gitGetLastCommitId(self.notebook.getDirectory()))
        self.setText(self.name + " (" + str(len(self.versions)) +")")

        # Check if the keywords have changed.
        self.checkKeywords(note_content)

        # For now, keywords are always from the most recently saved
        # version of the note. This may need improvement down the road?
        self.keywords = list(note_content.getKeywords())

        self.notebook.setUnpushed()
예제 #2
0
    def rename(self, new_name):
        self.name = str(new_name)
        self.setText(new_name)
        
        # Update the XML and commit.
        xml = ElementTree.Element("notebook")
        name_xml = ElementTree.SubElement(xml, "name")
        name_xml.text = self.name

        misc.pSaveXML(self.directory + "notebook.xml", xml)
        misc.gitAddCommit(self.directory, self.directory + "notebook.xml", "rename notebook.")

        self.setUnpushed()
예제 #3
0
    def createWithName(self, notebook_name, username, email):
        self.name = notebook_name
        self.uuid = str(uuid.uuid1())
        self.setText(self.name)

        self.directory += self.uuid
        os.makedirs(self.directory)

        xml = ElementTree.Element("notebook")
        name_xml = ElementTree.SubElement(xml, "name")
        name_xml.text = self.name

        self.directory += "/"
        misc.pSaveXML(self.directory + "notebook.xml", xml)

        # Create a new git repository for this notebook.
        misc.gitInit(self.directory, username, email)

        # Commit the notebook name.
        misc.gitAddCommit(self.directory, self.directory + "notebook.xml", "add notebook.")

        self.has_unpushed = True
        self.setToolTip(self.directory)