Completed default XHTML template for exporter
authorHarishankar <v.harishankar@gmail.com>
Wed, 7 Dec 2011 05:13:46 +0000 (10:43 +0530)
committerHarishankar <v.harishankar@gmail.com>
Wed, 7 Dec 2011 05:13:46 +0000 (10:43 +0530)
Started working on exporter and completed the default XHTML
template for the exporter

biacv_exporter.py [new file with mode: 0644]
biacv_mainwindow.py
biacv_mainwindow.ui
biacv_mainwindow_ui.py
biacv_res_rc.py
templates/default_xhtml/career_bit.tpl [new file with mode: 0644]
templates/default_xhtml/education_bit.tpl [new file with mode: 0644]
templates/default_xhtml/language_bit.tpl [new file with mode: 0644]
templates/default_xhtml/main.tpl [new file with mode: 0644]
templates/default_xhtml/profession_bit.tpl [new file with mode: 0644]
templates/default_xhtml/skill_bit.tpl [new file with mode: 0644]

diff --git a/biacv_exporter.py b/biacv_exporter.py
new file mode 100644 (file)
index 0000000..43bc635
--- /dev/null
@@ -0,0 +1,36 @@
+# class to export data in BiaCV native format to any external format as
+# specified by a template set. The final document is produced by putting
+# together the template "bits" into a single document and filling in the
+# document fields.
+
+import string.Template
+
+class BiaCVExporter:
+       def __init__ (self):
+               self.data = {}
+
+       # set the document data
+       def set_data (self, data):
+               # document data
+               self.data = data
+
+       # set the template directory and the files within
+       def set_template_directory (self, templatedir):
+               # set the template file names
+
+               # main document template
+               self.fil_main = os.path.join (templatedir, "main.tpl")
+               # education qualification bit
+               self.fil_education = os.path.join (templatedir, "education_bit.tpl")
+               # profession history bit
+               self.fil_profession = os.path.join (templatedir, "profession_bit.tpl")
+               # career list bit
+               self.fil_career = os.path.join (templatedir, "career_bit.tpl")
+               # skills bit
+               self.fil_skills = os.path.join (templatedir, "skill_bit.tpl")
+               # languages learned bit
+               self.fil_language = os.path.join (templatedir, "language_bit.tpl")
+
+       # set the output file
+       def set_output (self, output):
+               self.file_output = output
index b33d689..65ed3fe 100644 (file)
@@ -34,6 +34,11 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                # call the close event
                self.close()
 
+       # on file export - export current document to any external format based on
+       # a template
+       def on_file_export (self):
+               pass
+
        # function to open a file
        def on_file_open (self):
                # if modified, confirm
index ceae00c..8f20bf2 100644 (file)
     <property name="title">
      <string>&amp;File</string>
     </property>
-    <widget class="QMenu" name="menu_Export">
-     <property name="statusTip">
-      <string>Export as HTML document</string>
-     </property>
-     <property name="title">
-      <string>&amp;Export</string>
-     </property>
-     <addaction name="action_HTML"/>
-     <addaction name="actionOpenDocument_ODT"/>
-    </widget>
     <addaction name="action_New"/>
     <addaction name="action_Open"/>
     <addaction name="separator"/>
     <addaction name="action_Save"/>
     <addaction name="actionSave_As"/>
-    <addaction name="menu_Export"/>
+    <addaction name="action_Export"/>
     <addaction name="separator"/>
     <addaction name="actionE_xit"/>
    </widget>
     <string>Show program information</string>
    </property>
   </action>
+  <action name="action_Export">
+   <property name="text">
+    <string>&amp;Export...</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="biacv_res.qrc"/>
    <slot>on_add_education()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>70</x>
-     <y>98</y>
+     <x>430</x>
+     <y>212</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_delete_education()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>100</x>
-     <y>98</y>
+     <x>662</x>
+     <y>212</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <slot>on_select_education()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>100</x>
-     <y>102</y>
+     <x>104</x>
+     <y>293</y>
     </hint>
     <hint type="destinationlabel">
      <x>726</x>
    <slot>on_update_education()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>85</x>
