Unicode support added for export
[biacv.git] / biacv_exporter.py
index 3900c76..8ba3c24 100644 (file)
@@ -4,6 +4,7 @@
 # document fields.
 
 import string
+import codecs
 import os.path
 
 class BiaCVExporter:
@@ -42,12 +43,12 @@ class BiaCVExporter:
                                                str_languages)
 
                # write to export file
-               file (self.file_output, "w").write (str_main)
+               codecs.open (self.file_output, "w", "utf-8").write (str_main)
 
        # fill up the main template
        def _get_main (self, education, profession, shortterm, longterm, skills, languages):
                # main template
-               tpl_main = string.Template (file (self.fil_main, "r").read ())
+               tpl_main = string.Template (codecs.open (self.fil_main, "r", "utf-8").read ())
 
                if self.data["maritalstatus"] is True:
                        str_marital = self.lang_strings[3]
@@ -86,7 +87,7 @@ class BiaCVExporter:
 
        # get the language list
        def _get_languages (self):
-               tpl_language = string.Template (file (self.fil_language, "r").read ())
+               tpl_language = string.Template (codecs.open (self.fil_language, "r", "utf-8").read ())
 
                lst_languages = []
                # loop through each item
@@ -110,7 +111,7 @@ class BiaCVExporter:
        # get the skills
        def _get_skills (self):
                # load the template
-               tpl_skill = string.Template (file (self.fil_skills, "r").read ())
+               tpl_skill = string.Template (codecs.open (self.fil_skills, "r", "utf-8").read ())
 
                lst_skills = []
                # loop through each item
@@ -126,7 +127,7 @@ class BiaCVExporter:
        # get short term career objectives
        def _get_career (self):
                # load the template
-               tpl_career = string.Template (file (self.fil_career, "r").read ())
+               tpl_career = string.Template (codecs.open (self.fil_career, "r", "utf-8").read ())
 
                lst_shorttermcareer = []
                lst_longtermgoals = []
@@ -148,7 +149,7 @@ class BiaCVExporter:
        # fill the professional history template
        def _get_profession (self):
                # load the template
-               tpl_profession = string.Template (file (self.fil_profession, "r").read ())
+               tpl_profession = string.Template (codecs.open (self.fil_profession, "r", "utf-8").read ())
 
                lst_profession = []
                # loop through each item
@@ -171,7 +172,7 @@ class BiaCVExporter:
        # fill the education template
        def _get_education (self):
                # load the template
-               tpl_education = string.Template (file (self.fil_education, "r").read ())
+               tpl_education = string.Template (codecs.open (self.fil_education, "r", "utf-8").read ())
 
                lst_education = []
                # loop through each item
@@ -206,7 +207,9 @@ class BiaCVExporter:
                self.fil_language = os.path.join (templatedir, "language_bit.tpl")
 
                # load language strings
-               self.lang_strings = file (os.path.join (templatedir, "misc_strings.txt"), "r").readlines ()
+               lang_str = codecs.open (os.path.join (templatedir, "misc_strings.txt"), "r", "utf-8").read ()
+
+               self.lang_strings = lang_str.splitlines ()
 
        # set the output file
        def set_output (self, output):