Modifiche da casa

Leonardo Robol [2009-04-11 08:44]
Modifiche da casa
Filename
latex_manager.py
songbook-editor.mm
songbook-editor.py
diff --git a/latex_manager.py b/latex_manager.py
index 089adff..080cc7b 100644
--- a/latex_manager.py
+++ b/latex_manager.py
@@ -14,8 +14,6 @@ class latex_manager():
         year = song.year
         body = song.body

-        # We really have to assume that latex_song is unicode,
-        # or the write() function will eat us!
         latex_song = unicode()
         latex_song += "\\begin{song}{" + title + "}{" + tone + "}\n{" + mauthor + "}\n{" + tauthor + "}\n{" + year + "}" + "{}\n\n\\index{" + title + "}\n\n"

@@ -31,13 +29,8 @@ class latex_manager():

         latex_song += "\n\\end{song}\n\n"

-        # Transform chords in LaTeX Chords
         latex_song = re.sub("\[", "\\Ch{", latex_song)
-        latex_song = re.sub("\](\w|\s)(\w|\s)(\w|\s)", self.quadra_to_chord_end, latex_song)
         latex_song = re.sub("\]", "}{}", latex_song)

         return latex_song

-    def quadra_to_chord_end(self,m):
-        st = "}{" + m.group(1) + m.group(2) + m.group(3) + "}"
-        return st
diff --git a/songbook-editor.mm b/songbook-editor.mm
index 762df77..fb1dc53 100644
--- a/songbook-editor.mm
+++ b/songbook-editor.mm
@@ -1,29 +1,3 @@
-<map version="0.8.1">
-<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
-<node CREATED="1239034895868" ID="Freemind_Link_739180779" MODIFIED="1239034895868" TEXT="songbook-editor">
-<node CREATED="1239034934904" ID="_" MODIFIED="1239035024317" POSITION="right" TEXT="Gui (Qt4)">
-<node CREATED="1239035003332" ID="Freemind_Link_1180804855" MODIFIED="1239035014249" TEXT="Main Interface (sb_ui_main)"/>
-</node>
-<node CREATED="1239034941681" ID="Freemind_Link_1356515582" MODIFIED="1239035056122" POSITION="left" TEXT="Database manager (db_manager)">
-<node CREATED="1239035033190" ID="Freemind_Link_1712495053" MODIFIED="1239035081089" TEXT="db_handle open_db(db_file)"/>
-<node CREATED="1239035058295" ID="Freemind_Link_1940751595" MODIFIED="1239035283765" TEXT="list (of the ids) get_song_list(db_handle)"/>
-<node CREATED="1239035264263" ID="Freemind_Link_53846481" MODIFIED="1239035271810" TEXT="song get_song(song id)"/>
-</node>
-<node CREATED="1239034952871" ID="Freemind_Link_1926893403" MODIFIED="1239035426003" POSITION="right" TEXT="Latex manager (latex_manager)">
-<node CREATED="1239035294950" ID="Freemind_Link_503132419" MODIFIED="1239035385245" TEXT="string create_song(title, tone, music_author, year, text_author, body)"/>
-<node CREATED="1239035351548" ID="Freemind_Link_1399665608" MODIFIED="1239035382460" TEXT="string create latex_file(song list)"/>
-<node CREATED="1239035366322" ID="Freemind_Link_392950854" MODIFIED="1239035393247" TEXT="create_pdf( latex file , output_file)"/>
-</node>
-<node CREATED="1239035150522" ID="Freemind_Link_375303865" MODIFIED="1239035413653" POSITION="left" TEXT="Objects to code">
-<node CREATED="1239035156782" ID="Freemind_Link_287717029" MODIFIED="1239035164040" TEXT="song">
-<node CREATED="1239035166245" ID="Freemind_Link_1499777462" MODIFIED="1239035182358" TEXT="string title"/>
-<node CREATED="1239035184178" ID="Freemind_Link_1224648272" MODIFIED="1239035189216" TEXT="string body"/>
-<node CREATED="1239035195308" ID="Freemind_Link_320877804" MODIFIED="1239035200016" TEXT="string tone"/>
-<node CREATED="1239035201206" ID="Freemind_Link_243105388" MODIFIED="1239035231172" TEXT="string music_author"/>
-<node CREATED="1239035203978" ID="Freemind_Link_1251519353" MODIFIED="1239035212122" TEXT="string year"/>
-<node CREATED="1239035213050" ID="Freemind_Link_758572264" MODIFIED="1239035347723" TEXT="string text_author"/>
-<node CREATED="1239035234087" ID="Freemind_Link_1629588697" MODIFIED="1239035245966" TEXT="Methods to get this data :)"/>
-</node>
-</node>
-</node>
+<map version="0.7.1">
+<node TEXT="songbook-editor"/>
 </map>
diff --git a/songbook-editor.py b/songbook-editor.py
index 49f301e..e69de29 100755
--- a/songbook-editor.py
+++ b/songbook-editor.py
@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-
-from PyQt4 import QtGui, QtCore
-from interface import *
-from song import *
-from latex_manager import *
-import re
-
-class interface(QtGui.QMainWindow):
-    def __init__(self, lm, parent=None):
-        super(interface, self).__init__(parent)
-        self.ui = Ui_MainWindow()
-        self.ui.setupUi(self)
-
-        # Connections
-        self.connect(self.ui.actionEsci_2, QtCore.SIGNAL("activated()"), self.exit_called)
-        self.connect(self.ui.btn_create_latex_song, QtCore.SIGNAL("clicked()"), self.create_latex_song)
-
-    # Functions to manage events
-    def exit_called(self):
-        print "TODO: Save data on exit"
-
-    def get_active_song(self):
-        newtitle = unicode(self.ui.le_title.text())
-        newmauthor = unicode(self.ui.le_mauthor.text())
-        newtauthor = unicode(self.ui.le_tauthor.text())
-        newyear = unicode(self.ui.le_year.text())
-        newtone = unicode(self.ui.le_tone.text())
-        newsong = song(newtitle, [], newmauthor, newtauthor, newtone, newyear)
-
-        newbody = unicode(self.ui.te_body.toPlainText())
-        print newbody
-        newbody = re.split("\n\n+", newbody)
-        for paragraph in newbody:
-            if(len(paragraph) < 3):
-                break
-            if( (paragraph[0] == 'R') & (paragraph[1] == ':') ):
-                newsong.add_chorus(paragraph.split("R:")[1])
-            else:
-                newsong.add_verse(paragraph)
-
-        return newsong
-
-    def create_latex_song(self):
-        song = self.get_active_song()
-        filetowrite = lm.create_song(song)
-        filename = QtGui.QFileDialog.getSaveFileName(self, "Salva file latex", "/home/leonardo", "LaTeX Source File (*.tex)")
-        handle = open(filename, 'w')
-        # Just remember that filetowrite is an "unicode" object, treat it
-        # as it just deserve
-        handle.write(filetowrite.encode("utf-8"))
-        handle.close()
-
-
-
-
-
-if __name__ == "__main__":
-    app = QtGui.QApplication(None)
-    lm = latex_manager()
-    widget = interface(lm)
-    widget.show()
-    app.exec_()
ViewGit