-     <y>98</y>
+     <x>583</x>
+     <y>212</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <slot>on_select_education()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>100</x>
-     <y>102</y>
+     <x>104</x>
+     <y>293</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_change_currentemployment()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>80</x>
-     <y>88</y>
+     <x>332</x>
+     <y>156</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <slot>on_add_profession()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>61</x>
-     <y>99</y>
+     <x>313</x>
+     <y>239</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_select_profession()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>103</y>
+     <x>103</x>
+     <y>320</y>
     </hint>
     <hint type="destinationlabel">
      <x>727</x>
    <slot>on_select_profession()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>103</y>
+     <x>103</x>
+     <y>320</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_delete_profession()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>99</y>
+     <x>600</x>
+     <y>239</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_update_profession()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>80</x>
-     <y>99</y>
+     <x>457</x>
+     <y>239</y>
     </hint>
     <hint type="destinationlabel">
      <x>726</x>
    <slot>on_add_skill()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>51</x>
-     <y>96</y>
+     <x>211</x>
+     <y>255</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_delete_skill()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>96</y>
+     <x>570</x>
+     <y>255</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <slot>on_select_skill()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>102</y>
+     <x>103</x>
+     <y>338</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_select_skill()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>102</y>
+     <x>103</x>
+     <y>338</y>
     </hint>
     <hint type="destinationlabel">
      <x>726</x>
    <slot>on_update_skill()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>75</x>
-     <y>96</y>
+     <x>390</x>
+     <y>255</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <slot>on_add_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>107</x>
-     <y>110</y>
+     <x>551</x>
+     <y>155</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_delete_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>107</x>
-     <y>110</y>
+     <x>716</x>
+     <y>155</y>
     </hint>
     <hint type="destinationlabel">
      <x>733</x>
    <slot>on_select_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>107</x>
-     <y>110</y>
+     <x>116</x>
+     <y>266</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_select_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>107</x>
-     <y>110</y>
+     <x>116</x>
+     <y>266</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_update_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>107</x>
-     <y>110</y>
+     <x>644</x>
+     <y>155</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_document_modified()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>89</y>
+     <x>103</x>
+     <y>178</y>
     </hint>
     <hint type="destinationlabel">
      <x>0</x>
    <slot>on_document_modified()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>94</x>
-     <y>102</y>
+     <x>98</x>
+     <y>374</y>
     </hint>
     <hint type="destinationlabel">
      <x>2</x>
    <slot>on_document_modified()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>98</x>
-     <y>103</y>
+     <x>102</x>
+     <y>410</y>
     </hint>
     <hint type="destinationlabel">
      <x>1</x>
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>action_Export</sender>
+   <signal>triggered()</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_file_export()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>364</x>
+     <y>248</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>on_add_education()</slot>
   <slot>on_file_save_as()</slot>
   <slot>on_exit()</slot>
   <slot>on_help_about()</slot>
+  <slot>on_file_export()</slot>
  </slots>
 </ui>
index 5665929..b0dbee9 100644 (file)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'biacv_mainwindow.ui'
 #
-# Created: Tue Dec  6 14:03:31 2011
+# Created: Tue Dec  6 18:21:16 2011
 #      by: PyQt4 UI code generator 4.8.6
 #
 # WARNING! All changes made in this file will be lost!
@@ -509,10 +509,6 @@ class Ui_biacv_mainwindow(object):
         self.menu_File = QtGui.QMenu(self.menubar)
         self.menu_File.setTitle(QtGui.QApplication.translate("biacv_mainwindow", "&File", None, QtGui.QApplication.UnicodeUTF8))
         self.menu_File.setObjectName(_fromUtf8("menu_File"))
