X-Git-Url: https://harishankar.org/repos/?p=biacv.git;a=blobdiff_plain;f=biacv_exporter.py;h=1edb0e018355f951ac1f7931fe5253748130bb74;hp=8ba3c247acfd0eb238636c697fbaab872f9b44c5;hb=HEAD;hpb=c8e1ff6a6375828bc842406f25d4354425e6bbf8 diff --git a/biacv_exporter.py b/biacv_exporter.py index 8ba3c24..1edb0e0 100644 --- a/biacv_exporter.py +++ b/biacv_exporter.py @@ -10,6 +10,8 @@ import os.path class BiaCVExporter: def __init__ (self): self.data = {} + self.exporter_name = "" + self.export_filter = "" # set the document data def set_data (self, data): @@ -21,6 +23,9 @@ class BiaCVExporter: # fill education data template bit str_education = self._get_education () + # fill the profile highlight template bit + str_profile = self._get_profile () + # fill the professional history template bit str_profession = self._get_profession () @@ -35,6 +40,7 @@ class BiaCVExporter: # fill the main template str_main = self._get_main ( + str_profile, str_education, str_profession, str_shorttermobjectives, @@ -46,7 +52,7 @@ class BiaCVExporter: 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): + def _get_main (self, profile, education, profession, shortterm, longterm, skills, languages): # main template tpl_main = string.Template (codecs.open (self.fil_main, "r", "utf-8").read ()) @@ -64,6 +70,7 @@ class BiaCVExporter: lastname = self.data["lastname"], dateofbirth = self.data["dateofbirth"], maritalstatus = str_marital, + profile = profile, shortterm = shortterm, longterm = longterm, skills = skills, @@ -85,6 +92,20 @@ class BiaCVExporter: return str_main + # get the profile highlights list + def _get_profile (self): + tpl_profile = string.Template (codecs.open (self.fil_profile, "r", "utf-8").read ()) + + lst_profile = [] + # loop through each item + for item in self.data["profile"]: + str_profile = tpl_profile.safe_substitute ( + profile_item = item + ) + lst_profile.append (str_profile) + + return u'\n'.join (lst_profile) + # get the language list def _get_languages (self): tpl_language = string.Template (codecs.open (self.fil_language, "r", "utf-8").read ()) @@ -106,7 +127,7 @@ class BiaCVExporter: ) lst_languages.append (str_lang) - return "\n".join (lst_languages) + return u'\n'.join (lst_languages) # get the skills def _get_skills (self): @@ -122,7 +143,7 @@ class BiaCVExporter: ) lst_skills.append (str_skill) - return "\n".join (lst_skills) + return u'\n'.join (lst_skills) # get short term career objectives def _get_career (self): @@ -144,7 +165,7 @@ class BiaCVExporter: ) lst_longtermgoals.append (str_career) - return "\n".join (lst_shorttermcareer), "\n".join (lst_longtermgoals) + return u'\n'.join (lst_shorttermcareer), u'\n'.join (lst_longtermgoals) # fill the professional history template def _get_profession (self): @@ -167,7 +188,7 @@ class BiaCVExporter: ) lst_profession.append (str_profession) - return "\n".join (lst_profession) + return u'\n'.join (lst_profession) # fill the education template def _get_education (self): @@ -187,10 +208,16 @@ class BiaCVExporter: ) lst_education.append (str_education) - return "\n".join (lst_education) + return u'\n'.join (lst_education) # set the template directory and the files within def set_template_directory (self, templatedir): + # load the meta file for exporter title and name + file_meta = os.path.join (templatedir, "META-INFO") + lst_file_meta = (codecs.open (file_meta, 'r', "utf-8").read ()).splitlines () + self.exporter_name = lst_file_meta[0] + self.export_filter = lst_file_meta[1] + # set the template file names # main document template @@ -205,12 +232,15 @@ class BiaCVExporter: self.fil_skills = os.path.join (templatedir, "skill_bit.tpl") # languages learned bit self.fil_language = os.path.join (templatedir, "language_bit.tpl") + # profile bit + self.fil_profile = os.path.join (templatedir, "profile_bit.tpl") # load language strings 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): self.file_output = output