-        self.menu_Export = QtGui.QMenu(self.menu_File)
-        self.menu_Export.setStatusTip(QtGui.QApplication.translate("biacv_mainwindow", "Export as HTML document", None, QtGui.QApplication.UnicodeUTF8))
-        self.menu_Export.setTitle(QtGui.QApplication.translate("biacv_mainwindow", "&Export", None, QtGui.QApplication.UnicodeUTF8))
-        self.menu_Export.setObjectName(_fromUtf8("menu_Export"))
         self.menu_Help = QtGui.QMenu(self.menubar)
         self.menu_Help.setTitle(QtGui.QApplication.translate("biacv_mainwindow", "&Help", None, QtGui.QApplication.UnicodeUTF8))
         self.menu_Help.setObjectName(_fromUtf8("menu_Help"))
@@ -552,14 +548,15 @@ class Ui_biacv_mainwindow(object):
         self.action_About.setText(QtGui.QApplication.translate("biacv_mainwindow", "&About", None, QtGui.QApplication.UnicodeUTF8))
         self.action_About.setStatusTip(QtGui.QApplication.translate("biacv_mainwindow", "Show program information", None, QtGui.QApplication.UnicodeUTF8))
         self.action_About.setObjectName(_fromUtf8("action_About"))
-        self.menu_Export.addAction(self.action_HTML)
-        self.menu_Export.addAction(self.actionOpenDocument_ODT)
+        self.action_Export = QtGui.QAction(biacv_mainwindow)
+        self.action_Export.setText(QtGui.QApplication.translate("biacv_mainwindow", "&Export...", None, QtGui.QApplication.UnicodeUTF8))
+        self.action_Export.setObjectName(_fromUtf8("action_Export"))
         self.menu_File.addAction(self.action_New)
         self.menu_File.addAction(self.action_Open)
         self.menu_File.addSeparator()
         self.menu_File.addAction(self.action_Save)
         self.menu_File.addAction(self.actionSave_As)
-        self.menu_File.addAction(self.menu_Export.menuAction())
+        self.menu_File.addAction(self.action_Export)
         self.menu_File.addSeparator()
         self.menu_File.addAction(self.actionE_xit)
         self.menu_Help.addAction(self.action_About)
@@ -615,6 +612,7 @@ class Ui_biacv_mainwindow(object):
         QtCore.QObject.connect(self.actionSave_As, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_save_as)
         QtCore.QObject.connect(self.actionE_xit, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_exit)
         QtCore.QObject.connect(self.action_About, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_help_about)
+        QtCore.QObject.connect(self.action_Export, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_export)
         QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow)
 
     def retranslateUi(self, biacv_mainwindow):
index a4cc8e9..4e0ffaf 100644 (file)
@@ -2,7 +2,7 @@
 
 # Resource object code
 #
-# Created: Tue Dec 6 14:04:06 2011
+# Created: Tue Dec 6 18:17:10 2011
 #      by: The Resource Compiler for PyQt (Qt v4.7.3)
 #
 # WARNING! All changes made in this file will be lost!
diff --git a/templates/default_xhtml/career_bit.tpl b/templates/default_xhtml/career_bit.tpl
new file mode 100644 (file)
index 0000000..53a3cd3
--- /dev/null
@@ -0,0 +1 @@
+               <li>${careerobjective_item}</li>
\ No newline at end of file
diff --git a/templates/default_xhtml/education_bit.tpl b/templates/default_xhtml/education_bit.tpl
new file mode 100644 (file)
index 0000000..8ed3b10
--- /dev/null
@@ -0,0 +1,8 @@
+               <tr>
+                       <td>${degree}</td>
+                       <td>${dateofpassing}</td>
+                       <td>${institution}</td>
+                       <td>${university}</td>
+                       <td>${grade}</td>
+                       <td>${percentage}</td>
+               </tr>
\ No newline at end of file
diff --git a/templates/default_xhtml/language_bit.tpl b/templates/default_xhtml/language_bit.tpl
new file mode 100644 (file)
index 0000000..e633267
--- /dev/null
@@ -0,0 +1 @@
+               <li><b>${language}</b> - ${languagedesc}</li>
\ No newline at end of file
diff --git a/templates/default_xhtml/main.tpl b/templates/default_xhtml/main.tpl
new file mode 100644 (file)
index 0000000..65eda93
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?> 
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+       <title>${title}</title>
+       <style>
+               body { background-color: white; color: black; font-family: serif; font-size: 100% }
+               table.personal { width: 100%; background-color: #eeeeee; font-size: 90% }
+               table.contact { width: 100% }
+               table.education { width: 100% }
+               .education thead { background-color: #eeeeee; }
+               ul { list-style-type: square; }
+               h1 { text-align: center; font-family: sans-serif; font-size: 210%; color: darkblue; }
+               h2 { border-bottom: solid; font-family:  sans-serif; font-size: 140% }
+               h3 { font-family:  sans-serif; font-size:  120% }
+               td { vertical-align: top; }
+               .miscinfo { text-align: center; font-size: 110%; font-style: italic; }
+               .signature { font-size: 120%; font-variant: small-caps; }
+               .designation {font-size: 110%; font-variant: small-caps; }
+       </style>
+</head>
+<body>
+       <h1>${title}</h1>
+       
+       <!-- Personal information -->
+       <table class="personal">
+               <tr>
+                       <td><b>Name</b></td>
+                       <td>${nametitle} ${lastname}, ${firstname}</td>
+               </tr>
+               <tr>
+                       <td><b>Date of birth</b></td>
+                       <td>${dateofbirth}</td>
+               </tr>
+               <tr>
+                       <td><b>Marital status</b></td>
+                       <td>${maritalstatus}</td>
+               </tr>
+       </table>
+       
+       <!-- Career objectives -->
+       <h2>Career Objectives</h2>
+       <h3>Short Term Objectives</h3>
+       <ul>
+       ${shortterm}
+       </ul>   
+       <h3>Long Term Goals</h3>
+       <ul>
+       ${longterm}
+       </ul>
+       
+       <!-- Skill sets -->
+       <h2>Skill Sets</h2>
+       <dl>
+       ${skills}
+       </dl>
+       
+       <!-- Professional history/experience -->
+       <h2>Professional experience</h2>
+       ${profession}
+       
+       <!-- Educational qualifications -->
+       <h2>Educational qualifications</h2>
+       <table class="education">
+               <thead>
+                       <th>Qualification/Degree</th>
+                       <th>Month &amp; year of passing</th>
+                       <th>Name of Institution</th>
+                       <th>University</th>
+                       <th>Class/Grade</th>
+                       <th>Percentage</th>
+               </thead>
+               <tbody>
+               ${education}
+               </tbody>
+       </table>
+       
+       <h2>Languages known</h2>
+       <ul>
+               ${languages}
+       </ul>
+       
+       <h2>Contact information</h2>
+       <table class="contact">
+               <tr>
+                       <td><b>Residential address</b></td>
+                       <td>${street}, <br />${area},<br /><b>${city} - ${areacode}</b></td>
+               </tr>
+               <tr>
+                       <td><b>Landline</b></td>
+                       <td>${countrycode_landline} - ${landline}</td>
+               </tr>
+               <tr>
+                       <td><b>Mobile</b></td>
+                       <td>${countrycode_mobile} - ${mobile}</td>
+               </tr>
+               <tr>
+                       <td><b>Email address</b></td>
+                       <td>${email}</td>       
+               </tr>
+       </table>
+
+       <p class="miscinfo">${additionalinformation}</p>
+       
+       <p class="signature">${lastname}, ${firstname}</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/templates/default_xhtml/profession_bit.tpl b/templates/default_xhtml/profession_bit.tpl
new file mode 100644 (file)
index 0000000..341c80a
--- /dev/null
@@ -0,0 +1,3 @@
+       <h3>${dateofjoining} - ${dateofleaving} (with ${organization})
+       <p class="designation">Worked as ${designation}.</p>
+       <p>${additionalinfo}</p>
\ No newline at end of file
diff --git a/templates/default_xhtml/skill_bit.tpl b/templates/default_xhtml/skill_bit.tpl
new file mode 100644 (file)
index 0000000..3f5455c
--- /dev/null
@@ -0,0 +1,2 @@
+       <dt>${skilltitle}</dt>
+       <dd>${skilldesc}</dd>